diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/handler/test_elmmake_handler.vader | 201 | ||||
-rwxr-xr-x | test/script/custom-linting-rules | 1 | ||||
-rw-r--r-- | test/test_tmpdir_init.vader | 4 | ||||
-rw-r--r-- | test/test_tmpdir_wrapper.vader | 13 | ||||
-rw-r--r-- | test/vimrc | 4 |
5 files changed, 113 insertions, 110 deletions
diff --git a/test/handler/test_elmmake_handler.vader b/test/handler/test_elmmake_handler.vader index 41c9646f..f5906a8b 100644 --- a/test/handler/test_elmmake_handler.vader +++ b/test/handler/test_elmmake_handler.vader @@ -1,10 +1,7 @@ Before: - let b:tmp = has('win32') ? substitute($TMP, '\\', '\\\\', 'g') : $TMPDIR - runtime ale_linters/elm/make.vim After: - unlet! b:tmp unlet! g:config_error_lines call ale#linter#Reset() @@ -22,12 +19,12 @@ Execute(The elm-make handler should parse Elm 0.19 general problems correctly): \ } \ ], \ ale_linters#elm#make#Handle(347, [ - \ '{ - \ "type": "error", - \ "path": "' . b:tmp . '/Module.elm", - \ "title": "UNKNOWN IMPORT", - \ "message": ["error details\n\n", { "string": "styled details" }] - \ }' + \ json_encode({ + \ 'type': 'error', + \ 'path': ale#util#Tempname() . '/Module.elm', + \ 'title': 'UNKNOWN IMPORT', + \ 'message': ["error details\n\n", { 'string': 'styled details' }] + \ }), \ ]) Execute(The elm-make handler should parse Elm 0.19 compilation errors correctly): @@ -47,7 +44,7 @@ Execute(The elm-make handler should parse Elm 0.19 compilation errors correctly) \ 'end_lnum': 407, \ 'end_col': 17, \ 'type': 'E', - \ 'text': "error details 2", + \ 'text': 'error details 2', \ }, \ { \ 'lnum': 406, @@ -55,35 +52,35 @@ Execute(The elm-make handler should parse Elm 0.19 compilation errors correctly) \ 'end_lnum': 406, \ 'end_col': 93, \ 'type': 'E', - \ 'text': "error details 3", + \ 'text': 'error details 3', \ }, \ ], \ ale_linters#elm#make#Handle(347, [ - \ '{ - \ "type": "compile-errors", - \ "errors": [ + \ json_encode({ + \ 'type': 'compile-errors', + \ 'errors': [ \ { - \ "path": "' . b:tmp . '/Module.elm", - \ "problems": [ + \ 'path': ale#util#Tempname() . '/Module.elm', + \ 'problems': [ \ { - \ "title": "TYPE MISMATCH", - \ "message": ["error details 1\n\n", { "string": "styled details" }], - \ "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } } + \ 'title': 'TYPE MISMATCH', + \ 'message': ["error details 1\n\n", { 'string': 'styled details' }], + \ 'region': { 'start': { 'line': 404, 'column': 1 }, 'end': { 'line': 408, 'column': 18 } } \ }, \ { - \ "title": "TYPE MISMATCH", - \ "message": ["error details 2"], - \ "region": { "start": {"line": 406, "column": 5}, "end": {"line": 407, "column": 17 } } + \ 'title': 'TYPE MISMATCH', + \ 'message': ['error details 2'], + \ 'region': { 'start': {'line': 406, 'column': 5}, 'end': {'line': 407, 'column': 17 } } \ }, \ { - \ "title": "TYPE MISMATCH", - \ "message": ["error details 3"], - \ "region": { "start": { "line": 406, "column": 5}, "end": {"line": 406, "column": 93 } } + \ 'title': 'TYPE MISMATCH', + \ 'message': ['error details 3'], + \ 'region': { 'start': { 'line': 406, 'column': 5}, 'end': {'line': 406, 'column': 93 } } \ } \ ] \ } \ ] - \ }' + \ }), \ ]) Execute(The elm-make handler should handle errors in Elm 0.19 imported modules): @@ -109,33 +106,33 @@ Execute(The elm-make handler should handle errors in Elm 0.19 imported modules): \ }, \ ], \ ale_linters#elm#make#Handle(347, [ - \ '{ - \ "type": "error", - \ "path": "src/Module.elm", - \ "title": "UNKNOWN IMPORT", - \ "message": ["error details\n\n", { "string": "styled details" }] - \ }', - \ '{ - \ "type": "error", - \ "path": null, - \ "title": "UNKNOWN IMPORT", - \ "message": ["error details\n\n", { "string": "styled details" }] - \ }', - \ '{ - \ "type": "compile-errors", - \ "errors": [ + \ json_encode({ + \ 'type': 'error', + \ 'path': 'src/Module.elm', + \ 'title': 'UNKNOWN IMPORT', + \ 'message': ["error details\n\n", { 'string': 'styled details' }] + \ }), + \ json_encode({ + \ 'type': 'error', + \ 'path': v:null, + \ 'title': 'UNKNOWN IMPORT', + \ 'message': ["error details\n\n", { 'string': 'styled details' }] + \ }), + \ json_encode({ + \ 'type': 'compile-errors', + \ 'errors': [ \ { - \ "path": "src/Module.elm", - \ "problems": [ + \ '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 } } + \ 'title': 'TYPE MISMATCH', + \ 'message': ["error details\n\n", { 'string': 'styled details' }], + \ 'region': { 'start': { 'line': 404, 'column': 1 }, 'end': { 'line': 408, 'column': 18 } } \ } \ ] \ } \ ] - \ }' + \ }), \ ]) @@ -182,45 +179,45 @@ Execute(The elm-make handler should parse Elm 0.18 compilation errors correctly) \ }, \ ], \ ale_linters#elm#make#Handle(347, [ - \ '[ + \ json_encode([ \ { - \ "tag": "unused import", - \ "overview": "warning overview", - \ "details": "warning details", - \ "region": {"start": { "line": 33, "column": 1 }, "end": { "line": 33, "column": 19 } }, - \ "type": "warning", - \ "file": "' . b:tmp . '/Module.elm" + \ 'tag': 'unused import', + \ 'overview': 'warning overview', + \ 'details': 'warning details', + \ 'region': {'start': { 'line': 33, 'column': 1 }, 'end': { 'line': 33, 'column': 19 } }, + \ 'type': 'warning', + \ 'file': ale#util#Tempname() . '/Module.elm', \ } - \ ]', - \ '[ + \ ]), + \ json_encode([ \ { - \ "tag": "TYPE MISMATCH", - \ "overview": "error overview 1", - \ "subregion": { "start": { "line": 406, "column": 5 }, "end": { "line": 408, "column": 18 } }, - \ "details": "error details 1", - \ "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } }, - \ "type": "error", - \ "file":"' . b:tmp . '/Module.elm" + \ 'tag': 'TYPE MISMATCH', + \ 'overview': 'error overview 1', + \ 'subregion': { 'start': { 'line': 406, 'column': 5 }, 'end': { 'line': 408, 'column': 18 } }, + \ 'details': 'error details 1', + \ 'region': { 'start': { 'line': 404, 'column': 1 }, 'end': { 'line': 408, 'column': 18 } }, + \ 'type': 'error', + \ 'file': ale#util#Tempname() . '/Module.elm', \ }, \ { - \ "tag": "TYPE MISMATCH", - \ "overview": "error overview 2", - \ "subregion": { "start": { "line": 407, "column": 12 }, "end": { "line": 407, "column": 17 } }, - \ "details": "error details 2", - \ "region": { "start": { "line": 406, "column": 5}, "end": { "line": 407, "column": 17 } }, - \ "type":"error", - \ "file":"' . b:tmp . '/Module.elm" + \ 'tag': 'TYPE MISMATCH', + \ 'overview': 'error overview 2', + \ 'subregion': { 'start': { 'line': 407, 'column': 12 }, 'end': { 'line': 407, 'column': 17 } }, + \ 'details': 'error details 2', + \ 'region': { 'start': { 'line': 406, 'column': 5}, 'end': { 'line': 407, 'column': 17 } }, + \ 'type':'error', + \ 'file': ale#util#Tempname() . '/Module.elm', \ }, \ { - \ "tag": "TYPE MISMATCH", - \ "overview": "error overview 3", - \ "subregion": { "start": { "line": 406, "column": 88 }, "end": { "line": 406, "column": 93 } }, - \ "details": "error details 3", - \ "region": { "start": { "line": 406, "column": 5 }, "end": { "line": 406, "column": 93 } }, - \ "type":"error", - \ "file":"' . b:tmp . '/Module.elm" + \ 'tag': 'TYPE MISMATCH', + \ 'overview': 'error overview 3', + \ 'subregion': { 'start': { 'line': 406, 'column': 88 }, 'end': { 'line': 406, 'column': 93 } }, + \ 'details': 'error details 3', + \ 'region': { 'start': { 'line': 406, 'column': 5 }, 'end': { 'line': 406, 'column': 93 } }, + \ 'type':'error', + \ 'file': ale#util#Tempname() . '/Module.elm', \ } - \ ]' + \ ]), \ ]) Execute(The elm-make handler should handle errors in Elm 0.18 imported modules): @@ -229,29 +226,29 @@ Execute(The elm-make handler should handle errors in Elm 0.18 imported modules): \ { \ 'lnum': 1, \ 'type': 'E', - \ 'text': "src/Module.elm:33 - error overview", + \ 'text': 'src/Module.elm:33 - error overview', \ 'detail': "src/Module.elm:33 ----------\n\nerror overview\n\nerror details" \ } \ ], \ ale_linters#elm#make#Handle(347, [ - \ '[ + \ json_encode([ \ { - \ "tag": "unused import", - \ "overview": "warning overview", - \ "details": "warning details", - \ "region": {"start": { "line": 33, "column": 1 }, "end": { "line": 33, "column": 19 } }, - \ "type": "warning", - \ "file": "src/Module.elm" + \ 'tag': 'unused import', + \ 'overview': 'warning overview', + \ 'details': 'warning details', + \ 'region': {'start': { 'line': 33, 'column': 1 }, 'end': { 'line': 33, 'column': 19 } }, + \ 'type': 'warning', + \ 'file': 'src/Module.elm', \ }, \ { - \ "tag": "type error", - \ "overview": "error overview", - \ "details": "error details", - \ "region": {"start": { "line": 33, "column": 1 }, "end": { "line": 33, "column": 19 } }, - \ "type": "error", - \ "file": "src/Module.elm" + \ 'tag': 'type error', + \ 'overview': 'error overview', + \ 'details': 'error details', + \ 'region': {'start': { 'line': 33, 'column': 1 }, 'end': { 'line': 33, 'column': 19 } }, + \ 'type': 'error', + \ 'file': 'src/Module.elm', \ } - \ ]', + \ ]), \ ]) " Generic @@ -275,21 +272,21 @@ Execute(The elm-make handler should put an error on the first line if a line can \ }, \ ], \ ale_linters#elm#make#Handle(347, [ - \ '{ - \ "type": "compile-errors", - \ "errors": [ + \ json_encode({ + \ 'type': 'compile-errors', + \ 'errors': [ \ { - \ "path": "' . b:tmp . '/Module.elm", - \ "problems": [ + \ 'path': ale#util#Tempname() . '/Module.elm', + \ 'problems': [ \ { - \ "title": "TYPE MISMATCH", - \ "message": ["error details 1\n\n", { "string": "styled details" }], - \ "region": { "start": { "line": 404, "column": 1 }, "end": { "line": 408, "column": 18 } } + \ 'title': 'TYPE MISMATCH', + \ 'message': ["error details 1\n\n", { 'string': 'styled details' }], + \ 'region': { 'start': { 'line': 404, 'column': 1 }, 'end': { 'line': 408, 'column': 18 } } \ } \ ] \ } \ ] - \ }', + \ }), \ 'Not JSON', \ 'Also not JSON', \ ]) diff --git a/test/script/custom-linting-rules b/test/script/custom-linting-rules index 0d1a0fd1..51cf5680 100755 --- a/test/script/custom-linting-rules +++ b/test/script/custom-linting-rules @@ -87,6 +87,7 @@ check_errors $'\t' 'Use four spaces, not tabs' check_errors 'let g:ale_\w\+_\w\+_args =' 'Name your option g:ale_<filetype>_<lintername>_options instead' check_errors 'shellescape(' 'Use ale#Escape instead of shellescape' check_errors 'simplify(' 'Use ale#path#Simplify instead of simplify' +check_errors 'tempname(' 'Use ale#util#Tempname instead of tempname' check_errors "expand(['\"]%" "Use expand('#' . a:buffer . '...') instead. You might get a filename for the wrong buffer." check_errors 'getcwd()' "Do not use getcwd(), as it could run from the wrong buffer. Use expand('#' . a:buffer . ':p:h') instead." check_errors '==#' "Use 'is#' instead of '==#'. 0 ==# 'foobar' is true" diff --git a/test/test_tmpdir_init.vader b/test/test_tmpdir_init.vader deleted file mode 100644 index 23326dcc..00000000 --- a/test/test_tmpdir_init.vader +++ /dev/null @@ -1,4 +0,0 @@ -Execute($TMPDIR should be set to a default value if unset): - if has('unix') - AssertEqual '/tmp', $TMPDIR - endif diff --git a/test/test_tmpdir_wrapper.vader b/test/test_tmpdir_wrapper.vader new file mode 100644 index 00000000..4d87061f --- /dev/null +++ b/test/test_tmpdir_wrapper.vader @@ -0,0 +1,13 @@ +Before: + Save $TMPDIR + +After: + Restore + +Execute(ale#util#Tempname should create files in /tmp if $TMPDIR isn't set): + if has('unix') + let $TMPDIR = '' + Assert ale#util#Tempname() =~# '^/tmp' + " We should unlet the environment variable again. + AssertEqual '', $TMPDIR + endif @@ -35,7 +35,3 @@ set ttimeoutlen=0 execute 'set encoding=utf-8' let g:mapleader=',' - -" Clear the TMPDIR value for tests. -" The plugin should set this to /tmp by default, which we will test. -let $TMPDIR = '' |