mirror of https://github.com/dense-analysis/ale
#4454 Clean up root test directory tests
Combine cases into smaller tests of tests and remove tests we no longer need. Linter tests have been moved to where they should be.
This commit is contained in:
parent
e5816964d1
commit
bf55175b69
|
@ -56,7 +56,6 @@ let s:global_variable_list = [
|
|||
\ 'ale_sign_style_warning',
|
||||
\ 'ale_sign_warning',
|
||||
\ 'ale_sign_highlight_linenrs',
|
||||
\ 'ale_statusline_format',
|
||||
\ 'ale_type_map',
|
||||
\ 'ale_use_neovim_diagnostics_api',
|
||||
\ 'ale_use_global_executables',
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('css', 'csslint')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(--config should be set when the .csslintrc file is found):
|
||||
call ale#test#SetFilename('../test-files/csslint/some-app/subdir/testfile.js')
|
||||
|
||||
AssertLinter 'csslint', 'csslint --format=compact '
|
||||
\ . '--config=' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/csslint/some-app/.csslintrc'))
|
||||
\ . ' %t'
|
||||
|
||||
Execute(--config should not be used when no .csslintrc file exists):
|
||||
call ale#test#SetFilename('../test-files/csslint/other-app/testfile.css')
|
||||
|
||||
AssertLinter 'csslint', 'csslint --format=compact %t'
|
|
@ -0,0 +1,25 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('dockerfile', 'hadolint')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(We should not use Docker by default):
|
||||
AssertLinter 'hadolint', 'hadolint --no-color -'
|
||||
|
||||
Execute(Options should be passed correctly when docker is disabled):
|
||||
let b:ale_dockerfile_hadolint_options = '--ignore DL3006'
|
||||
|
||||
AssertLinter 'hadolint', 'hadolint --ignore DL3006 --no-color -'
|
||||
|
||||
Execute(The command should be correct when using Docker):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
||||
|
||||
AssertLinter 'docker', 'docker run --rm -i hadolint/hadolint hadolint --no-color -'
|
||||
|
||||
Execute(The command should be correct when using docker and supplying options):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
||||
let b:ale_dockerfile_hadolint_options = '--ignore DL3006'
|
||||
|
||||
AssertLinter 'docker',
|
||||
\ 'docker run --rm -i hadolint/hadolint hadolint --ignore DL3006 --no-color -'
|
|
@ -0,0 +1,31 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('json', 'jsonlint')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(local executable should be detected correctly):
|
||||
call ale#test#SetFilename('../test-files/jsonlint/app/src/app.json')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/jsonlint/app/node_modules/.bin/jsonlint'),
|
||||
\ ale_linters#json#jsonlint#GetExecutable(bufnr(''))
|
||||
\
|
||||
Execute(use_global should override project executable):
|
||||
let g:ale_json_jsonlint_use_global = 1
|
||||
|
||||
call ale#test#SetFilename('../test-files/jsonlint/app/src/app.json')
|
||||
|
||||
AssertEqual
|
||||
\ 'jsonlint',
|
||||
\ ale_linters#json#jsonlint#GetExecutable(bufnr(''))
|
||||
\
|
||||
Execute(manually defined should override default executable):
|
||||
let g:ale_json_jsonlint_use_global = 1
|
||||
let g:ale_json_jsonlint_executable = 'custom_jsonlint'
|
||||
|
||||
call ale#test#SetFilename('../test-files/jsonlint/app/src/app.json')
|
||||
|
||||
AssertEqual
|
||||
\ 'custom_jsonlint',
|
||||
\ ale_linters#json#jsonlint#GetExecutable(bufnr(''))
|
|
@ -0,0 +1,19 @@
|
|||
Before:
|
||||
call ale#assert#SetUpLinterTest('puppet', 'languageserver')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownLinterTest()
|
||||
|
||||
Execute(old-style module should find its root correctly):
|
||||
call ale#test#SetFilename('../test-files/puppet/old-style-module/manifests/init.pp')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/puppet/old-style-module'),
|
||||
\ ale_linters#puppet#languageserver#GetProjectRoot(bufnr(''))
|
||||
\
|
||||
Execute(new-style module should find its root correctly):
|
||||
call ale#test#SetFilename('../test-files/puppet/new-style-module/lib/puppet/types/exampletype.rb')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/../test-files/puppet/new-style-module'),
|
||||
\ ale_linters#puppet#languageserver#GetProjectRoot(bufnr(''))
|
|
@ -1,12 +1,5 @@
|
|||
Execute(Checks for versions below the current version should succeed):
|
||||
AssertEqual 1, ale#Has('ale-3.3.0')
|
||||
AssertEqual 1, ale#Has('ale-3.2.0')
|
||||
AssertEqual 1, ale#Has('ale-3.1.0')
|
||||
AssertEqual 1, ale#Has('ale-3.0.0')
|
||||
AssertEqual 1, ale#Has('ale-2.7.0')
|
||||
AssertEqual 1, ale#Has('ale-2.6.0')
|
||||
AssertEqual 1, ale#Has('ale-2.5.0')
|
||||
AssertEqual 1, ale#Has('ale-2.4.0')
|
||||
AssertEqual 1, ale#Has('ALE-2.2.1')
|
||||
AssertEqual 1, ale#Has('ALE-1.0.0')
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ Before:
|
|||
Save g:ale_sign_style_warning
|
||||
Save g:ale_sign_warning
|
||||
Save g:ale_sign_highlight_linenrs
|
||||
Save g:ale_statusline_format
|
||||
Save g:ale_type_map
|
||||
Save g:ale_use_neovim_diagnostics_api
|
||||
Save g:ale_use_global_executables
|
||||
|
@ -112,7 +111,6 @@ Before:
|
|||
let g:ale_sign_style_warning = '--'
|
||||
let g:ale_sign_warning = '--'
|
||||
let g:ale_sign_highlight_linenrs = 0
|
||||
let g:ale_statusline_format = ['%d error(s)', '%d warning(s)', 'OK']
|
||||
let g:ale_type_map = {}
|
||||
let g:ale_use_neovim_diagnostics_api = 0
|
||||
let g:ale_use_global_executables = v:null
|
||||
|
@ -189,7 +187,6 @@ Before:
|
|||
\ 'let g:ale_sign_style_warning = ''--''',
|
||||
\ 'let g:ale_sign_warning = ''--''',
|
||||
\ 'let g:ale_sign_highlight_linenrs = 0',
|
||||
\ 'let g:ale_statusline_format = [''%d error(s)'', ''%d warning(s)'', ''OK'']',
|
||||
\ 'let g:ale_type_map = {}',
|
||||
\ 'let g:ale_use_neovim_diagnostics_api = 0',
|
||||
\ 'let g:ale_use_global_executables = v:null',
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
After:
|
||||
unlet! g:output
|
||||
|
||||
Execute(ALEInfo -clipboard should that clipboard support is required):
|
||||
Execute(ALEInfo -clipboard should tell the user that clipboard support is required):
|
||||
" When run in the Docker image, there's no clipboard support, so this test
|
||||
" will actually run.
|
||||
if !has('clipboard')
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
Before:
|
||||
Save g:ale_run_synchronously
|
||||
Save g:ale_buffer_info
|
||||
|
||||
let g:ale_run_synchronously = 1
|
||||
let g:ale_buffer_info = {}
|
||||
|
||||
let g:checking_buffer = 0
|
||||
|
||||
unlet! b:ale_linted
|
||||
|
||||
function! TestCallback(buffer, output)
|
||||
return []
|
||||
endfunction
|
||||
|
||||
call ale#linter#PreventLoading('testft')
|
||||
call ale#linter#Define('testft', {
|
||||
\ 'name': 'testlinter',
|
||||
\ 'callback': 'TestCallback',
|
||||
\ 'executable': has('win32') ? 'cmd' : 'true',
|
||||
\ 'command': 'true',
|
||||
\})
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! g:checking_buffer
|
||||
|
||||
delfunction TestCallback
|
||||
call ale#linter#Reset()
|
||||
|
||||
augroup VaderTest
|
||||
autocmd!
|
||||
augroup END
|
||||
|
||||
augroup! VaderTest
|
||||
|
||||
Given testft (An empty file):
|
||||
Execute(ALELintPre should not return success on ale#engine#IsCheckingBuffer):
|
||||
augroup VaderTest
|
||||
autocmd!
|
||||
autocmd User ALELintPre let g:checking_buffer = ale#engine#IsCheckingBuffer(bufnr('')) ? 1 : 0
|
||||
augroup END
|
||||
|
||||
ALELint
|
||||
|
||||
AssertEqual g:checking_buffer, 0
|
||||
|
||||
Execute(ALEJobStarted should return success on ale#engine#IsCheckingBuffer):
|
||||
augroup VaderTest
|
||||
autocmd!
|
||||
autocmd User ALEJobStarted let g:checking_buffer = ale#engine#IsCheckingBuffer(bufnr('')) ? 1 : 0
|
||||
augroup END
|
||||
|
||||
ALELint
|
||||
|
||||
AssertEqual g:checking_buffer, 1
|
|
@ -1,59 +0,0 @@
|
|||
Given python(An example Python file):
|
||||
def main():
|
||||
a = 1
|
||||
c = a + 1
|
||||
|
||||
Execute():
|
||||
let g:changes = [
|
||||
\ {'end': {'offset': 7, 'line': 1}, 'newText': 'func_qtffgsv', 'start': {'offset': 5, 'line': 1}},
|
||||
\ {'end': {'offset': 9, 'line': 1}, 'newText': '', 'start': {'offset': 8, 'line': 1}},
|
||||
\ {'end': {'offset': 15, 'line': 3}, 'newText': " return c\n\n\ndef main():\n c = func_qtffgsvi()\n", 'start': {'offset': 15, 'line': 3}}
|
||||
\]
|
||||
|
||||
call ale#code_action#ApplyChanges(expand('%:p'), g:changes, {})
|
||||
|
||||
Expect(The changes should be applied correctly):
|
||||
def func_qtffgsvi():
|
||||
a = 1
|
||||
c = a + 1
|
||||
return c
|
||||
|
||||
|
||||
def main():
|
||||
c = func_qtffgsvi()
|
||||
|
||||
|
||||
Given python(Second python example):
|
||||
import sys
|
||||
import exifread
|
||||
|
||||
def main():
|
||||
with open(sys.argv[1], 'rb') as f:
|
||||
exif = exifread.process_file(f)
|
||||
dt = str(exif['Image DateTime'])
|
||||
date = dt[:10].replace(':', '-')
|
||||
|
||||
Execute():
|
||||
let g:changes = [
|
||||
\ {'end': {'offset': 16, 'line': 2}, 'newText': "\n\n\ndef func_ivlpdpao(f):\n exif = exifread.process_file(f)\n dt = str(exif['Image DateTime'])\n date = dt[:10].replace(':', '-')\n return date\n", 'start': {'offset': 16, 'line': 2}},
|
||||
\ {'end': {'offset': 32, 'line': 6}, 'newText': 'date = func', 'start': {'offset': 9, 'line': 6}},
|
||||
\ {'end': {'offset': 42, 'line': 8}, 'newText': "ivlpdpao(f)\n", 'start': {'offset': 33, 'line': 6}}
|
||||
\]
|
||||
|
||||
call ale#code_action#ApplyChanges(expand('%:p'), g:changes, {})
|
||||
|
||||
Expect(The changes should be applied correctly):
|
||||
import sys
|
||||
import exifread
|
||||
|
||||
|
||||
def func_ivlpdpao(f):
|
||||
exif = exifread.process_file(f)
|
||||
dt = str(exif['Image DateTime'])
|
||||
date = dt[:10].replace(':', '-')
|
||||
return date
|
||||
|
||||
|
||||
def main():
|
||||
with open(sys.argv[1], 'rb') as f:
|
||||
date = func_ivlpdpao(f)
|
|
@ -1,29 +0,0 @@
|
|||
Before:
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
runtime ale_linters/css/csslint.vim
|
||||
|
||||
After:
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(--config should be set when the .csslintrc file is found):
|
||||
call ale#test#SetFilename('test-files/csslint/some-app/subdir/testfile.js')
|
||||
|
||||
AssertEqual
|
||||
\ (
|
||||
\ 'csslint --format=compact '
|
||||
\ . '--config=' . ale#Escape(ale#path#Simplify(g:dir . '/test-files/csslint/some-app/.csslintrc'))
|
||||
\ . ' %t'
|
||||
\ ),
|
||||
\ ale_linters#css#csslint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(--config should not be used when no .csslintrc file exists):
|
||||
call ale#test#SetFilename('test-files/csslint/other-app/testfile.css')
|
||||
|
||||
AssertEqual
|
||||
\ (
|
||||
\ 'csslint --format=compact '
|
||||
\ . ' %t'
|
||||
\ ),
|
||||
\ ale_linters#css#csslint#GetCommand(bufnr(''))
|
|
@ -27,7 +27,7 @@ After:
|
|||
unlet! g:ale_run_synchronously_callbacks
|
||||
|
||||
Given foobar (Some imaginary filetype):
|
||||
Execute(It should be possible to compute an executable to check based on the result of commands):
|
||||
Execute(It should be possible to compute a command based on the result of other commands):
|
||||
AssertLinter has('win32') ? 'cmd' : 'echo', 'foo'
|
||||
|
||||
ALELint
|
||||
|
@ -37,7 +37,7 @@ Execute(It should be possible to compute an executable to check based on the res
|
|||
\ 1,
|
||||
\ len(filter(copy(b:ale_history), 'string(v:val.command) =~# ''foo'''))
|
||||
|
||||
Execute(It handle the deferred command failing):
|
||||
Execute(We should handle the deferered command failing):
|
||||
let g:ale_emulate_job_failure = 1
|
||||
|
||||
AssertLinter has('win32') ? 'cmd' : 'echo', 0
|
||||
|
|
|
@ -33,7 +33,7 @@ Execute(It should be possible to compute an executable to check based on the res
|
|||
\ [{'status': 0, 'job_id': 'executable', 'command': 'foo'}],
|
||||
\ filter(copy(b:ale_history), 'v:val.job_id is# ''executable''')
|
||||
|
||||
Execute(It handle the deferred command failing):
|
||||
Execute(We should handle the deferered executable command failing):
|
||||
let g:ale_emulate_job_failure = 1
|
||||
|
||||
AssertLinter 0, 'echo'
|
||||
|
|
|
@ -39,7 +39,8 @@ Before:
|
|||
silent mess
|
||||
redir END
|
||||
|
||||
let l:lines = split(l:output, "\n")
|
||||
" Filter out messages that could come from saving this test file.
|
||||
let l:lines = filter(split(l:output, "\n"), 'v:val !~ ''written\|No line''')
|
||||
|
||||
return empty(l:lines) ? '' : l:lines[-1]
|
||||
endfunction
|
||||
|
@ -65,14 +66,9 @@ Execute(Linting shouldn't happen when ALE is disabled globally):
|
|||
call ale#Queue(0)
|
||||
|
||||
AssertEqual {}, g:ale_buffer_info
|
||||
|
||||
Execute(Linting shouldn't happen when the file is too large with a global options):
|
||||
let g:ale_maximum_file_size = 12
|
||||
let g:ale_buffer_info = {}
|
||||
|
||||
call ale#Queue(0)
|
||||
|
||||
AssertEqual {}, g:ale_buffer_info
|
||||
call SetUpCursorData()
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
AssertEqual '', GetLastMessage()
|
||||
|
||||
Execute(Linting shouldn't happen when ALE is disabled locally):
|
||||
let b:ale_enabled = 0
|
||||
|
@ -81,39 +77,29 @@ Execute(Linting shouldn't happen when ALE is disabled locally):
|
|||
call ale#Queue(0)
|
||||
|
||||
AssertEqual {}, g:ale_buffer_info
|
||||
call SetUpCursorData()
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
AssertEqual '', GetLastMessage()
|
||||
|
||||
Execute(Linting shouldn't happen when the file is too large with a local options):
|
||||
Execute(Linting shouldn't happen when the file is too large with global options):
|
||||
let g:ale_maximum_file_size = 12
|
||||
let g:ale_buffer_info = {}
|
||||
|
||||
call ale#Queue(0)
|
||||
|
||||
AssertEqual {}, g:ale_buffer_info
|
||||
" We shouldn't show cursor warnings.
|
||||
call SetUpCursorData()
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
AssertEqual '', GetLastMessage()
|
||||
|
||||
Execute(Linting shouldn't happen when the file is too large with local options):
|
||||
let b:ale_maximum_file_size = 12
|
||||
let g:ale_buffer_info = {}
|
||||
|
||||
call ale#Queue(0)
|
||||
|
||||
AssertEqual {}, g:ale_buffer_info
|
||||
|
||||
Execute(Cursor warnings shouldn't be echoed when ALE is disabled globally):
|
||||
let g:ale_enabled = 0
|
||||
|
||||
call SetUpCursorData()
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
AssertEqual '', GetLastMessage()
|
||||
|
||||
Execute(Cursor warnings shouldn't be echoed when the file is too large with global options):
|
||||
let g:ale_maximum_file_size = 12
|
||||
|
||||
call SetUpCursorData()
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
AssertEqual '', GetLastMessage()
|
||||
|
||||
Execute(Cursor warnings shouldn't be echoed when ALE is disabled locally):
|
||||
let b:ale_enabled = 0
|
||||
|
||||
call SetUpCursorData()
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
AssertEqual '', GetLastMessage()
|
||||
|
||||
Execute(Cursor warnings shouldn't be echoed when the file is too large with local options):
|
||||
let b:ale_maximum_file_size = 12
|
||||
|
||||
call SetUpCursorData()
|
||||
call ale#cursor#EchoCursorWarning()
|
||||
AssertEqual '', GetLastMessage()
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
" NOTE: We use the 'b:' forms below to ensure that we're properly using
|
||||
" ale#Var()
|
||||
|
||||
Given dockerfile:
|
||||
#
|
||||
|
||||
Before:
|
||||
Save g:ale_dockerfile_hadolint_use_docker
|
||||
Save g:ale_dockerfile_hadolint_docker_image
|
||||
silent! unlet g:ale_dockerfile_hadolint_use_docker
|
||||
silent! unlet g:ale_dockerfile_hadolint_docker_image
|
||||
|
||||
" enable loading inside test container
|
||||
silent! cd /testplugin
|
||||
source ale_linters/dockerfile/hadolint.vim
|
||||
|
||||
|
||||
After:
|
||||
Restore
|
||||
silent! unlet b:ale_dockerfile_hadolint_use_docker
|
||||
silent! unlet b:ale_dockerfile_hadolint_docker_image
|
||||
silent! unlet b:ale_dockerfile_hadolint_options
|
||||
|
||||
|
||||
Execute(linter honors ..._use_docker correctly):
|
||||
|
||||
" default: never
|
||||
AssertEqual
|
||||
\ 'hadolint',
|
||||
\ ale_linters#dockerfile#hadolint#GetExecutable(bufnr(''))
|
||||
|
||||
" explicit never
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'never'
|
||||
AssertEqual
|
||||
\ 'hadolint',
|
||||
\ ale_linters#dockerfile#hadolint#GetExecutable(bufnr(''))
|
||||
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
||||
AssertEqual
|
||||
\ 'docker',
|
||||
\ ale_linters#dockerfile#hadolint#GetExecutable(bufnr(''))
|
||||
|
||||
" hadolint if present, otherwise docker
|
||||
let command = 'docker'
|
||||
if executable('hadolint')
|
||||
let command = 'hadolint'
|
||||
endif
|
||||
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'yes'
|
||||
AssertEqual
|
||||
\ command,
|
||||
\ ale_linters#dockerfile#hadolint#GetExecutable(bufnr(''))
|
||||
|
||||
|
||||
Execute(command is correct when using docker):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
||||
|
||||
AssertEqual
|
||||
\ "docker run --rm -i hadolint/hadolint hadolint --no-color -",
|
||||
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(command is correct when using docker and supplying options):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'always'
|
||||
let b:ale_dockerfile_hadolint_options = '--ignore DL3006'
|
||||
|
||||
AssertEqual
|
||||
\ "docker run --rm -i hadolint/hadolint hadolint --ignore DL3006 --no-color -",
|
||||
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(command is correct when not docker):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'never'
|
||||
|
||||
AssertEqual
|
||||
\ "hadolint --no-color -",
|
||||
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(command is correct when not docker and supplying options):
|
||||
let b:ale_dockerfile_hadolint_use_docker = 'never'
|
||||
let b:ale_dockerfile_hadolint_options = '--ignore DL3006'
|
||||
|
||||
AssertEqual
|
||||
\ "hadolint --ignore DL3006 --no-color -",
|
||||
\ ale_linters#dockerfile#hadolint#GetCommand(bufnr(''))
|
||||
|
||||
Execute(test warnings from hadolint):
|
||||
AssertEqual
|
||||
\ [{'lnum': 10, 'col': 0, 'type': 'W', 'code': 'DL3007', 'text': 'DL3007: Using latest is prone to errors', 'detail': "DL3007 ( https://github.com/hadolint/hadolint/wiki/DL3007 )\n\nUsing latest is prone to errors"}],
|
||||
\ ale_linters#dockerfile#hadolint#Handle(bufnr(''), [
|
||||
\ '-:10 DL3007 warning: Using latest is prone to errors',
|
||||
\ ])
|
||||
|
||||
Execute(test warnings from shellcheck):
|
||||
AssertEqual
|
||||
\ [{'lnum': 3, 'col': 0, 'type': 'W', 'code': 'SC2154', 'text': 'SC2154: bar is referenced but not assigned.', 'detail': "SC2154 ( https://github.com/koalaman/shellcheck/wiki/SC2154 )\n\nbar is referenced but not assigned."}],
|
||||
\ ale_linters#dockerfile#hadolint#Handle(bufnr(''), [
|
||||
\ '-:3 SC2154 warning: bar is referenced but not assigned.',
|
||||
\ ])
|
||||
|
||||
Execute(test errors from dockerfile parser):
|
||||
AssertEqual
|
||||
\ [{'lnum': 3, 'col': 4, 'type': 'E', 'text': 'unexpected "A" expecting at least one space after ''RUN''', 'detail': 'hadolint could not parse the file because of a syntax error.'}],
|
||||
\ ale_linters#dockerfile#hadolint#Handle(bufnr(''), [
|
||||
\ "/dev/stdin:3:4 unexpected \"A\" expecting at least one space after 'RUN'",
|
||||
\ ])
|
||||
|
||||
" fin...
|
|
@ -8,20 +8,11 @@ Before:
|
|||
augroup END
|
||||
|
||||
After:
|
||||
unlet! g:map
|
||||
augroup TestFiletypeGroup
|
||||
autocmd!
|
||||
augroup END
|
||||
augroup! TestFiletypeGroup
|
||||
|
||||
Execute(ALE should parse autocmd filetypes correctly):
|
||||
let g:map = ale#filetypes#LoadExtensionMap()
|
||||
|
||||
AssertEqual '.x', g:map['xfiletype']
|
||||
AssertEqual '.y', g:map['yfiletype']
|
||||
AssertEqual '.z', g:map['zfiletype']
|
||||
AssertEqual '.jsx', g:map['javascript.jsx']
|
||||
|
||||
Execute(ALE should guess file extensions appropriately):
|
||||
" The whole string should be used, if there's a match.
|
||||
AssertEqual '.jsx', ale#filetypes#GuessExtension('javascript.jsx')
|
|
@ -1,45 +0,0 @@
|
|||
Before:
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
runtime ale_linters/json/jsonlint.vim
|
||||
|
||||
After:
|
||||
let g:ale_json_jsonlint_executable = 'jsonlint'
|
||||
let g:ale_json_jsonlint_use_global = 0
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(local executable should be detected correctly):
|
||||
call ale#test#SetFilename('test-files/jsonlint/app/src/app.json')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/test-files/jsonlint/app/node_modules/.bin/jsonlint'),
|
||||
\ ale_linters#json#jsonlint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(recursively executable should be detected correctly):
|
||||
call ale#test#SetFilename('test-files/jsonlint/app-without-jsonlint/src/app.json')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/test-files/jsonlint/node_modules/jsonlint/lib/cli.js'),
|
||||
\ ale_linters#json#jsonlint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(use_global should override project executable):
|
||||
let g:ale_json_jsonlint_use_global = 1
|
||||
|
||||
call ale#test#SetFilename('test-files/jsonlint/app/src/app.json')
|
||||
|
||||
AssertEqual
|
||||
\ 'jsonlint',
|
||||
\ ale_linters#json#jsonlint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(manually defined should override default executable):
|
||||
let g:ale_json_jsonlint_use_global = 1
|
||||
let g:ale_json_jsonlint_executable = 'custom_jsonlint'
|
||||
|
||||
call ale#test#SetFilename('test-files/jsonlint/app/src/app.json')
|
||||
|
||||
AssertEqual
|
||||
\ 'custom_jsonlint',
|
||||
\ ale_linters#json#jsonlint#GetExecutable(bufnr(''))
|
||||
|
|
@ -246,13 +246,7 @@ Execute(The quickfix window should be horizontal for the quickfix with appropria
|
|||
|
||||
AssertEqual 0, GetQuickfixIsVertical(8)
|
||||
|
||||
Execute(The buffer ale_open_list option should be respected):
|
||||
let b:ale_open_list = 1
|
||||
|
||||
call ale#list#SetLists(bufnr('%'), g:loclist)
|
||||
Assert ale#list#IsQuickfixOpen()
|
||||
|
||||
Execute(The buffer ale_keep_list_window_open option should be respected):
|
||||
Execute(buffer-local options should be respected):
|
||||
let b:ale_open_list = 1
|
||||
let b:ale_keep_list_window_open = 1
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
Before:
|
||||
runtime ale_linters/nim/nimlsp.vim
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
After:
|
||||
if isdirectory(g:dir . '/.git')
|
||||
call delete(g:dir . '/.git', 'd')
|
||||
endif
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
|
||||
Execute(Detect root of nim project with .git/ correctly):
|
||||
call ale#test#SetFilename('test-files/nim/with-git/src/source.nim')
|
||||
call mkdir(g:dir . '/.git')
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir),
|
||||
\ ale_linters#nim#nimlsp#GetProjectRoot(bufnr(''))
|
|
@ -154,7 +154,7 @@ Given python(Some Python file):
|
|||
somelongerline
|
||||
bazxyzxyzxyz
|
||||
|
||||
Execute(Should result in error message):
|
||||
Execute(Should result in error message for LSP):
|
||||
call ale#linter#Reset()
|
||||
runtime ale_linters/python/pylsp.vim
|
||||
let b:ale_linters = ['pylsp']
|
||||
|
|
|
@ -5,48 +5,27 @@ After:
|
|||
delcommand ParseTest
|
||||
endif
|
||||
|
||||
Execute(ale#args#Parse should handle empty input):
|
||||
AssertEqual
|
||||
\ [{}, ''],
|
||||
\ ale#args#Parse([], '')
|
||||
AssertEqual
|
||||
\ [{}, ''],
|
||||
\ ale#args#Parse(['foo', 'bar'], '')
|
||||
|
||||
Execute(ale#args#Parse should parse commands correctly):
|
||||
AssertEqual
|
||||
\ [{'foo': '', 'bar': ''}, 'leave these alone'],
|
||||
\ ale#args#Parse(['foo', 'bar'], '-foo -bar leave these alone')
|
||||
AssertEqual
|
||||
\ [{'foo': ''}, 'leave these alone'],
|
||||
\ ale#args#Parse(['foo', 'bar'], '-foo leave these alone')
|
||||
|
||||
Execute(ale#args#Parse should raise errors for unknown arguments):
|
||||
AssertThrows call ale#args#Parse(['foo', 'bar'], '-nope leave these alone')
|
||||
AssertEqual 'Invalid argument: -nope', g:vader_exception
|
||||
|
||||
Execute(ale#args#Parse should stop parsing arguments after --):
|
||||
AssertEqual
|
||||
\ [{'foo': ''}, ' --nope leave these alone'],
|
||||
\ ale#args#Parse(['foo', 'bar'], '-foo -- --nope leave these alone')
|
||||
AssertEqual
|
||||
\ [{}, '--'],
|
||||
\ ale#args#Parse(['foo', 'bar'], '-- --')
|
||||
AssertEqual
|
||||
\ [{}, ''],
|
||||
\ ale#args#Parse(['foo', 'bar'], '--')
|
||||
|
||||
Execute(ale#args#Parse should work for an example command):
|
||||
command! -nargs=* ParseTest let b:parse_result = ale#args#Parse(['foo', 'bar'], <q-args>)
|
||||
|
||||
ParseTest
|
||||
AssertEqual [{}, ''], b:parse_result
|
||||
|
||||
ParseTest --
|
||||
AssertEqual [{}, ''], b:parse_result
|
||||
|
||||
ParseTest -foo
|
||||
AssertEqual [{'foo': ''}, ''], b:parse_result
|
||||
|
||||
ParseTest -foo -- --
|
||||
AssertEqual [{'foo': ''}, '--'], b:parse_result
|
||||
|
||||
ParseTest -foo -bar
|
||||
AssertEqual [{'foo': '', 'bar': ''}, ''], b:parse_result
|
||||
|
||||
ParseTest -foo -bar leave these alone
|
||||
AssertEqual [{'foo': '', 'bar': ''}, 'leave these alone'], b:parse_result
|
||||
|
||||
Execute(ale#args#Parse should raise errors for unknown arguments):
|
||||
AssertThrows call ale#args#Parse(['foo', 'bar'], '-nope leave these alone')
|
||||
AssertEqual 'Invalid argument: -nope', g:vader_exception
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
Before:
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
runtime ale_linters/puppet/languageserver.vim
|
||||
|
||||
After:
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(old-style module should find its root correctly):
|
||||
call ale#test#SetFilename('test-files/puppet/old-style-module/manifests/init.pp')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/test-files/puppet/old-style-module'),
|
||||
\ ale_linters#puppet#languageserver#GetProjectRoot(bufnr(''))
|
||||
|
||||
Execute(new-style module should find its root correctly):
|
||||
call ale#test#SetFilename('test-files/puppet/new-style-module/lib/puppet/types/exampletype.rb')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/test-files/puppet/new-style-module'),
|
||||
\ ale_linters#puppet#languageserver#GetProjectRoot(bufnr(''))
|
|
@ -1,11 +0,0 @@
|
|||
Before:
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
After:
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(Detect root of Python project with .flake8 correctly):
|
||||
call ale#test#SetFilename('test-files/python/python-package-project/package-name/module.py')
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/test-files/python/python-package-project'),
|
||||
\ ale#python#FindProjectRoot(bufnr(''))
|
|
@ -201,16 +201,6 @@ Execute(Code actions from tsserver should be handled):
|
|||
\ ],
|
||||
\ g:code_actions
|
||||
|
||||
Execute(HandleTSServerResponse does nothing when no data in rename_map):
|
||||
call ale#rename#HandleTSServerResponse(1, {
|
||||
\ 'command': 'rename',
|
||||
\ 'request_seq': -9,
|
||||
\ 'success': v:true,
|
||||
\ 'body': {}
|
||||
\})
|
||||
|
||||
AssertEqual g:handle_code_action_called, 0
|
||||
|
||||
Execute(Prints a tsserver error message when unsuccessful):
|
||||
call ale#rename#HandleTSServerResponse(1, {
|
||||
\ 'command': 'rename',
|
||||
|
@ -223,7 +213,7 @@ Execute(Prints a tsserver error message when unsuccessful):
|
|||
AssertEqual ['echom ''Error renaming "oldName" to: "aNewName". ' .
|
||||
\ 'Reason: This symbol cannot be renamed'''], g:expr_list
|
||||
|
||||
Execute(Does nothing when no changes):
|
||||
Execute(HandleTSServerResponse does nothing when no changes):
|
||||
call ale#rename#HandleTSServerResponse(1, {
|
||||
\ 'command': 'rename',
|
||||
\ 'request_seq': 3,
|
||||
|
|
|
@ -8,7 +8,7 @@ Execute(ParseVersion should return the version from the lines of output):
|
|||
\ '1.2.3',
|
||||
\])
|
||||
|
||||
Execute(ParseVersion should return an empty list when no vesrion can be found):
|
||||
Execute(ParseVersion should return an empty list when no version can be found):
|
||||
AssertEqual [], ale#semver#ParseVersion(['x'])
|
||||
AssertEqual [], ale#semver#ParseVersion([])
|
||||
|
||||
|
@ -17,8 +17,6 @@ Execute(ParseVersion should tolerate missing patch numbers):
|
|||
AssertEqual [3, 4, 0], ale#semver#ParseVersion(['Version 3.4'])
|
||||
|
||||
Execute(GTE should compare triples correctly):
|
||||
Assert ale#semver#GTE([3, 0, 4], [3, 0, 0])
|
||||
Assert ale#semver#GTE([3, 0, 0], [3, 0, 0])
|
||||
Assert ale#semver#GTE([3, 0, 0], [2, 0, 0])
|
||||
Assert ale#semver#GTE([3, 1, 0], [3, 1, 0])
|
||||
Assert ale#semver#GTE([3, 2, 0], [3, 1, 0])
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
Before:
|
||||
Save g:ale_statusline_format
|
||||
Save g:ale_buffer_info
|
||||
|
||||
let g:ale_buffer_info = {}
|
||||
|
@ -82,8 +81,8 @@ Execute (Count should read data from the cache):
|
|||
AssertEqual Counts({'error': 1, 'warning': 2}), ale#statusline#Count(44)
|
||||
|
||||
Execute (FirstProblem should read data from the cache):
|
||||
let g:ale_buffer_info =
|
||||
\{"44":
|
||||
let g:ale_buffer_info =
|
||||
\{"44":
|
||||
\{'count': 0,
|
||||
\'first_problems':
|
||||
\{'error': {'lnum': 3},
|
||||
|
@ -91,7 +90,7 @@ Execute (FirstProblem should read data from the cache):
|
|||
\'style_error': {'lnum': 22},
|
||||
\'style_warning': {'lnum': 223},
|
||||
\'info': {'lnum': 2}
|
||||
\}
|
||||
\}
|
||||
\}
|
||||
\}
|
||||
AssertEqual {'lnum': 3}, ale#statusline#FirstProblem(44, 'error')
|
||||
|
@ -143,15 +142,3 @@ Execute (Output should be empty for non-existent buffer):
|
|||
AssertEqual {}, ale#statusline#FirstProblem(9001, 'style_error')
|
||||
AssertEqual {}, ale#statusline#FirstProblem(9001, 'style_warning')
|
||||
AssertEqual {}, ale#statusline#FirstProblem(9001, 'info')
|
||||
|
||||
Execute(ale#statusline#Update shouldn't blow up when globals are undefined):
|
||||
unlet! g:ale_statusline_format
|
||||
call ale#statusline#Update(1, [])
|
||||
|
||||
Execute(ale#statusline#Count should return 0 counts when globals are undefined):
|
||||
unlet! g:ale_statusline_format
|
||||
AssertEqual Counts({}), ale#statusline#Count(1)
|
||||
|
||||
Execute(FirstProblem should return an empty dict when globals are undefined):
|
||||
unlet! g:ale_statusline_format
|
||||
AssertEqual {}, ale#statusline#FirstProblem(bufnr(''), 'info')
|
||||
|
|
|
@ -19,7 +19,7 @@ Execute(ale#util#Tempname shouldn't set $TMPDIR to an empty string if it isn't s
|
|||
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.):
|
||||
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'
|
||||
|
|
|
@ -129,7 +129,7 @@ Execute(We should find a virtualtext error on line 2):
|
|||
endif
|
||||
|
||||
Execute(We should be able to change the virtualtext prefix globally):
|
||||
let g:ale_virtualtext_prefix = '> '
|
||||
let g:ale_virtualtext_prefix = '%severity%: '
|
||||
|
||||
if has('patch-9.0.0297') || has('nvim-0.8.0')
|
||||
let g:ale_virtualtext_cursor = 'current'
|
||||
|
@ -138,7 +138,7 @@ Execute(We should be able to change the virtualtext prefix globally):
|
|||
" Tick the timer.
|
||||
sleep 1ms
|
||||
|
||||
AssertEqual '> Line 1 error', ale#virtualtext#GetLastMessageForTests()
|
||||
AssertEqual 'Error: Line 1 error', ale#virtualtext#GetLastMessageForTests()
|
||||
endif
|
||||
|
||||
Execute(We should be able to change the virtualtext prefix per-buffer):
|
||||
|
@ -154,19 +154,6 @@ Execute(We should be able to change the virtualtext prefix per-buffer):
|
|||
AssertEqual 'B> Line 1 error', ale#virtualtext#GetLastMessageForTests()
|
||||
endif
|
||||
|
||||
Execute(We should be format in other data from the loclist items):
|
||||
let g:ale_virtualtext_prefix = '%severity%: '
|
||||
|
||||
if has('patch-9.0.0297') || has('nvim-0.8.0')
|
||||
let g:ale_virtualtext_cursor = 'current'
|
||||
call cursor(1, 1)
|
||||
call ale#virtualtext#ShowCursorWarningWithDelay()
|
||||
" Tick the timer.
|
||||
sleep 1ms
|
||||
|
||||
AssertEqual 'Error: Line 1 error', ale#virtualtext#GetLastMessageForTests()
|
||||
endif
|
||||
|
||||
Execute(We should set errors across all lines):
|
||||
if has('patch-9.0.0297') || has('nvim-0.8.0')
|
||||
call ale#virtualtext#SetTexts(bufnr(''), g:ale_buffer_info[bufnr('')].loclist)
|
||||
|
|
|
@ -23,12 +23,7 @@ Execute(The command wrapper should work with a nice command):
|
|||
|
||||
call TestCommand('nice -n 5 foo bar', 'foo bar')
|
||||
|
||||
Execute(The command wrapper should work with a nice command with an explicit marker):
|
||||
let b:ale_command_wrapper = 'nice -n 5 %*'
|
||||
|
||||
call TestCommand('nice -n 5 foo bar', 'foo bar')
|
||||
|
||||
Execute(Wrappers with spread arguments in the middle should be supported):
|
||||
Execute(The command wrapper should spread arguments correctly):
|
||||
let b:ale_command_wrapper = 'wrap %* --'
|
||||
|
||||
call TestCommand('wrap foo bar --', 'foo bar')
|
||||
|
|
Loading…
Reference in New Issue