mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-28 06:46:52 +08:00
Fix #1716 - Replace tempdir() with a wrapper to preserve TMPDIR
This commit is contained in:
@@ -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',
|
||||
\ ])
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
Execute($TMPDIR should be set to a default value if unset):
|
||||
if has('unix')
|
||||
AssertEqual '/tmp', $TMPDIR
|
||||
endif
|
||||
13
test/test_tmpdir_wrapper.vader
Normal file
13
test/test_tmpdir_wrapper.vader
Normal file
@@ -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 = ''
|
||||
|
||||
Reference in New Issue
Block a user