mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-30 08:04:31 +08:00
Group handler test cases in a directory
This commit is contained in:
208
test/handler/test_common_handlers.vader
Normal file
208
test/handler/test_common_handlers.vader
Normal file
@@ -0,0 +1,208 @@
|
||||
Execute (Run HandleCSSLintFormat):
|
||||
let g:loclist = ale#handlers#HandleCSSLintFormat(42, [
|
||||
\ 'something.css: line 2, col 1, Error - Expected RBRACE at line 2, col 1. (errors)',
|
||||
\ "something.css: line 2, col 5, Warning - Expected ... but found 'wat'. (known-properties)",
|
||||
\])
|
||||
|
||||
Then (The loclist should be correct):
|
||||
AssertEqual [
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': '(errors) Expected RBRACE at line 2, col 1.',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 5,
|
||||
\ 'type': 'W',
|
||||
\ 'text': "(known-properties) Expected ... but found 'wat'.",
|
||||
\ },
|
||||
\], g:loclist
|
||||
|
||||
Execute (Run HandlePEP8Format):
|
||||
let g:loclist = ale#handlers#HandlePEP8Format(42, [
|
||||
\ "stdin:6:6: E111 indentation is not a multiple of four",
|
||||
\ "test.yml:35: [EANSIBLE0002] Trailing whitespace",
|
||||
\])
|
||||
|
||||
Then (The loclist should be correct):
|
||||
AssertEqual [
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 6,
|
||||
\ 'col': 6,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'E111: indentation is not a multiple of four',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 35,
|
||||
\ 'col': 0,
|
||||
\ 'type': 'E',
|
||||
\ 'text': "EANSIBLE0002: Trailing whitespace",
|
||||
\ },
|
||||
\], g:loclist
|
||||
|
||||
Execute (Run HandleGCCFormat):
|
||||
let g:loclist = ale#handlers#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 *’)',
|
||||
\])
|
||||
|
||||
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',
|
||||
\ 'text': 'invalid operands to binary - (have ‘int’ and ‘char *’)',
|
||||
\ },
|
||||
\], g:loclist
|
||||
|
||||
Execute (Run HandleUnixFormatAsError):
|
||||
let g:loclist = ale#handlers#HandleUnixFormatAsError(42, [
|
||||
\ 'file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args',
|
||||
\ 'file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)',
|
||||
\ 'test.pug:1:1 ".b" is not a valid class name. Class names must begin with "-", "_" or a letter and can only contain "_", "-", a-z and 0-9.',
|
||||
\])
|
||||
|
||||
Then (The loclist should be correct):
|
||||
AssertEqual [
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 27,
|
||||
\ 'col': 0,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'missing argument for Printf("%s"): format reads arg 2, have only 1 args',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 53,
|
||||
\ 'col': 10,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 1,
|
||||
\ 'type': 'E',
|
||||
\ 'text': '".b" is not a valid class name. Class names must begin with "-", "_" or a letter and can only contain "_", "-", a-z and 0-9.',
|
||||
\ },
|
||||
\], g:loclist
|
||||
|
||||
Execute (Run HandleUnixFormatAsWarning):
|
||||
let g:loclist = ale#handlers#HandleUnixFormatAsWarning(42, [
|
||||
\ 'file.go:27: missing argument for Printf("%s"): format reads arg 2, have only 1 args',
|
||||
\ 'file.go:53:10: if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)',
|
||||
\])
|
||||
|
||||
Then (The loclist should be correct):
|
||||
AssertEqual [
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 27,
|
||||
\ 'col': 0,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'missing argument for Printf("%s"): format reads arg 2, have only 1 args',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 53,
|
||||
\ 'col': 10,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'if block ends with a return statement, so drop this else and outdent its block (move short variable declaration to its own line if necessary)',
|
||||
\ },
|
||||
\], g:loclist
|
||||
|
||||
Execute (Run a Unix format function with a Windows path):
|
||||
let g:loclist = ale#handlers#HandleUnixFormatAsError(42, [
|
||||
\ 'C:\Users\w0rp\AppData\Local\Temp\Xyz123.go:27: foo',
|
||||
\ 'C:\Users\w0rp\AppData\Local\Temp\Xyz123.go:53:10: foo',
|
||||
\])
|
||||
|
||||
Then (The loclist should be correct):
|
||||
AssertEqual [
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 27,
|
||||
\ 'col': 0,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'foo',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 53,
|
||||
\ 'col': 10,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'foo',
|
||||
\ },
|
||||
\], g:loclist
|
||||
|
||||
Execute (Run HandleCppCheckFormat):
|
||||
let g:loclist = ale#handlers#HandleCppCheckFormat(42, [
|
||||
\ '[/tmp/test.c:5]: (style) Variable a is assigned a value that is never used.',
|
||||
\ '[/tmp/test.c:12]: (error) Array a[10] accessed at index 10, which is out of bounds.'
|
||||
\])
|
||||
|
||||
Then (The loclist should be correct):
|
||||
AssertEqual [
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 5,
|
||||
\ 'col': 0,
|
||||
\ 'type': 'W',
|
||||
\ 'text': 'Variable a is assigned a value that is never used. (style)',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 42,
|
||||
\ 'vcol': 0,
|
||||
\ 'nr': -1,
|
||||
\ 'lnum': 12,
|
||||
\ 'col': 0,
|
||||
\ 'type': 'E',
|
||||
\ 'text': 'Array a[10] accessed at index 10, which is out of bounds. (error)',
|
||||
\ },
|
||||
\], g:loclist
|
||||
|
||||
After:
|
||||
unlet g:loclist
|
||||
29
test/handler/test_credo_handler.vader
Normal file
29
test/handler/test_credo_handler.vader
Normal file
@@ -0,0 +1,29 @@
|
||||
Execute(The credo handler should parse lines correctly):
|
||||
runtime ale_linters/elixir/credo.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 4,
|
||||
\ 'text': 'There is no whitespace around parentheses/brackets most of the time, but here there is.',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 26,
|
||||
\ 'col': 0,
|
||||
\ 'text': 'If/else blocks should not have a negated condition in `if`.',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#elixir#credo#Handle(347, [
|
||||
\ 'This line should be ignored completely',
|
||||
\ 'lib/filename.ex:1:4: C: There is no whitespace around parentheses/brackets most of the time, but here there is.',
|
||||
\ 'lib/phoenix/channel.ex:26: R: If/else blocks should not have a negated condition in `if`.',
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
37
test/handler/test_eslint_handler.vader
Normal file
37
test/handler/test_eslint_handler.vader
Normal file
@@ -0,0 +1,37 @@
|
||||
Execute(The eslint handler should parse lines correctly):
|
||||
runtime ale_linters/javascript/eslint.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 47,
|
||||
\ 'col': 14,
|
||||
\ 'text': 'Missing trailing comma. [Warning/comma-dangle]',
|
||||
\ 'type': 'W',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 56,
|
||||
\ 'col': 41,
|
||||
\ 'text': 'Missing semicolon. [Error/semi]',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 13,
|
||||
\ 'col': 3,
|
||||
\ 'text': 'Parsing error: Unexpected token',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#javascript#eslint#Handle(347, [
|
||||
\ 'This line should be ignored completely',
|
||||
\ '/path/to/some-filename.js:47:14: Missing trailing comma. [Warning/comma-dangle]',
|
||||
\ '/path/to/some-filename.js:56:41: Missing semicolon. [Error/semi]',
|
||||
\ 'This line should be ignored completely',
|
||||
\ '/path/to/some-filename.js:13:3: Parsing error: Unexpected token',
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
130
test/handler/test_flow_handler.vader
Normal file
130
test/handler/test_flow_handler.vader
Normal file
@@ -0,0 +1,130 @@
|
||||
Before:
|
||||
let g:flow_output = {
|
||||
\ "flowVersion": "0.39.0",
|
||||
\ "errors": [
|
||||
\ {
|
||||
\ "kind": "infer",
|
||||
\ "level": "error",
|
||||
\ "message": [
|
||||
\ {
|
||||
\ "context": " return 1",
|
||||
\ "descr": "number",
|
||||
\ "type": "Blame",
|
||||
\ "loc": {
|
||||
\ "source": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
|
||||
\ "type": "SourceFile",
|
||||
\ "start": {
|
||||
\ "line": 417,
|
||||
\ "column": 10,
|
||||
\ "offset": 9503
|
||||
\ },
|
||||
\ "end": {
|
||||
\ "line": 417,
|
||||
\ "column": 10,
|
||||
\ "offset": 9504
|
||||
\ }
|
||||
\ },
|
||||
\ "path": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
|
||||
\ "line": 417,
|
||||
\ "endline": 417,
|
||||
\ "start": 10,
|
||||
\ "end": 10
|
||||
\ },
|
||||
\ {
|
||||
\ "context": v:null,
|
||||
\ "descr": "This type is incompatible with the expected return type of",
|
||||
\ "type": "Comment",
|
||||
\ "path": "",
|
||||
\ "line": 0,
|
||||
\ "endline": 0,
|
||||
\ "start": 1,
|
||||
\ "end": 0
|
||||
\ },
|
||||
\ {
|
||||
\ "context": "function parseArguments(lexer: Lexer<*>): Array<ArgumentNode> {",
|
||||
\ "descr": "array type",
|
||||
\ "type": "Blame",
|
||||
\ "loc": {
|
||||
\ "source": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
|
||||
\ "type": "SourceFile",
|
||||
\ "start": {
|
||||
\ "line": 416,
|
||||
\ "column": 43,
|
||||
\ "offset": 9472
|
||||
\ },
|
||||
\ "end": {
|
||||
\ "line": 416,
|
||||
\ "column": 61,
|
||||
\ "offset": 9491
|
||||
\ }
|
||||
\ },
|
||||
\ "path": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
|
||||
\ "line": 416,
|
||||
\ "endline": 416,
|
||||
\ "start": 43,
|
||||
\ "end": 61
|
||||
\ }
|
||||
\ ]
|
||||
\ },
|
||||
\ {
|
||||
\ "kind": "infer",
|
||||
\ "level": "warning",
|
||||
\ "message": [
|
||||
\ {
|
||||
\ "context": " return peek(lexer, TokenKind.PAREN_L) ?",
|
||||
\ "descr": "unreachable code",
|
||||
\ "type": "Blame",
|
||||
\ "loc": {
|
||||
\ "source": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
|
||||
\ "type": "SourceFile",
|
||||
\ "start": {
|
||||
\ "line": 419,
|
||||
\ "column": 3,
|
||||
\ "offset": 9508
|
||||
\ },
|
||||
\ "end": {
|
||||
\ "line": 421,
|
||||
\ "column": 7,
|
||||
\ "offset": 9626
|
||||
\ }
|
||||
\ },
|
||||
\ "path": "/home/w0rp/Downloads/graphql-js/src/language/parser.js",
|
||||
\ "line": 419,
|
||||
\ "endline": 421,
|
||||
\ "start": 3,
|
||||
\ "end": 7
|
||||
\ }
|
||||
\ ]
|
||||
\ }
|
||||
\ ],
|
||||
\ "passed": v:false
|
||||
\}
|
||||
|
||||
runtime ale_linters/javascript/flow.vim
|
||||
|
||||
After:
|
||||
unlet! g:flow_output
|
||||
unlet! g:expected
|
||||
unlet! g:actual
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(The flow handler should process errors correctly.):
|
||||
let g:actual = ale_linters#javascript#flow#Handle(347, [json_encode(g:flow_output)])
|
||||
let g:expected = [
|
||||
\ {
|
||||
\ 'lnum': 417,
|
||||
\ 'bufnr': 347,
|
||||
\ 'type': 'E',
|
||||
\ 'col': 10,
|
||||
\ 'text': 'number: This type is incompatible with the expected return type of array type',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 419,
|
||||
\ 'bufnr': 347,
|
||||
\ 'type': 'W',
|
||||
\ 'col': 3,
|
||||
\ 'text': 'unreachable code:',
|
||||
\ },
|
||||
\]
|
||||
|
||||
AssertEqual g:expected, g:actual
|
||||
106
test/handler/test_fortran_handler.vader
Normal file
106
test/handler/test_fortran_handler.vader
Normal file
@@ -0,0 +1,106 @@
|
||||
Execute(The fortran handler should parse lines from GCC 4.1.2 correctly):
|
||||
runtime ale_linters/fortran/gcc.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 357,
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 0,
|
||||
\ 'text': "Symbol ‘b’ at (1) has no IMPLICIT type",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 357,
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 0,
|
||||
\ 'text': "Symbol ‘a’ at (1) has no IMPLICIT type",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#fortran#gcc#Handle(357, [
|
||||
\ " In file :4",
|
||||
\ "",
|
||||
\ "write(*,*) b",
|
||||
\ " 1",
|
||||
\ "Error: Symbol ‘b’ at (1) has no IMPLICIT type",
|
||||
\ " In file :3",
|
||||
\ "",
|
||||
\ "write(*,*) a",
|
||||
\ " 1",
|
||||
\ "Error: Symbol ‘a’ at (1) has no IMPLICIT type",
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
|
||||
Execute(The fortran handler should parse lines from GCC 4.9.3 correctly):
|
||||
runtime ale_linters/fortran/gcc.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 357,
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 12,
|
||||
\ 'text': "Symbol ‘a’ at (1) has no IMPLICIT type",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 357,
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 12,
|
||||
\ 'text': "Symbol ‘b’ at (1) has no IMPLICIT type",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#fortran#gcc#Handle(357, [
|
||||
\ ":3.12:",
|
||||
\ "",
|
||||
\ "write(*,*) a",
|
||||
\ " 1",
|
||||
\ "Error: Symbol ‘a’ at (1) has no IMPLICIT type",
|
||||
\ ":4.12:",
|
||||
\ "",
|
||||
\ "write(*,*) b",
|
||||
\ " 1",
|
||||
\ "Error: Symbol ‘b’ at (1) has no IMPLICIT type",
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
|
||||
|
||||
Execute(The fortran handler should parse lines from GCC 6.3.1 correctly):
|
||||
runtime ale_linters/fortran/gcc.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 337,
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 12,
|
||||
\ 'text': "Symbol ‘a’ at (1) has no IMPLICIT type",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 337,
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 12,
|
||||
\ 'text': "Symbol ‘b’ at (1) has no IMPLICIT type",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#fortran#gcc#Handle(337, [
|
||||
\ "<stdin>:3:12:",
|
||||
\ "",
|
||||
\ "Error: Symbol ‘a’ at (1) has no IMPLICIT type",
|
||||
\ "<stdin>:4:12:",
|
||||
\ "",
|
||||
\ "Error: Symbol ‘b’ at (1) has no IMPLICIT type",
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
42
test/handler/test_ghc_handler.vader
Normal file
42
test/handler/test_ghc_handler.vader
Normal file
@@ -0,0 +1,42 @@
|
||||
Execute(The ghc handler should handle hdevtools output):
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {'lnum': 147, 'bufnr': 12, 'vcol': 0, 'nr': -1, 'type': 'W', 'col': 62, 'text': '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’ Expected type: [T.Text]'},
|
||||
\ ],
|
||||
\ ale#handlers#HandleGhcFormat(12, [
|
||||
\ '/path/to/foo.hs:147:62: warning:',
|
||||
\ '• Couldnt match type ‘a -> T.Text’ with ‘T.Text’',
|
||||
\ ' Expected type: [T.Text]',
|
||||
\ ])
|
||||
|
||||
|
||||
Execute(The ghc handler should handle ghc 8 output):
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {'lnum': 6, 'bufnr': 47, 'vcol': 0, 'nr': -1, 'type': 'E', 'col': 1, 'text': ' Failed to load interface for ‘GitHub.Data’ Use -v to see a list of the files searched for.'},
|
||||
\ {'lnum': 7, 'bufnr': 47, 'vcol': 0, 'nr': -1, 'type': 'W', 'col': 1, 'text': ' Failed to load interface for ‘GitHub.Endpoints.PullRequests’ Use -v to see a list of the files searched for.'},
|
||||
\ ],
|
||||
\ ale#handlers#HandleGhcFormat(47, [
|
||||
\ '',
|
||||
\ 'src/Appoint/Lib.hs:6:1: error:',
|
||||
\ ' Failed to load interface for ‘GitHub.Data’',
|
||||
\ ' Use -v to see a list of the files searched for.',
|
||||
\ '',
|
||||
\ 'src/Appoint/Lib.hs:7:1: warning:',
|
||||
\ ' Failed to load interface for ‘GitHub.Endpoints.PullRequests’',
|
||||
\ ' Use -v to see a list of the files searched for.',
|
||||
\ ])
|
||||
|
||||
|
||||
Execute(The ghc handler should handle ghc 7 output):
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {'lnum': 168, 'bufnr': 47, 'vcol': 0, 'nr': -1, 'type': 'E', 'col': 1, 'text': ' parse error (possibly incorrect indentation or mismatched brackets)'},
|
||||
\ ],
|
||||
\ ale#handlers#HandleGhcFormat(47, [
|
||||
\ 'src/Main.hs:168:1:',
|
||||
\ ' parse error (possibly incorrect indentation or mismatched brackets)',
|
||||
\ ])
|
||||
28
test/handler/test_mypy_handler.vader
Normal file
28
test/handler/test_mypy_handler.vader
Normal file
@@ -0,0 +1,28 @@
|
||||
Execute(The mypy handler should parse lines correctly):
|
||||
runtime ale_linters/python/mypy.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 0,
|
||||
\ 'text': "No library stub file for module 'django.db'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 40,
|
||||
\ 'col': 5,
|
||||
\ 'text': "Some other problem",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#python#mypy#Handle(347, [
|
||||
\ "file.py:4: error: No library stub file for module 'django.db'",
|
||||
\ 'file.py:4: note: (Stub files are from https://github.com/python/typeshed)',
|
||||
\ "file.py:40:5: error: Some other problem",
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
26
test/handler/test_nix_handler.vader
Normal file
26
test/handler/test_nix_handler.vader
Normal file
@@ -0,0 +1,26 @@
|
||||
Execute(The nix handler should parse nix-instantiate error messages correctly):
|
||||
runtime ale_linters/nix/nix.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 47,
|
||||
\ 'lnum': 23,
|
||||
\ 'col': 14,
|
||||
\ 'text': 'error: syntax error, unexpected IN',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 47,
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 12,
|
||||
\ 'text': 'error: syntax error, unexpected ''='', expecting '';''',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\
|
||||
\ ],
|
||||
\ ale_linters#nix#nix#Handle(47, [
|
||||
\ 'This line should be ignored',
|
||||
\ 'error: syntax error, unexpected IN, at /path/to/filename.nix:23:14',
|
||||
\ 'error: syntax error, unexpected ''='', expecting '';'', at /path/to/filename.nix:3:12',
|
||||
\ ])
|
||||
66
test/handler/test_php_handler.vader
Normal file
66
test/handler/test_php_handler.vader
Normal file
@@ -0,0 +1,66 @@
|
||||
Given (Some invalid lines of PHP):
|
||||
[foo;]
|
||||
class Foo { / }
|
||||
$foo)
|
||||
['foo' 'bar']
|
||||
|
||||
Execute(The php handler should parse lines correctly):
|
||||
runtime ale_linters/php/php.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 1,
|
||||
\ 'col': 5,
|
||||
\ 'text': "syntax error, unexpected ';', expecting ']'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 2,
|
||||
\ 'col': 13,
|
||||
\ 'text': "syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST)",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 3,
|
||||
\ 'col': 5,
|
||||
\ 'text': "syntax error, unexpected ')'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 4,
|
||||
\ 'col': 8,
|
||||
\ 'text': "syntax error, unexpected ''bar'' (T_CONSTANT_ENCAPSED_STRING), expecting ']'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 21,
|
||||
\ 'col': 0,
|
||||
\ 'text': "syntax error, unexpected end of file",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 47,
|
||||
\ 'col': 0,
|
||||
\ 'text': "Invalid numeric literal",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#php#php#Handle(347, [
|
||||
\ 'This line should be ignored completely',
|
||||
\ "PHP Parse error: syntax error, unexpected ';', expecting ']' in - on line 1",
|
||||
\ "PHP Parse error: syntax error, unexpected '/', expecting function (T_FUNCTION) or const (T_CONST) in - on line 2",
|
||||
\ "PHP Parse error: syntax error, unexpected ')' in - on line 3",
|
||||
\ "PHP Parse error: syntax error, unexpected ''bar'' (T_CONSTANT_ENCAPSED_STRING), expecting ']' in - on line 4",
|
||||
\ 'PHP Parse error: syntax error, unexpected end of file in - on line 21',
|
||||
\ 'PHP Parse error: Invalid numeric literal in - on line 47',
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
28
test/handler/test_rust_handler.vader
Normal file
28
test/handler/test_rust_handler.vader
Normal file
@@ -0,0 +1,28 @@
|
||||
Execute(The Rust handler should handle rustc output):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {'lnum': 15, 'bufnr': 347, 'vcol': 0, 'nr': -1, 'type': 'E', 'col': 418, 'text': 'expected one of `.`, `;`, `?`, `}`, or an operator, found `for`'},
|
||||
\ {'lnum': 13, 'bufnr': 347, 'vcol': 0, 'nr': -1, 'type': 'E', 'col': 407, 'text': 'no method named `wat` found for type `std::string::String` in the current scope'},
|
||||
\ ],
|
||||
\ ale#handlers#rust#HandleRustErrorsForFile(347, 'src/playpen.rs', [
|
||||
\ '',
|
||||
\ 'ignore this',
|
||||
\ '{"message":"expected one of `.`, `;`, `?`, `}`, or an operator, found `for`","code":null,"level":"error","spans":[{"file_name":"<anon>","byte_start":418,"byte_end":421,"line_start":15,"line_end":15,"column_start":5,"column_end":8,"is_primary":true,"text":[{"text":" for chr in source.trim().chars() {","highlight_start":5,"highlight_end":8}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}',
|
||||
\ '{"message":"main function not found","code":null,"level":"error","spans":[],"children":[],"rendered":null}',
|
||||
\ '{"message":"no method named `wat` found for type `std::string::String` in the current scope","code":null,"level":"error","spans":[{"file_name":"<anon>","byte_start":407,"byte_end":410,"line_start":13,"line_end":13,"column_start":7,"column_end":10,"is_primary":true,"text":[{"text":" s.wat()","highlight_start":7,"highlight_end":10}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":null}',
|
||||
\ '{"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":null}',
|
||||
\ ])
|
||||
|
||||
Execute(The Rust handler should handle cargo output):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {'lnum': 15, 'bufnr': 347, 'vcol': 0, 'nr': -1, 'type': 'E', 'col': 11505, 'text': 'expected one of `.`, `;`, `?`, `}`, or an operator, found `for`'},
|
||||
\ {'lnum': 13, 'bufnr': 347, 'vcol': 0, 'nr': -1, 'type': 'E', 'col': 11494, 'text': 'no method named `wat` found for type `std::string::String` in the current scope'},
|
||||
\ ],
|
||||
\ ale#handlers#rust#HandleRustErrorsForFile(347, 'src/playpen.rs', [
|
||||
\ '',
|
||||
\ 'ignore this',
|
||||
\ '{"message":{"children":[],"code":null,"level":"error","message":"expected one of `.`, `;`, `?`, `}`, or an operator, found `for`","rendered":null,"spans":[{"byte_end":11508,"byte_start":11505,"column_end":8,"column_start":5,"expansion":null,"file_name":"src/playpen.rs","is_primary":true,"label":null,"line_end":15,"line_start":15,"suggested_replacement":null,"text":[{"highlight_end":8,"highlight_start":5,"text":" for chr in source.trim().chars() {"}]}]},"package_id":"update 0.0.1 (path+file:///home/w0rp/Downloads/rust-by-example)","reason":"compiler-message","target":{"kind":["bin"],"name":"update","src_path":"/home/w0rp/Downloads/rust-by-example/src/main.rs"}}',
|
||||
\ '{"message":{"children":[],"code":null,"level":"error","message":"no method named `wat` found for type `std::string::String` in the current scope","rendered":null,"spans":[{"byte_end":11497,"byte_start":11494,"column_end":10,"column_start":7,"expansion":null,"file_name":"src/playpen.rs","is_primary":true,"label":null,"line_end":13,"line_start":13,"suggested_replacement":null,"text":[{"highlight_end":10,"highlight_start":7,"text":" s.wat()"}]}]},"package_id":"update 0.0.1 (path+file:///home/w0rp/Downloads/rust-by-example)","reason":"compiler-message","target":{"kind":["bin"],"name":"update","src_path":"/home/w0rp/Downloads/rust-by-example/src/main.rs"}}',
|
||||
\ '{"message":{"children":[],"code":null,"level":"error","message":"aborting due to previous error","rendered":null,"spans":[]},"package_id":"update 0.0.1 (path+file:///home/w0rp/Downloads/rust-by-example)","reason":"compiler-message","target":{"kind":["bin"],"name":"update","src_path":"/home/w0rp/Downloads/rust-by-example/src/main.rs"}}',
|
||||
\ ])
|
||||
38
test/handler/test_standard_handler.vader
Normal file
38
test/handler/test_standard_handler.vader
Normal file
@@ -0,0 +1,38 @@
|
||||
Execute(The standard handler should parse lines correctly):
|
||||
runtime ale_linters/javascript/standard.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 47,
|
||||
\ 'col': 14,
|
||||
\ 'text': 'Expected indentation of 2 spaces but found 4.',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 56,
|
||||
\ 'col': 41,
|
||||
\ 'text': 'Strings must use singlequote.',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 13,
|
||||
\ 'col': 3,
|
||||
\ 'text': 'Parsing error: Unexpected token',
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#javascript#standard#Handle(347, [
|
||||
\ 'This line should be ignored completely',
|
||||
\ '/path/to/some-filename.js:47:14: Expected indentation of 2 spaces but found 4.',
|
||||
\ '/path/to/some-filename.js:56:41: Strings must use singlequote.',
|
||||
\ 'This line should be ignored completely',
|
||||
\ '/path/to/some-filename.js:13:3: Parsing error: Unexpected token',
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
|
||||
27
test/handler/test_typecheck_handler.vader
Normal file
27
test/handler/test_typecheck_handler.vader
Normal file
@@ -0,0 +1,27 @@
|
||||
Execute(The typecheck handler should parse lines correctly):
|
||||
runtime ale_linters/typescript/typecheck.vim
|
||||
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 16,
|
||||
\ 'col': 7,
|
||||
\ 'text': "Type 'A' is not assignable to type 'B'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'bufnr': 347,
|
||||
\ 'lnum': 7,
|
||||
\ 'col': 41,
|
||||
\ 'text': "Property 'a' does not exist on type 'A'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#typescript#typecheck#Handle(347, [
|
||||
\ "somets.ts[16, 7]: Type 'A' is not assignable to type 'B'",
|
||||
\ "somets.ts[7, 41]: Property 'a' does not exist on type 'A'",
|
||||
\ ])
|
||||
|
||||
After:
|
||||
call ale#linter#Reset()
|
||||
Reference in New Issue
Block a user