summaryrefslogtreecommitdiff
path: root/test/handler/test_gcc_handler.vader
blob: 3daa9e60e325b30f8ffba7481c7991d9a8400294 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
Execute(The GCC handler should ignore other lines of output):
  AssertEqual
  \ [],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \   'foo',
  \   'bar',
  \   'baz',
  \ ])

Execute(GCC errors from included files should be parsed correctly):
  AssertEqual
  \ [
  \   {
  \     'lnum': 1,
  \     'col': 1,
  \     'filename': 'broken.h',
  \     'type': 'E',
  \     'text': 'expected identifier or ''('' before ''{'' token',
  \   },
  \   {
  \     'lnum': 3,
  \     'col': 2,
  \     'text': 'Error found in header. See :ALEDetail',
  \     'detail': join([
  \       'In file included from <stdin>:3:2:',
  \       'broken.h:1:1: error: expected identifier or ''('' before ''{'' token',
  \       ' {{{',
  \       ' ^',
  \     ], "\n"),
  \   },
  \ ],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \   'In file included from <stdin>:3:2:',
  \   'broken.h:1:1: error: expected identifier or ''('' before ''{'' token',
  \   ' {{{',
  \   ' ^',
  \   'compilation terminated.',
  \ ])

  AssertEqual
  \ [
  \   {
  \     'lnum': 1,
  \     'col': 1,
  \     'filename': 'b.h',
  \     'type': 'E',
  \     'text': 'expected identifier or ''('' before ''{'' token',
  \   },
  \   {
  \     'lnum': 5,
  \     'text': 'Error found in header. See :ALEDetail',
  \     'detail': join([
  \       'In file included from a.h:1:0,',
  \       '                 from <stdin>:5:',
  \       'b.h:1:1: error: expected identifier or ''('' before ''{'' token',
  \       ' {{{',
  \       ' ^',
  \     ], "\n"),
  \   },
  \ ],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \   'In file included from a.h:1:0,',
  \   '                 from <stdin>:5:',
  \   'b.h:1:1: error: expected identifier or ''('' before ''{'' token',
  \   ' {{{',
  \   ' ^',
  \   'compilation terminated.',
  \ ])

  AssertEqual
  \ [
  \   {
  \     'lnum': 1,
  \     'col': 1,
  \     'filename': 'b.h',
  \     'type': 'E',
  \     'text': 'unknown type name ''bad_type''',
  \   },
  \   {
  \     'lnum': 2,
  \     'col': 1,
  \     'filename': 'b.h',
  \     'type': 'E',
  \     'text': 'unknown type name ''other_bad_type''',
  \   },
  \   {
  \     'lnum': 3,
  \     'text': 'Error found in header. See :ALEDetail',
  \     'detail': join([
  \       'In file included from a.h:1:0,',
  \       '                 from <stdin>:3:',
  \       'b.h:1:1: error: unknown type name ‘bad_type’',
  \       ' bad_type x;',
  \       ' ^',
  \       'b.h:2:1: error: unknown type name ‘other_bad_type’',
  \       ' other_bad_type y;',
  \       ' ^',
  \     ], "\n"),
  \   },
  \ ],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \   'In file included from a.h:1:0,',
  \   '                 from <stdin>:3:',
  \   'b.h:1:1: error: unknown type name ‘bad_type’',
  \   ' bad_type x;',
  \   ' ^',
  \   'b.h:2:1: error: unknown type name ‘other_bad_type’',
  \   ' other_bad_type y;',
  \   ' ^',
  \   'compilation terminated.',
  \ ])

Execute(The GCC handler shouldn't complain about #pragma once for headers):
  silent file! test.h

  AssertEqual
  \ [],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \   '<stdin>:1:1: warning: #pragma once in main file [enabled by default]',
  \ ])

  silent file! test.hpp

  AssertEqual
  \ [],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \   '<stdin>:1:1: warning: #pragma once in main file [enabled by default]',
  \ ])

Execute(The GCC handler should handle syntax errors):
  AssertEqual
  \ [
  \   {
  \     'lnum': 6,
  \     'col': 12,
  \     'type': 'E',
  \     'text': 'invalid suffix "p" on integer constant'
  \   },
  \   {
  \     'lnum': 17,
  \     'col': 5,
  \     'type': 'E',
  \     'text': 'invalid suffix "n" on integer constant'
  \   },
  \   {
  \     'lnum': 4,
  \     'type': 'E',
  \     'text': 'variable or field ''foo'' declared void'
  \   },
  \   {
  \     'lnum': 4,
  \     'type': 'E',
  \     'text': '''cat'' was not declared in this scope'
  \   },
  \   {
  \     'lnum': 12,
  \     'type': 'E',
  \     'text': 'expected '';'' before ''o'''
  \   },
  \ ],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \ '<stdin>:6:12: error: invalid suffix "p" on integer constant',
  \ '<stdin>:17:5: error: invalid suffix "n" on integer constant',
  \ '<stdin>:4: error: variable or field ''foo'' declared void',
  \ '<stdin>:4: error: ''cat'' was not declared in this scope',
  \ '<stdin>:12: error: expected `;'' before ''o''',
  \ ])

Execute(The GCC handler should handle notes with no previous message):
  AssertEqual
  \ [],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \   '<stdin>:1:1: note: x',
  \   '<stdin>:1:1: note: x',
  \ ])

Execute(The GCC handler should attach notes to previous messages):
  AssertEqual
  \ [
  \   {
  \     'lnum': 6,
  \     'col': 12,
  \     'type': 'E',
  \     'text': 'Some error',
  \     'detail': "Some error\n<stdin>:1:1: note: x",
  \   },
  \ ],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \   '-:6:12: error: Some error',
  \   '<stdin>:1:1: note: x',
  \ ])

Execute(The GCC handler should interpret - as being the current file):
  AssertEqual
  \ [
  \   {
  \     'lnum': 6,
  \     'col': 12,
  \     'type': 'E',
  \     'text': 'Some error',
  \   },
  \ ],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \ '-:6:12: error: Some error',
  \ ])

Execute(The GCC handler should handle fatal error messages due to missing files):
  AssertEqual
  \ [
  \   {
  \     'lnum': 3,
  \     'col': 12,
  \     'type': 'E',
  \     'text': 'foo.h: No such file or directory'
  \   },
  \ ],
  \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [
  \ '<stdin>:3:12: fatal error: foo.h: No such file or directory',
  \ ])