diff options
Diffstat (limited to 'test/handler')
-rw-r--r-- | test/handler/test_checkmake_handler.vader | 19 | ||||
-rw-r--r-- | test/handler/test_clang_handler.vader | 12 | ||||
-rw-r--r-- | test/handler/test_gcc_handler.vader | 74 | ||||
-rw-r--r-- | test/handler/test_php_phan_handler.vader | 24 | ||||
-rw-r--r-- | test/handler/test_php_phpmd_handler.vader | 24 | ||||
-rw-r--r-- | test/handler/test_remark_lint_handler.vader | 27 | ||||
-rw-r--r-- | test/handler/test_vint_handler.vader | 6 | ||||
-rw-r--r-- | test/handler/test_write_good_handler.vader | 37 |
8 files changed, 191 insertions, 32 deletions
diff --git a/test/handler/test_checkmake_handler.vader b/test/handler/test_checkmake_handler.vader new file mode 100644 index 00000000..61fe141a --- /dev/null +++ b/test/handler/test_checkmake_handler.vader @@ -0,0 +1,19 @@ +Execute(Parsing checkmake errors should work): + runtime ale_linters/make/checkmake.vim + silent file Makefile + + AssertEqual + \ [ + \ { + \ 'bufnr': 42, + \ 'lnum': 1, + \ 'type': 'E', + \ 'text': 'woops: an error has occurred', + \ } + \ ], + \ ale_linters#make#checkmake#Handle(42, [ + \ 'This shouldnt match', + \ '1:woops:an error has occurred', + \ ]) +After: + call ale#linter#Reset() diff --git a/test/handler/test_clang_handler.vader b/test/handler/test_clang_handler.vader index d28b9eb8..278737a8 100644 --- a/test/handler/test_clang_handler.vader +++ b/test/handler/test_clang_handler.vader @@ -2,15 +2,11 @@ Execute(clang errors from included files should be parsed correctly): AssertEqual \ [ \ { - \ 'lnum': 3, + \ 'lnum': 1, + \ 'col': 1, + \ 'filename': './b.h', \ 'type': 'E', - \ 'text': 'Problems were found in the header (See :ALEDetail)', - \ 'detail': join([ - \ './b.h:1:1: error: expected identifier or ''(''', - \ '{{{', - \ '^', - \ '1 error generated.', - \ ], "\n"), + \ 'text': 'expected identifier or ''(''', \ }, \ ], \ ale#handlers#gcc#HandleGCCFormat(347, [ diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader index 2f60390c..9324273e 100644 --- a/test/handler/test_gcc_handler.vader +++ b/test/handler/test_gcc_handler.vader @@ -1,15 +1,21 @@ +Execute(The GCC handler should ignore other lines of output): + AssertEqual + \ [], + \ ale#handlers#gcc#HandleGCCFormat(347, [ + \ 'foo', + \ 'bar', + \ 'baz', + \ ]) + Execute(GCC errors from included files should be parsed correctly): AssertEqual \ [ \ { - \ 'lnum': 3, + \ 'lnum': 1, + \ 'col': 1, + \ 'filename': 'broken.h', \ 'type': 'E', - \ 'text': 'Problems were found in the header (See :ALEDetail)', - \ 'detail': join([ - \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token', - \ ' {{{', - \ ' ^', - \ ], "\n"), + \ 'text': 'expected identifier or ''('' before ''{'' token', \ }, \ ], \ ale#handlers#gcc#HandleGCCFormat(347, [ @@ -22,14 +28,11 @@ Execute(GCC errors from included files should be parsed correctly): AssertEqual \ [ \ { - \ 'lnum': 3, + \ 'lnum': 1, + \ 'col': 1, + \ 'filename': 'b.h', \ 'type': 'E', - \ 'text': 'Problems were found in the header (See :ALEDetail)', - \ 'detail': join([ - \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token', - \ ' {{{', - \ ' ^', - \ ], "\n"), + \ 'text': 'expected identifier or ''('' before ''{'' token', \ }, \ ], \ ale#handlers#gcc#HandleGCCFormat(347, [ @@ -43,17 +46,18 @@ Execute(GCC errors from included files should be parsed correctly): AssertEqual \ [ \ { - \ 'lnum': 3, + \ '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': '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"), + \ 'text': 'unknown type name ''other_bad_type''', \ }, \ ], \ ale#handlers#gcc#HandleGCCFormat(347, [ @@ -133,3 +137,25 @@ Execute(The GCC handler should handle syntax errors): \ '<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#HandleGCCFormat(347, [ + \ '<stdin>:1:1: note: x', + \ '<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#HandleGCCFormat(347, [ + \ '-:6:12: error: Some error', + \ ]) diff --git a/test/handler/test_php_phan_handler.vader b/test/handler/test_php_phan_handler.vader new file mode 100644 index 00000000..68ed6d06 --- /dev/null +++ b/test/handler/test_php_phan_handler.vader @@ -0,0 +1,24 @@ +Before: + runtime ale_linters/php/phan.vim + +Execute(The php static analyzer handler should parse errors from phan): + AssertEqual + \ [ + \ { + \ 'lnum': 25, + \ 'type': 'W', + \ 'text': 'Return type of getValidator is undeclared type \Respect\Validation\Validator', + \ }, + \ { + \ 'lnum': 66, + \ 'type': 'W', + \ 'text': 'Call to method string from undeclared class \Respect\Validation\Validator', + \ }, + \ ], + \ ale_linters#php#phan#Handle(347, [ + \ "example.php:25 PhanUndeclaredTypeReturnType Return type of getValidator is undeclared type \\Respect\\Validation\\Validator", + \ "example.php:66 PhanUndeclaredClassMethod Call to method string from undeclared class \\Respect\\Validation\\Validator", + \ ]) + +After: + call ale#linter#Reset() diff --git a/test/handler/test_php_phpmd_handler.vader b/test/handler/test_php_phpmd_handler.vader new file mode 100644 index 00000000..be36f3db --- /dev/null +++ b/test/handler/test_php_phpmd_handler.vader @@ -0,0 +1,24 @@ +Before: + runtime ale_linters/php/phpmd.vim + +Execute(The php static analyzer handler should parse errors from phpmd): + AssertEqual + \ [ + \ { + \ 'lnum': 22, + \ 'type': 'W', + \ 'text': "Avoid unused local variables such as '$response'.", + \ }, + \ { + \ 'lnum': 14, + \ 'type': 'W', + \ 'text': "The method test uses an else expression. Else is never necessary and you can simplify the code to work without else.", + \ }, + \ ], + \ ale_linters#php#phpmd#Handle(347, [ + \ "example.php:22 Avoid unused local variables such as '$response'.", + \ "example.php:14 The method test uses an else expression. Else is never necessary and you can simplify the code to work without else.", + \ ]) + +After: + call ale#linter#Reset() diff --git a/test/handler/test_remark_lint_handler.vader b/test/handler/test_remark_lint_handler.vader new file mode 100644 index 00000000..f63e0c5b --- /dev/null +++ b/test/handler/test_remark_lint_handler.vader @@ -0,0 +1,27 @@ +Before: + runtime ale_linters/markdown/remark_lint.vim + +Execute(Warning and error messages should be handled correctly): + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 4, + \ 'type': 'W', + \ 'text': 'Incorrect list-item indent: add 1 space list-item-indent remark-lint', + \ }, + \ { + \ 'lnum': 3, + \ 'col': 5, + \ 'type': 'E', + \ 'text': 'Incorrect list-item indent: remove 1 space list-item-indent remark-lint', + \ }, + \ ], + \ ale_linters#markdown#remark_lint#Handle(1, [ + \ 'foo.md', + \ ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint', + \ ' 3:5 error Incorrect list-item indent: remove 1 space list-item-indent remark-lint', + \ '', + \ '⚠ 1 warnings', + \ '✘ 1 errors', + \]) diff --git a/test/handler/test_vint_handler.vader b/test/handler/test_vint_handler.vader index 8747979c..c542b4ea 100644 --- a/test/handler/test_vint_handler.vader +++ b/test/handler/test_vint_handler.vader @@ -10,12 +10,14 @@ Execute(The vint handler should parse error messages correctly): \ { \ 'lnum': 1, \ 'col': 1, + \ 'filename': 'gcc.vim', \ 'text': 'Use scriptencoding when multibyte char exists (see :help :script encoding)', \ 'type': 'W', \ }, \ { \ 'lnum': 3, \ 'col': 17, + \ 'filename': 'gcc.vim', \ 'end_col': 18, \ 'text': 'Use robust operators ''==#'' or ''==?'' instead of ''=='' (see Google VimScript Style Guide (Matching))', \ 'type': 'W', @@ -23,6 +25,7 @@ Execute(The vint handler should parse error messages correctly): \ { \ 'lnum': 3, \ 'col': 8, + \ 'filename': 'gcc.vim', \ 'end_col': 15, \ 'text': 'Make the scope explicit like ''l:filename'' (see Anti-pattern of vimrc (Scope of identifier))', \ 'type': 'W', @@ -30,6 +33,7 @@ Execute(The vint handler should parse error messages correctly): \ { \ 'lnum': 7, \ 'col': 8, + \ 'filename': 'gcc.vim', \ 'end_col': 15, \ 'text': 'Undefined variable: filename (see :help E738)', \ 'type': 'W', @@ -37,6 +41,7 @@ Execute(The vint handler should parse error messages correctly): \ { \ 'lnum': 8, \ 'col': 11, + \ 'filename': 'gcc.vim', \ 'end_col': 16, \ 'text': 'E128: Function name must start with a capital or contain a colon: foobar (see ynkdir/vim-vimlparser)', \ 'type': 'E', @@ -44,6 +49,7 @@ Execute(The vint handler should parse error messages correctly): \ { \ 'lnum': 9, \ 'col': 12, + \ 'filename': 'gcc.vim', \ 'end_col': 13, \ 'text': 'Use robust operators ''=~#'' or ''=~?'' instead of ''=~'' (see Google VimScript Style Guide (Matching))', \ 'type': 'W', diff --git a/test/handler/test_write_good_handler.vader b/test/handler/test_write_good_handler.vader new file mode 100644 index 00000000..8bf4b223 --- /dev/null +++ b/test/handler/test_write_good_handler.vader @@ -0,0 +1,37 @@ +Execute(The write-good handler should handle the example from the write-good README): + AssertEqual + \ [ + \ { + \ 'lnum': 1, + \ 'col': 1, + \ 'end_col': 2, + \ 'type': 'W', + \ 'text': '"So" adds no meaning', + \ }, + \ { + \ 'lnum': 1, + \ 'col': 12, + \ 'end_col': 21, + \ 'type': 'W', + \ 'text': '"was stolen" may be passive voice', + \ }, + \ { + \ 'lnum': 6, + \ 'col': 2, + \ 'end_col': 2, + \ 'type': 'W', + \ 'text': '"foo bar" bla', + \ }, + \ ], + \ ale#handlers#writegood#Handle(bufnr(''), [ + \ 'In /tmp/vBYivbZ/6/test.md', + \ '=============', + \ 'So the cat was stolen.', + \ '^^', + \ '"So" adds no meaning on line 1 at column 0', + \ '-------------', + \ 'So the cat was stolen.', + \ ' ^^^^^^^^^^', + \ '"was stolen" may be passive voice on line 1 at column 11', + \ '"foo bar" bla on line 6 at column 1', + \ ]) |