Test global problems and imported module errors

This commit is contained in:
Héctor Ramón Jiménez 2018-05-11 20:07:28 +02:00
parent d40f447931
commit 2f40da76e6
3 changed files with 67 additions and 20 deletions

View File

@ -1,11 +1,11 @@
" Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod " Author: buffalocoder - https://github.com/buffalocoder, soywod - https://github.com/soywod
" Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim. " Description: Elm linting in Ale. Closely follows the Syntastic checker in https://github.com/ElmCast/elm-vim.
call ale#Set('elm_executable', 'elm') call ale#Set('elm_make_executable', 'elm')
call ale#Set('elm_use_global', get(g:, 'ale_use_global_executables', 0)) call ale#Set('elm_make_use_global', get(g:, 'ale_use_global_executables', 0))
function! ale_linters#elm#make#GetExecutable(buffer) abort function! ale_linters#elm#make#GetExecutable(buffer) abort
return ale#node#FindExecutable(a:buffer, 'elm', [ return ale#node#FindExecutable(a:buffer, 'elm_make', [
\ 'node_modules/.bin/elm', \ 'node_modules/.bin/elm',
\]) \])
endfunction endfunction

View File

@ -9,7 +9,26 @@ After:
call ale#linter#Reset() call ale#linter#Reset()
Execute(The elm-make handler should parse lines correctly): Execute(The elm make handler should parse general problems correctly):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': 'UNKNOWN IMPORT',
\ 'detail': "error details 1\n\nstyled details"
\ }
\ ],
\ ale_linters#elm#make#Handle(347, [
\ '{
\ "type": "error",
\ "path": "' . b:tmp . '/Module.elm",
\ "title": "UNKNOWN IMPORT",
\ "message": ["error details 1\n\n", { "string": "styled details" }]
\ }'
\ ])
Execute(The elm make handler should parse compilation errors correctly):
AssertEqual AssertEqual
\ [ \ [
\ { \ {
@ -19,7 +38,7 @@ Execute(The elm-make handler should parse lines correctly):
\ 'end_col': 18, \ 'end_col': 18,
\ 'type': 'E', \ 'type': 'E',
\ 'text': 'TYPE MISMATCH', \ 'text': 'TYPE MISMATCH',
\ 'detail': "error details 1 styled details" \ 'detail': "error details 1\n\nstyled details"
\ }, \ },
\ { \ {
\ 'lnum': 406, \ 'lnum': 406,
@ -42,25 +61,25 @@ Execute(The elm-make handler should parse lines correctly):
\ ], \ ],
\ ale_linters#elm#make#Handle(347, [ \ ale_linters#elm#make#Handle(347, [
\ '{ \ '{
\ "type":"compile-errors", \ "type": "compile-errors",
\ "errors": [ \ "errors": [
\ { \ {
\ "path": "' . b:tmp . 'Module.elm", \ "path": "' . b:tmp . '/Module.elm",
\ "problems": [ \ "problems": [
\ { \ {
\ "title": "TYPE MISMATCH", \ "title": "TYPE MISMATCH",
\ "message": ["error details 1 ", { "string": "styled details" }], \ "message": ["error details 1\n\n", { "string": "styled details" }],
\ "region": { "start": { "line": 404, "column":1 }, "end": { "line":408, "column":18} } \ "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } }
\ }, \ },
\ { \ {
\ "title": "TYPE MISMATCH", \ "title": "TYPE MISMATCH",
\ "message": ["error details 2"], \ "message": ["error details 2"],
\ "region": { "start": {"line": 406, "column": 5}, "end": {"line": 407, "column": 17} } \ "region": { "start": {"line": 406, "column": 5}, "end": {"line": 407, "column": 17 } }
\ }, \ },
\ { \ {
\ "title": "TYPE MISMATCH", \ "title": "TYPE MISMATCH",
\ "message": ["error details 3"], \ "message": ["error details 3"],
\ "region": { "start": { "line": 406, "column": 5}, "end": {"line": 406, "column":93 } } \ "region": { "start": { "line": 406, "column": 5}, "end": {"line": 406, "column": 93 } }
\ } \ }
\ ] \ ]
\ } \ }
@ -68,7 +87,35 @@ Execute(The elm-make handler should parse lines correctly):
\ }' \ }'
\ ]) \ ])
Execute(The elm-make handler should put an error on the first line if a line cannot be parsed): Execute(The elm make handler should put an error on the first line for compilation errors in imported modules):
AssertEqual
\ [
\ {
\ 'lnum': 1,
\ 'type': 'E',
\ 'text': 'src/Module.elm:404 - TYPE MISMATCH',
\ 'detail': "src/Module.elm:404 -------\n\nerror details\n\nstyled details"
\ },
\ ],
\ ale_linters#elm#make#Handle(347, [
\ '{
\ "type": "compile-errors",
\ "errors": [
\ {
\ "path": "src/Module.elm",
\ "problems": [
\ {
\ "title": "TYPE MISMATCH",
\ "message": ["error details\n\n", { "string": "styled details" }],
\ "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } }
\ }
\ ]
\ }
\ ]
\ }'
\ ])
Execute(The elm make handler should put an error on the first line if a line cannot be parsed):
AssertEqual AssertEqual
\ [ \ [
\ { \ {
@ -89,15 +136,15 @@ Execute(The elm-make handler should put an error on the first line if a line can
\ ], \ ],
\ ale_linters#elm#make#Handle(347, [ \ ale_linters#elm#make#Handle(347, [
\ '{ \ '{
\ "type":"compile-errors", \ "type": "compile-errors",
\ "errors": [ \ "errors": [
\ { \ {
\ "path": "' . b:tmp . 'Module.elm", \ "path": "' . b:tmp . '/Module.elm",
\ "problems": [ \ "problems": [
\ { \ {
\ "title": "TYPE MISMATCH", \ "title": "TYPE MISMATCH",
\ "message": ["error details 1 ", { "string": "styled details" }], \ "message": ["error details 1 ", { "string": "styled details" }],
\ "region": { "start": { "line": 404, "column":1 }, "end": { "line":408, "column":18} } \ "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } }
\ } \ }
\ ] \ ]
\ } \ }

View File

@ -3,8 +3,8 @@ Before:
runtime ale_linters/elm/make.vim runtime ale_linters/elm/make.vim
After: After:
unlet! g:ale_elm_use_global unlet! g:ale_elm_make_use_global
unlet! g:ale_elm_executable unlet! g:ale_elm_make_executable
call ale#test#RestoreDirectory() call ale#test#RestoreDirectory()
@ -16,7 +16,7 @@ Execute(should get valid executable with default params):
\ ale_linters#elm#make#GetExecutable(bufnr('')) \ ale_linters#elm#make#GetExecutable(bufnr(''))
Execute(should get valid executable with 'use_global' params): Execute(should get valid executable with 'use_global' params):
let g:ale_elm_use_global = 1 let g:ale_elm_make_use_global = 1
call ale#test#SetFilename('elm-test-files/app/testfile.elm') call ale#test#SetFilename('elm-test-files/app/testfile.elm')
@ -25,8 +25,8 @@ Execute(should get valid executable with 'use_global' params):
\ ale_linters#elm#make#GetExecutable(bufnr('')) \ ale_linters#elm#make#GetExecutable(bufnr(''))
Execute(should get valid executable with 'use_global' and 'executable' params): Execute(should get valid executable with 'use_global' and 'executable' params):
let g:ale_elm_executable = 'other-elm' let g:ale_elm_make_executable = 'other-elm'
let g:ale_elm_use_global = 1 let g:ale_elm_make_use_global = 1
call ale#test#SetFilename('elm-test-files/app/testfile.elm') call ale#test#SetFilename('elm-test-files/app/testfile.elm')