test_gcc_handler.vader
1 Execute(The GCC handler should ignore other lines of output): 2 AssertEqual 3 \ [], 4 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, ['foo', 'bar', 'baz']) 5 6 Execute(GCC errors from included files should be parsed correctly): 7 AssertEqual 8 \ [ 9 \ { 10 \ 'lnum': 1, 11 \ 'col': 1, 12 \ 'filename': 'broken.h', 13 \ 'type': 'E', 14 \ 'text': 'expected identifier or ''('' before ''{'' token', 15 \ }, 16 \ { 17 \ 'lnum': 3, 18 \ 'col': 2, 19 \ 'text': 'Error found in header. See :ALEDetail', 20 \ 'detail': join([ 21 \ 'In file included from <stdin>:3:2:', 22 \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token', 23 \ ' {{{', 24 \ ' ^', 25 \ ], "\n"), 26 \ }, 27 \ ], 28 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 29 \ 'In file included from <stdin>:3:2:', 30 \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token', 31 \ ' {{{', 32 \ ' ^', 33 \ 'compilation terminated.', 34 \ ]) 35 36 AssertEqual 37 \ [ 38 \ { 39 \ 'lnum': 1, 40 \ 'col': 1, 41 \ 'filename': 'b.h', 42 \ 'type': 'E', 43 \ 'text': 'expected identifier or ''('' before ''{'' token', 44 \ }, 45 \ { 46 \ 'lnum': 5, 47 \ 'text': 'Error found in header. See :ALEDetail', 48 \ 'detail': join([ 49 \ 'In file included from a.h:1:0,', 50 \ ' from <stdin>:5:', 51 \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token', 52 \ ' {{{', 53 \ ' ^', 54 \ ], "\n"), 55 \ }, 56 \ ], 57 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 58 \ 'In file included from a.h:1:0,', 59 \ ' from <stdin>:5:', 60 \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token', 61 \ ' {{{', 62 \ ' ^', 63 \ 'compilation terminated.', 64 \ ]) 65 66 AssertEqual 67 \ [ 68 \ { 69 \ 'lnum': 1, 70 \ 'col': 1, 71 \ 'filename': 'b.h', 72 \ 'type': 'E', 73 \ 'text': 'unknown type name ''bad_type''', 74 \ }, 75 \ { 76 \ 'lnum': 2, 77 \ 'col': 1, 78 \ 'filename': 'b.h', 79 \ 'type': 'E', 80 \ 'text': 'unknown type name ''other_bad_type''', 81 \ }, 82 \ { 83 \ 'lnum': 3, 84 \ 'text': 'Error found in header. See :ALEDetail', 85 \ 'detail': join([ 86 \ 'In file included from a.h:1:0,', 87 \ ' from <stdin>:3:', 88 \ 'b.h:1:1: error: unknown type name ‘bad_type’', 89 \ ' bad_type x;', 90 \ ' ^', 91 \ 'b.h:2:1: error: unknown type name ‘other_bad_type’', 92 \ ' other_bad_type y;', 93 \ ' ^', 94 \ ], "\n"), 95 \ }, 96 \ ], 97 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 98 \ 'In file included from a.h:1:0,', 99 \ ' from <stdin>:3:', 100 \ 'b.h:1:1: error: unknown type name ‘bad_type’', 101 \ ' bad_type x;', 102 \ ' ^', 103 \ 'b.h:2:1: error: unknown type name ‘other_bad_type’', 104 \ ' other_bad_type y;', 105 \ ' ^', 106 \ 'compilation terminated.', 107 \ ]) 108 109 Execute(The GCC handler shouldn't complain about #pragma once for headers): 110 silent file! test.h 111 112 AssertEqual 113 \ [], 114 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 115 \ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]', 116 \ ]) 117 118 silent file! test.hpp 119 120 AssertEqual 121 \ [], 122 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 123 \ '<stdin>:1:1: warning: #pragma once in main file [enabled by default]', 124 \ ]) 125 126 Execute(The GCC handler should handle syntax errors): 127 AssertEqual 128 \ [ 129 \ { 130 \ 'lnum': 6, 131 \ 'col': 12, 132 \ 'type': 'E', 133 \ 'text': 'invalid suffix "p" on integer constant' 134 \ }, 135 \ { 136 \ 'lnum': 17, 137 \ 'col': 5, 138 \ 'type': 'E', 139 \ 'text': 'invalid suffix "n" on integer constant' 140 \ }, 141 \ { 142 \ 'lnum': 4, 143 \ 'type': 'E', 144 \ 'text': 'variable or field ''foo'' declared void' 145 \ }, 146 \ { 147 \ 'lnum': 4, 148 \ 'type': 'E', 149 \ 'text': '''cat'' was not declared in this scope' 150 \ }, 151 \ { 152 \ 'lnum': 12, 153 \ 'type': 'E', 154 \ 'text': 'expected '';'' before ''o''' 155 \ }, 156 \ ], 157 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 158 \ '<stdin>:6:12: error: invalid suffix "p" on integer constant', 159 \ '<stdin>:17:5: error: invalid suffix "n" on integer constant', 160 \ '<stdin>:4: error: variable or field ''foo'' declared void', 161 \ '<stdin>:4: error: ''cat'' was not declared in this scope', 162 \ '<stdin>:12: error: expected `;'' before ''o''', 163 \ ]) 164 165 Execute(The GCC handler should handle notes with no previous message): 166 AssertEqual 167 \ [], 168 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 169 \ '<stdin>:1:1: note: x', 170 \ '<stdin>:1:1: note: x', 171 \ ]) 172 173 Execute(The GCC handler should attach notes to previous messages): 174 AssertEqual 175 \ [ 176 \ { 177 \ 'lnum': 6, 178 \ 'col': 12, 179 \ 'type': 'E', 180 \ 'text': 'Some error', 181 \ 'detail': "Some error\n<stdin>:1:1: note: x", 182 \ }, 183 \ ], 184 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 185 \ '-:6:12: error: Some error', 186 \ '<stdin>:1:1: note: x', 187 \ ]) 188 189 Execute(The GCC handler should interpret - as being the current file): 190 AssertEqual 191 \ [ 192 \ { 193 \ 'lnum': 6, 194 \ 'col': 12, 195 \ 'type': 'E', 196 \ 'text': 'Some error', 197 \ }, 198 \ ], 199 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 200 \ '-:6:12: error: Some error', 201 \ ]) 202 203 Execute(The GCC handler should handle fatal error messages due to missing files): 204 AssertEqual 205 \ [ 206 \ { 207 \ 'lnum': 3, 208 \ 'col': 12, 209 \ 'type': 'E', 210 \ 'text': 'foo.h: No such file or directory' 211 \ }, 212 \ ], 213 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 214 \ '<stdin>:3:12: fatal error: foo.h: No such file or directory', 215 \ ]) 216 217 Execute(The GCC handler should handle errors for inlined header functions): 218 AssertEqual 219 \ [ 220 \ { 221 \ 'lnum': 50, 222 \ 'col': 4, 223 \ 'filename': '/usr/include/bits/fcntl2.h', 224 \ 'type': 'E', 225 \ 'text': 'call to ''__open_missing_mode'' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments', 226 \ }, 227 \ { 228 \ 'lnum': 44, 229 \ 'col': 5, 230 \ 'filename': '/usr/include/bits/fcntl2.h', 231 \ 'type': 'E', 232 \ 'text': 'call to ''__open_too_many_args'' declared with attribute error: open can be called either with 2 or 3 arguments, not more', 233 \ }, 234 \ { 235 \ 'lnum': 7, 236 \ 'col': 10, 237 \ 'type': 'E', 238 \ 'text': 'call to ''__open_missing_mode'' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments', 239 \ }, 240 \ { 241 \ 'lnum': 13, 242 \ 'col': 11, 243 \ 'type': 'E', 244 \ 'text': 'call to ''__open_too_many_args'' declared with attribute error: open can be called either with 2 or 3 arguments, not more', 245 \ }, 246 \ { 247 \ 'lnum': 1, 248 \ 'text': 'Error found in header. See :ALEDetail', 249 \ 'detail': join([ 250 \ 'In file included from /usr/include/fcntl.h:328,', 251 \ ' from <stdin>:1:', 252 \ 'In function ‘open’,', 253 \ ' inlined from ‘main’ at <stdin>:7:10:', 254 \ '/usr/include/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments', 255 \ ' __open_missing_mode ();', 256 \ ' ^~~~~~~~~~~~~~~~~~~~~~', 257 \ 'In function ‘open’,', 258 \ ' inlined from ‘main’ at <stdin>:13:11:', 259 \ '/usr/include/bits/fcntl2.h:44:5: error: call to ‘__open_too_many_args’ declared with attribute error: open can be called either with 2 or 3 arguments, not more', 260 \ ' __open_too_many_args ();', 261 \ ], "\n") 262 \ }, 263 \], 264 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 265 \ 'In file included from /usr/include/fcntl.h:328,', 266 \ ' from <stdin>:1:', 267 \ 'In function ‘open’,', 268 \ ' inlined from ‘main’ at <stdin>:7:10:', 269 \ '/usr/include/bits/fcntl2.h:50:4: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments', 270 \ ' __open_missing_mode ();', 271 \ ' ^~~~~~~~~~~~~~~~~~~~~~', 272 \ 'In function ‘open’,', 273 \ ' inlined from ‘main’ at <stdin>:13:11:', 274 \ '/usr/include/bits/fcntl2.h:44:5: error: call to ‘__open_too_many_args’ declared with attribute error: open can be called either with 2 or 3 arguments, not more', 275 \ ' __open_too_many_args ();', 276 \ ' ^~~~~~~~~~~~~~~~~~~~~~~', 277 \ ]) 278 279 Execute(The GCC handler should handle macro expansion errors in current file): 280 AssertEqual 281 \ [ 282 \ { 283 \ 'lnum': 1, 284 \ 'col': 19, 285 \ 'type': 'E', 286 \ 'text': 'error message', 287 \ 'detail': "error message\n<stdin>:1:19: note: in expansion of macro 'TEST'", 288 \ }, 289 \ ], 290 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 291 \ '<command-line>: error: error message', 292 \ '<stdin>:1:19: note: in expansion of macro ‘TEST’', 293 \ ' 1 | std::string str = TEST;', 294 \ ' | ^~~~', 295 \ ]) 296 297 Execute(The GCC handler should handle macro expansion errors in other files): 298 AssertEqual 299 \ [ 300 \ { 301 \ 'lnum': 0, 302 \ 'type': 'E', 303 \ 'text': 'Error found in macro expansion. See :ALEDetail', 304 \ 'detail': "error message\ninc.h:1:19: note: in expansion of macro 'TEST'", 305 \ }, 306 \ ], 307 \ ale#handlers#gcc#HandleGCCFormatWithIncludes(347, [ 308 \ '<command-line>: error: error message', 309 \ 'inc.h:1:19: note: in expansion of macro ‘TEST’', 310 \ ' 1 | std::string str = TEST;', 311 \ ' | ^~~~', 312 \ ])