diff options
author | w0rp <devw0rp@gmail.com> | 2017-04-11 20:32:57 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-04-11 20:32:57 +0100 |
commit | b06b832447253404180ce6a97927755e4ae68c22 (patch) | |
tree | b8b4b0592ffc245257869edca0066b425e1806f6 /test | |
parent | 8b890caa31411cd022156dca8e4c7f4c5fb65fc9 (diff) | |
download | ale-b06b832447253404180ce6a97927755e4ae68c22.zip |
#392 Report errors inside of headers, in a very basic way
Diffstat (limited to 'test')
-rw-r--r-- | test/c_tests/broken.h | 1 | ||||
-rw-r--r-- | test/c_tests/test_gcc.vader | 53 | ||||
-rw-r--r-- | test/handler/test_common_handlers.vader | 8 | ||||
-rw-r--r-- | test/handler/test_gcc_handler.vader | 68 | ||||
-rw-r--r-- | test/handler/test_swiftlint_handler.vader | 8 | ||||
-rw-r--r-- | test/handler/test_vint_handler.vader | 36 |
6 files changed, 147 insertions, 27 deletions
diff --git a/test/c_tests/broken.h b/test/c_tests/broken.h new file mode 100644 index 00000000..3bd3571a --- /dev/null +++ b/test/c_tests/broken.h @@ -0,0 +1 @@ +{{{ diff --git a/test/c_tests/test_gcc.vader b/test/c_tests/test_gcc.vader index 67e4e426..0bf3eb1d 100644 --- a/test/c_tests/test_gcc.vader +++ b/test/c_tests/test_gcc.vader @@ -34,12 +34,9 @@ Given c (A test C file): Execute(Basic errors should be returned for GCC for C files): call ale#Lint() - AssertEqual [{ - \ 'lnum': 3, - \ 'col': 1, - \ }], - \ map(getloclist(0), '{''lnum'': v:val.lnum, ''col'': v:val.col}'), - \ 'No errors returned! Got: ' . GetCommandOutput() + AssertEqual + \ [{'lnum': 3, 'col': 1}], + \ map(getloclist(0), '{''lnum'': v:val.lnum, ''col'': v:val.col}') Assert match(getloclist(0)[0].text, '\v^expected .*;.* before .*\}.* token$') >= 0, \ 'Invalid error text: ' . getloclist(0)[0].text @@ -52,12 +49,42 @@ Given cpp (A test C++ file): Execute(Basic errors should be returned for GCC for C++ files): call ale#Lint() - AssertEqual [{ - \ 'lnum': 3, - \ 'col': 1, - \ }], - \ map(getloclist(0), '{''lnum'': v:val.lnum, ''col'': v:val.col}'), - \ 'No errors returned! Got: ' . GetCommandOutput() + AssertEqual + \ [{'lnum': 3, 'col': 1}], + \ map(getloclist(0), '{''lnum'': v:val.lnum, ''col'': v:val.col}') Assert match(getloclist(0)[0].text, '\v^expected .*;.* before .*\}.* token$') >= 0, - \ 'Invalid error text: ' . getloclist(0)[0].text + +Given c (A test C file with a header containing broken code): + // Some comment line + #include "broken.h" + + int main() { + return 0 + } + +Execute(Basic errors should be returned for GCC for C files with headers): + call ale#Lint() + + AssertEqual + \ [{'lnum': 2, 'col': 0}], + \ map(getloclist(0), '{''lnum'': v:val.lnum, ''col'': v:val.col}') + + AssertEqual 'Problems were found in the header (See :ALEDetail)', getloclist(0)[0].text + +Given cpp (A test C++ file with a header containing broken code): + // Some comment line + #include "broken.h" + + int main() { + return 0 + } + +Execute(Basic errors should be returned for GCC for C++ files with headers): + call ale#Lint() + + AssertEqual + \ [{'lnum': 2, 'col': 0}], + \ map(getloclist(0), '{''lnum'': v:val.lnum, ''col'': v:val.col}') + + AssertEqual 'Problems were found in the header (See :ALEDetail)', getloclist(0)[0].text diff --git a/test/handler/test_common_handlers.vader b/test/handler/test_common_handlers.vader index 0968a916..f087fb55 100644 --- a/test/handler/test_common_handlers.vader +++ b/test/handler/test_common_handlers.vader @@ -55,7 +55,7 @@ Then (The loclist should be correct): \], g:loclist Execute (Run HandleGCCFormat): - let g:loclist = ale#handlers#HandleGCCFormat(42, [ + let g:loclist = ale#handlers#gcc#HandleGCCFormat(42, [ \ '<stdin>:8:5: warning: conversion lacks type at end of format [-Wformat=]', \ '<stdin>:10:27: error: invalid operands to binary - (have ‘int’ and ‘char *’)', \]) @@ -63,18 +63,12 @@ Execute (Run HandleGCCFormat): Then (The loclist should be correct): AssertEqual [ \ { - \ 'bufnr': 42, - \ 'vcol': 0, - \ 'nr': -1, \ 'lnum': 8, \ 'col': 5, \ 'type': 'W', \ 'text': 'conversion lacks type at end of format [-Wformat=]', \ }, \ { - \ 'bufnr': 42, - \ 'vcol': 0, - \ 'nr': -1, \ 'lnum': 10, \ 'col': 27, \ 'type': 'E', diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader new file mode 100644 index 00000000..3d5a24d4 --- /dev/null +++ b/test/handler/test_gcc_handler.vader @@ -0,0 +1,68 @@ +Execute(GCC errors from included files should be parsed correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 3, + \ 'type': 'E', + \ 'text': 'Problems were found in the header (See :ALEDetail)', + \ 'detail': join([ + \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token', + \ ' {{{', + \ ' ^', + \ ], "\n"), + \ }, + \ ], + \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ 'In file included from <stdin>:3:0:', + \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token', + \ ' {{{', + \ ' ^', + \ ]) + + AssertEqual + \ [ + \ { + \ 'lnum': 3, + \ 'type': 'E', + \ 'text': 'Problems were found in the header (See :ALEDetail)', + \ 'detail': join([ + \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token', + \ ' {{{', + \ ' ^', + \ ], "\n"), + \ }, + \ ], + \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ 'In file included from a.h:1:0,', + \ ' from test.c:3:', + \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token', + \ ' {{{', + \ ' ^', + \ ]) + + AssertEqual + \ [ + \ { + \ 'lnum': 3, + \ 'type': 'E', + \ 'text': 'Problems were found in the header (See :ALEDetail)', + \ 'detail': join([ + \ '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#HandleGCCFormat(347, [ + \ 'In file included from a.h:1:0,', + \ ' from test.c: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;', + \ ' ^', + \ ]) diff --git a/test/handler/test_swiftlint_handler.vader b/test/handler/test_swiftlint_handler.vader index 42fc8242..b77b4420 100644 --- a/test/handler/test_swiftlint_handler.vader +++ b/test/handler/test_swiftlint_handler.vader @@ -2,26 +2,20 @@ Execute(The swiftint handler should parse error messages correctly): AssertEqual \ [ \ { - \ 'bufnr': 347, \ 'lnum': 1, \ 'col': 7, \ 'text': 'Operator Usage Whitespace Violation: Operators should be surrounded by a single whitespace when they are being used. (operator_usage_whitespace)', \ 'type': 'W', - \ 'vcol': 0, - \ 'nr': -1, \ }, \ { - \ 'bufnr': 347, \ 'lnum': 1, \ 'col': 11, \ 'text': 'Operator Usage Whitespace Violation: Operators should be surrounded by a single whitespace when they are being used. (operator_usage_whitespace)', \ 'type': 'W', - \ 'vcol': 0, - \ 'nr': -1, \ }, \ \ ], - \ ale#handlers#HandleGCCFormat(347, [ + \ ale#handlers#gcc#HandleGCCFormat(347, [ \ 'This line should be ignored', \ '<nopath>:1:7: warning: Operator Usage Whitespace Violation: Operators should be surrounded by a single whitespace when they are being used. (operator_usage_whitespace)', \ '<nopath>:1:11: warning: Operator Usage Whitespace Violation: Operators should be surrounded by a single whitespace when they are being used. (operator_usage_whitespace)', diff --git a/test/handler/test_vint_handler.vader b/test/handler/test_vint_handler.vader new file mode 100644 index 00000000..efd33d10 --- /dev/null +++ b/test/handler/test_vint_handler.vader @@ -0,0 +1,36 @@ +Execute(The vint handler should parse error messages correctly): + :file! gxc.vim + + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 1, + \ 'text': 'Use scriptencoding when multibyte char exists (see :help :script encoding)', + \ 'type': 'W', + \ }, + \ { + \ 'lnum': 3, + \ 'col': 17, + \ 'text': 'Use robust operators `==#` or `==?` instead of `==` (see Google VimScript Style Guide (Matching))', + \ 'type': 'W', + \ }, + \ { + \ 'lnum': 3, + \ 'col': 8, + \ 'text': 'Make the scope explicit like `l:filename` (see Anti-pattern of vimrc (Scope of identifier))', + \ 'type': 'W', + \ }, + \ { + \ 'lnum': 7, + \ 'col': 8, + \ 'text': 'Undefined variable: filename (see :help E738)', + \ 'type': 'W', + \ }, + \ ], + \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ 'gcc.vim:1:1: warning: Use scriptencoding when multibyte char exists (see :help :script encoding)', + \ 'gcc.vim:3:17: warning: Use robust operators `==#` or `==?` instead of `==` (see Google VimScript Style Guide (Matching))', + \ 'gcc.vim:3:8: style_problem: Make the scope explicit like `l:filename` (see Anti-pattern of vimrc (Scope of identifier))', + \ 'gcc.vim:7:8: warning: Undefined variable: filename (see :help E738)', + \ ]) |