Compare commits

...

9 Commits

Author SHA1 Message Date
w0rp 2ee3dcdd62
Fix #1631 - Disable balloon support for terminals by default 2018-07-20 16:11:38 +01:00
w0rp 465db4daa1
Only temporarily replace TMPDIR if it's defined to be an empty string 2018-07-16 08:50:34 +01:00
w0rp fb8c090971
unlet $TMPDIR too, where we can 2018-07-15 23:05:04 +01:00
w0rp d29e32d42d
Fix #1687 - Parse highlights when verbose > 0 2018-07-15 21:03:49 +01:00
w0rp ab2b181012
Handle linter callback functions being unknown or deleted 2018-07-13 09:47:40 +01:00
w0rp 033a6c1178
Merge pull request #1720 from MTDL9/fix-error-response-string-data
Fix E712 error in ale#lsp#response#GetErrorMessage when receiving string primitives in the error.data field
2018-07-13 09:38:19 +01:00
w0rp 7d66293bbc
Fix #1716 - Replace tempdir() with a wrapper to preserve TMPDIR 2018-07-12 13:06:11 +01:00
w0rp 1fc3a1563b
Update the sandbox test now that functions can be defined in the sandbox 2018-07-11 13:38:22 +01:00
w0rp a31f54d08f
Fix how Docker images are pulled for developers 2018-07-04 09:36:55 +01:00
24 changed files with 236 additions and 169 deletions

View File

@ -29,7 +29,7 @@ function! ale_linters#cs#mcsc#GetCommand(buffer) abort
\ : ''
" register temporary module target file with ale
let l:out = tempname()
let l:out = ale#util#Tempname()
call ale#engine#ManageFile(a:buffer, l:out)
" The code is compiled as a module and the output is redirected to a

View File

@ -10,7 +10,7 @@ endfunction
function! ale_linters#cuda#nvcc#GetCommand(buffer) abort
" Unused: use ale#util#nul_file
" let l:output_file = tempname() . '.ii'
" let l:output_file = ale#util#Tempname() . '.ii'
" call ale#engine#ManageFile(a:buffer, l:output_file)
return ale#Escape(ale_linters#cuda#nvcc#GetExecutable(a:buffer))

View File

@ -128,14 +128,7 @@ function! ale_linters#elm#make#HandleElm018Line(line, output) abort
endfunction
function! ale_linters#elm#make#FileIsBuffer(path) abort
let l:is_windows = has('win32')
let l:temp_dir = l:is_windows ? $TMP : $TMPDIR
if has('win32')
return a:path[0:len(l:temp_dir) - 1] is? l:temp_dir
else
return a:path[0:len(l:temp_dir) - 1] is# l:temp_dir
endif
return ale#path#IsTempName(a:path)
endfunction
function! ale_linters#elm#make#ParseMessage(message) abort

View File

@ -3,7 +3,7 @@
let g:ale_erlang_erlc_options = get(g:, 'ale_erlang_erlc_options', '')
function! ale_linters#erlang#erlc#GetCommand(buffer) abort
let l:output_file = tempname()
let l:output_file = ale#util#Tempname()
call ale#engine#ManageFile(a:buffer, l:output_file)
return 'erlc -o ' . ale#Escape(l:output_file)

View File

@ -20,7 +20,7 @@ function! ale_linters#thrift#thrift#GetCommand(buffer) abort
let l:generators = ['cpp']
endif
let l:output_dir = tempname()
let l:output_dir = ale#util#Tempname()
call mkdir(l:output_dir)
call ale#engine#ManageDirectory(a:buffer, l:output_dir)

View File

@ -7,7 +7,7 @@ if !exists('g:ale_verilog_verilator_options')
endif
function! ale_linters#verilog#verilator#GetCommand(buffer) abort
let l:filename = tempname() . '_verilator_linted.v'
let l:filename = ale#util#Tempname() . '_verilator_linted.v'
" Create a special filename, so we can detect it in the handler.
call ale#engine#ManageFile(a:buffer, l:filename)

View File

@ -13,7 +13,7 @@ function! s:TemporaryFilename(buffer) abort
" Create a temporary filename, <temp_dir>/<original_basename>
" The file itself will not be created by this function.
return tempname() . (has('win32') ? '\' : '/') . l:filename
return ale#util#Tempname() . (has('win32') ? '\' : '/') . l:filename
endfunction
" Given a command string, replace every...

View File

@ -98,7 +98,7 @@ endfunction
" Create a new temporary directory and manage it in one go.
function! ale#engine#CreateDirectory(buffer) abort
let l:temporary_directory = tempname()
let l:temporary_directory = ale#util#Tempname()
" Create the temporary directory for the file, unreadable by 'other'
" users.
call mkdir(l:temporary_directory, '', 0750)
@ -221,7 +221,12 @@ function! s:HandleExit(job_id, exit_code) abort
call ale#history#RememberOutput(l:buffer, a:job_id, l:output[:])
endif
let l:loclist = ale#util#GetFunction(l:linter.callback)(l:buffer, l:output)
try
let l:loclist = ale#util#GetFunction(l:linter.callback)(l:buffer, l:output)
" Handle the function being unknown, or being deleted.
catch /E700/
let l:loclist = []
endtry
call ale#engine#HandleLoclist(l:linter.name, l:buffer, l:loclist)
endfunction

View File

@ -2,7 +2,7 @@
" Description: Error handling for the format GHC outputs.
" Remember the directory used for temporary files for Vim.
let s:temp_dir = fnamemodify(tempname(), ':h')
let s:temp_dir = fnamemodify(ale#util#Tempname(), ':h')
" Build part of a regular expression for matching ALE temporary filenames.
let s:temp_regex_prefix =
\ '\M'

View File

@ -105,11 +105,17 @@ function! ale#lsp#response#GetErrorMessage(response) abort
return ''
endif
" Include the traceback as details, if it's there.
let l:traceback = get(get(a:response.error, 'data', {}), 'traceback', [])
" Include the traceback or error data as details, if present.
let l:error_data = get(a:response.error, 'data', {})
if type(l:traceback) is type([]) && !empty(l:traceback)
let l:message .= "\n" . join(l:traceback, "\n")
if type(l:error_data) is type('')
let l:message .= "\n" . l:error_data
else
let l:traceback = get(l:error_data, 'traceback', [])
if type(l:traceback) is type([]) && !empty(l:traceback)
let l:message .= "\n" . join(l:traceback, "\n")
endif
endif
return l:message

View File

@ -84,7 +84,7 @@ function! ale#path#IsAbsolute(filename) abort
return a:filename[:0] is# '/' || a:filename[1:2] is# ':\'
endfunction
let s:temp_dir = ale#path#Simplify(fnamemodify(tempname(), ':h'))
let s:temp_dir = ale#path#Simplify(fnamemodify(ale#util#Tempname(), ':h'))
" Given a filename, return 1 if the file represents some temporary file
" created by Vim.

View File

@ -45,25 +45,23 @@ if !hlexists('ALESignColumnWithErrors')
highlight link ALESignColumnWithErrors error
endif
function! ale#sign#SetUpDefaultColumnWithoutErrorsHighlight() abort
redir => l:output
0verbose silent highlight SignColumn
redir end
let l:highlight_syntax = join(split(l:output)[2:])
let l:match = matchlist(l:highlight_syntax, '\vlinks to (.+)$')
if !empty(l:match)
execute 'highlight link ALESignColumnWithoutErrors ' . l:match[1]
elseif l:highlight_syntax isnot# 'cleared'
execute 'highlight ALESignColumnWithoutErrors ' . l:highlight_syntax
endif
endfunction
if !hlexists('ALESignColumnWithoutErrors')
function! s:SetSignColumnWithoutErrorsHighlight() abort
redir => l:output
silent highlight SignColumn
redir end
let l:highlight_syntax = join(split(l:output)[2:])
let l:match = matchlist(l:highlight_syntax, '\vlinks to (.+)$')
if !empty(l:match)
execute 'highlight link ALESignColumnWithoutErrors ' . l:match[1]
elseif l:highlight_syntax isnot# 'cleared'
execute 'highlight ALESignColumnWithoutErrors ' . l:highlight_syntax
endif
endfunction
call s:SetSignColumnWithoutErrorsHighlight()
delfunction s:SetSignColumnWithoutErrorsHighlight
call ale#sign#SetUpDefaultColumnWithoutErrorsHighlight()
endif
" Signs show up on the left for error markers.

View File

@ -268,9 +268,8 @@ endfunction
" See :help sandbox
function! ale#util#InSandbox() abort
try
function! s:SandboxCheck() abort
endfunction
catch /^Vim\%((\a\+)\)\=:E48/
let &equalprg=&equalprg
catch /E48/
" E48 is the sandbox error.
return 1
endtry
@ -278,6 +277,25 @@ function! ale#util#InSandbox() abort
return 0
endfunction
function! ale#util#Tempname() abort
let l:clear_tempdir = 0
if exists('$TMPDIR') && empty($TMPDIR)
let l:clear_tempdir = 1
let $TMPDIR = '/tmp'
endif
try
let l:name = tempname() " no-custom-checks
finally
if l:clear_tempdir
let $TMPDIR = ''
endif
endtry
return l:name
endfunction
" Given a single line, or a List of lines, and a single pattern, or a List
" of patterns, return all of the matches for the lines(s) from the given
" patterns, using matchlist().

View File

@ -111,6 +111,9 @@ these are reported with ALE's `custom-linting-rules` script. See
* Don't use the `shellescape()` function. It doesn't escape arguments properly
on Windows. Use `ale#Escape()` instead, which will avoid escaping where it
isn't needed, and generally escape arguments better on Windows.
* Don't use the `tempname()` function. It doesn't work when `$TMPDIR` isn't
set. Use `ale#util#Tempname()` instead, which temporarily sets `$TMPDIR`
appropriately where needed.
Apply the following guidelines when writing Vader test files.

View File

@ -1401,8 +1401,7 @@ g:ale_set_balloons *g:ale_set_balloons*
*b:ale_set_balloons*
Type: |Number|
Default: `(has('balloon_eval') && has('gui_running'))`
`|| (has('balloon_eval_term') && !has('gui_running'))`
Default: `has('balloon_eval') && has('gui_running')`
When this option is set to `1`, balloon messages will be displayed for
problems or hover information if available.
@ -1412,6 +1411,12 @@ g:ale_set_balloons *g:ale_set_balloons*
supporting "Hover" information, per |ale-hover|, then brief information
about the symbol under the cursor will be displayed in a balloon.
Balloons can be enabled for terminal versions of Vim that support balloons,
but some versions of Vim will produce strange mouse behavior when balloons
are enabled. To configure balloons for your terminal, you should first
configure your |ttymouse| setting, and then consider setting
`g:ale_set_balloons` to `1` before ALE is loaded.
`b:ale_set_balloons` can be set to `0` to disable balloons for a buffer.
Balloons cannot be enabled for a specific buffer when not initially enabled
globally.
@ -2206,6 +2211,10 @@ ale#linter#Define(filetype, linter) *ale#linter#Define()*
defined, as LSP linters handle diagnostics
automatically. See |ale-lsp-linters|.
If the function named does not exist, including if
the function is later deleted, ALE will behave as if
the callback returned an empty list.
The keys for each item in the List will be handled in
the following manner:
*ale-loclist-format*

View File

@ -35,12 +35,6 @@ endif
" Set this flag so that other plugins can use it, like airline.
let g:loaded_ale = 1
" Set the TMPDIR environment variable if it is not set automatically.
" This can automatically fix some environments.
if has('unix') && empty($TMPDIR)
let $TMPDIR = '/tmp'
endif
" This global variable is used internally by ALE for tracking information for
" each buffer which linters are being run against.
let g:ale_buffer_info = {}
@ -114,10 +108,7 @@ let g:ale_set_highlights = get(g:, 'ale_set_highlights', has('syntax'))
let g:ale_echo_cursor = get(g:, 'ale_echo_cursor', 1)
" This flag can be set to 0 to disable balloon support.
let g:ale_set_balloons = get(g:, 'ale_set_balloons',
\ (has('balloon_eval') && has('gui_running'))
\ || (has('balloon_eval_term') && !has('gui_running'))
\)
let g:ale_set_balloons = get(g:, 'ale_set_balloons', has('balloon_eval') && has('gui_running'))
" This flag can be set to 0 to disable warnings for trailing whitespace
let g:ale_warn_about_trailing_whitespace = get(g:, 'ale_warn_about_trailing_whitespace', 1)

View File

@ -11,10 +11,9 @@ set -u
image=w0rp/ale
current_image_id=71553d0ab3e8
current_digest=sha256:fea0ddf220c080af9d615d86c277cdecbd63682e430cba92fff2014ebf2a5f3a
# Used in all test scripts for running the selected Docker image.
DOCKER_RUN_IMAGE="$image:$current_image_id"
DOCKER_RUN_IMAGE="$image"
export DOCKER_RUN_IMAGE
tests='test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader'
@ -110,7 +109,8 @@ fi
# Delete .swp files in the test directory, which cause Vim 8 to hang.
find test -name '*.swp' -delete
docker pull "$image"@"$current_digest"
docker images -q w0rp/ale | grep "^$current_image_id" > /dev/null \
|| docker pull "$image"
output_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')

View File

@ -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',
\ ])

View File

@ -63,3 +63,12 @@ Execute(Messages with tracebacks should be handled):
\ },
\ },
\})
Execute(Messages with string data should be handled):
AssertEqual "xyz\nUncaught Exception", ale#lsp#response#GetErrorMessage({
\ 'error': {
\ 'code': -32602,
\ 'message': 'xyz',
\ 'data': 'Uncaught Exception',
\ },
\})

View File

@ -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"

View File

@ -1,12 +1,13 @@
Before:
Save g:ale_change_sign_column_color
Save &verbose
function! ParseHighlight(name) abort
redir => l:output
silent execute 'highlight ' . a:name
redir end
return join(split(l:output)[2:])
return substitute(join(split(l:output)[2:]), ' Last set.*', '', '')
endfunction
function! SetHighlight(name, syntax) abort
@ -53,3 +54,15 @@ Execute(The SignColumn highlight should be set and reset):
call ale#sign#SetSigns(bufnr(''), [])
AssertEqual 'links to ALESignColumnWithoutErrors', ParseHighlight('SignColumn')
Execute(The SignColumn should be correctly parsed when verbose=1):
set verbose=1
highlight SignColumn ctermfg=246 ctermbg=7 guifg=#839496 guibg=Grey
call ale#sign#SetUpDefaultColumnWithoutErrorsHighlight()
AssertEqual
\ has('nvim')
\ ? 'ctermfg=246 ctermbg=7 guifg=#839496 guibg=Grey'
\ : 'term=standout ctermfg=246 ctermbg=7 guifg=#839496 guibg=Grey',
\ ParseHighlight('ALESignColumnWithoutErrors')

View File

@ -1,4 +0,0 @@
Execute($TMPDIR should be set to a default value if unset):
if has('unix')
AssertEqual '/tmp', $TMPDIR
endif

View File

@ -0,0 +1,32 @@
Before:
let g:exists = exists('$TMPDIR')
let g:old_value = $TMPDIR
After:
if g:exists
let $TMPDIR = g:old_value
else
silent! unlet! $TMPDIR
endif
unlet! g:exists
unlet! g:old_value
Execute(ale#util#Tempname shouldn't set $TMPDIR to an empty string if it isn't set):
" You can't run this test twice on old Vim versions.
if has('unix')
Assert ale#util#Tempname() =~# '^/tmp'
Assert !exists('$TMPDIR'), '$TMPDIR exists where it shouldn''t'
endif
Execute(ale#util#Tempname shouldn't replace $TMPDIR and reset them to an empty string.):
if has('unix')
let $TMPDIR = ''
Assert ale#util#Tempname() =~# '^/tmp'
if !has('nvim')
Assert exists('$TMPDIR'), '$TMPDIR doesn''t exist where it should'
endif
AssertEqual '', $TMPDIR
endif

View File

@ -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 = ''