summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/command_callback/python_paths/with_virtualenv/env/Scripts/pylama.exe0
-rwxr-xr-xtest/command_callback/python_paths/with_virtualenv/env/Scripts/vulture.exe0
-rwxr-xr-xtest/command_callback/python_paths/with_virtualenv/env/bin/pylama0
-rwxr-xr-xtest/command_callback/python_paths/with_virtualenv/env/bin/vulture0
-rw-r--r--test/command_callback/test_cypher_cypher_lint_command_callback.vader8
-rw-r--r--test/command_callback/test_javalsp_command_callback.vader4
-rw-r--r--test/command_callback/test_pylama_command_callback.vader85
-rw-r--r--test/command_callback/test_shellcheck_command_callback.vader12
-rw-r--r--test/command_callback/test_vulture_command_callback.vader68
-rw-r--r--test/completion/test_lsp_completion_messages.vader4
-rw-r--r--test/fix/test_ale_fix.vader59
-rw-r--r--test/fixers/test_black_fixer_callback.vader7
-rw-r--r--test/handler/test_cypher_lint_handler.vader21
-rw-r--r--test/handler/test_flake8_handler.vader2
-rw-r--r--test/handler/test_pylama_handler.vader212
-rw-r--r--test/handler/test_vulture_handler.vader2
-rw-r--r--test/lsp/test_reset_lsp.vader12
-rwxr-xr-xtest/script/block-padding-checker32
-rw-r--r--test/sign/test_linting_sets_signs.vader1
-rw-r--r--test/sign/test_sign_placement.vader1
-rw-r--r--test/smoke_test.vader8
-rw-r--r--test/test_ale_lint_command.vader4
-rw-r--r--test/test_ale_toggle.vader19
-rw-r--r--test/test_command_chain.vader3
-rw-r--r--test/test_errors_removed_after_filetype_changed.vader7
-rw-r--r--test/test_format_temporary_file_creation.vader3
-rw-r--r--test/test_highlight_placement.vader3
-rw-r--r--test/test_history_saving.vader68
-rw-r--r--test/test_lint_file_linters.vader20
-rw-r--r--test/test_lint_on_enter_when_file_changed.vader2
-rw-r--r--test/test_linting_blacklist.vader2
-rw-r--r--test/test_linting_updates_loclist.vader1
-rw-r--r--test/test_loclist_jumping.vader78
-rw-r--r--test/test_no_linting_on_write_quit.vader8
-rw-r--r--test/test_parse_command_args.vader52
-rw-r--r--test/test_python_traceback.vader79
-rw-r--r--test/test_symbol_search.vader18
-rw-r--r--test/test_temporary_file_management.vader10
38 files changed, 820 insertions, 95 deletions
diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/pylama.exe b/test/command_callback/python_paths/with_virtualenv/env/Scripts/pylama.exe
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/pylama.exe
diff --git a/test/command_callback/python_paths/with_virtualenv/env/Scripts/vulture.exe b/test/command_callback/python_paths/with_virtualenv/env/Scripts/vulture.exe
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/python_paths/with_virtualenv/env/Scripts/vulture.exe
diff --git a/test/command_callback/python_paths/with_virtualenv/env/bin/pylama b/test/command_callback/python_paths/with_virtualenv/env/bin/pylama
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/python_paths/with_virtualenv/env/bin/pylama
diff --git a/test/command_callback/python_paths/with_virtualenv/env/bin/vulture b/test/command_callback/python_paths/with_virtualenv/env/bin/vulture
new file mode 100755
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/python_paths/with_virtualenv/env/bin/vulture
diff --git a/test/command_callback/test_cypher_cypher_lint_command_callback.vader b/test/command_callback/test_cypher_cypher_lint_command_callback.vader
new file mode 100644
index 00000000..6b64dc1f
--- /dev/null
+++ b/test/command_callback/test_cypher_cypher_lint_command_callback.vader
@@ -0,0 +1,8 @@
+Before:
+ call ale#assert#SetUpLinterTest('cypher', 'cypher_lint')
+
+After:
+ call ale#assert#TearDownLinterTest()
+
+Execute(The default command and executable should be correct):
+ AssertLinter 'cypher-lint', 'cypher-lint'
diff --git a/test/command_callback/test_javalsp_command_callback.vader b/test/command_callback/test_javalsp_command_callback.vader
index aedb4a4b..8bfaa8ee 100644
--- a/test/command_callback/test_javalsp_command_callback.vader
+++ b/test/command_callback/test_javalsp_command_callback.vader
@@ -6,9 +6,9 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The javalsp callback should return the correct default value):
- AssertLinter 'java', ale#Escape('java') . ' -cp javacs.jar -Xverify:none org.javacs.Main'
+ AssertLinter 'java', ale#Escape('java') . ' -Xverify:none -m javacs/org.javacs.Main'
Execute(The javalsp java executable should be configurable):
let b:ale_java_javalsp_executable = '/bin/foobar'
- AssertLinter '/bin/foobar', ale#Escape('/bin/foobar') . ' -cp javacs.jar -Xverify:none org.javacs.Main'
+ AssertLinter '/bin/foobar', ale#Escape('/bin/foobar') . ' -Xverify:none -m javacs/org.javacs.Main'
diff --git a/test/command_callback/test_pylama_command_callback.vader b/test/command_callback/test_pylama_command_callback.vader
new file mode 100644
index 00000000..a24b55f8
--- /dev/null
+++ b/test/command_callback/test_pylama_command_callback.vader
@@ -0,0 +1,85 @@
+Before:
+ call ale#assert#SetUpLinterTest('python', 'pylama')
+ call ale#test#SetFilename('test.py')
+
+ let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
+ let b:command_tail = ' %t'
+
+After:
+ unlet! b:bin_dir
+ unlet! b:executable
+ unlet! b:command_tail
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(The pylama command callback should return a default):
+ AssertLinter 'pylama',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('pylama') . b:command_tail
+
+Execute(The option for disabling changing directories should work):
+ let g:ale_python_pylama_change_directory = 0
+
+ AssertLinter 'pylama', ale#Escape('pylama') . b:command_tail
+
+Execute(The pylama executable should be configurable, and escaped properly):
+ let g:ale_python_pylama_executable = 'executable with spaces'
+
+ AssertLinter 'executable with spaces',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('executable with spaces') . b:command_tail
+
+Execute(The pylama command callback should let you set options):
+ let g:ale_python_pylama_options = '--some-option'
+
+ AssertLinter 'pylama',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('pylama') . ' --some-option' . b:command_tail
+
+Execute(The pylama command callback should switch directories to the detected project root):
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
+
+ AssertLinter 'pylama',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
+ \ . ale#Escape('pylama') . b:command_tail
+
+Execute(The pylama command callback shouldn't detect virtualenv directories where they don't exist):
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
+
+ AssertLinter 'pylama',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
+ \ . ale#Escape('pylama') . b:command_tail
+
+Execute(The pylama command callback should detect virtualenv directories and switch to the project root):
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
+
+ let b:executable = ale#path#Simplify(
+ \ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pylama'
+ \)
+
+ AssertLinter b:executable,
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
+ \ . ale#Escape(b:executable) . b:command_tail
+
+Execute(You should able able to use the global pylama instead):
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
+ let g:ale_python_pylama_use_global = 1
+
+ AssertLinter 'pylama',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
+ \ . ale#Escape('pylama') . b:command_tail
+
+Execute(Setting executable to 'pipenv' appends 'run pylama'):
+ let g:ale_python_pylama_executable = 'path/to/pipenv'
+
+ AssertLinter 'path/to/pipenv',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('path/to/pipenv') . ' run pylama' . b:command_tail
+
+Execute(Pipenv is detected when python_pylama_auto_pipenv is set):
+ let g:ale_python_pylama_auto_pipenv = 1
+ call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
+
+ AssertLinter 'pipenv',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('pipenv') . ' run pylama' . b:command_tail
diff --git a/test/command_callback/test_shellcheck_command_callback.vader b/test/command_callback/test_shellcheck_command_callback.vader
index 22a9ccb5..c5360b7d 100644
--- a/test/command_callback/test_shellcheck_command_callback.vader
+++ b/test/command_callback/test_shellcheck_command_callback.vader
@@ -33,6 +33,18 @@ Execute(The shellcheck command should include the dialect):
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' -s bash' . b:suffix
+Execute(The shellcheck command should use ale_sh_shellcheck_dialect):
+ let b:ale_sh_shellcheck_dialect = 'ksh93'
+
+ AssertLinter 'shellcheck',
+ \ b:prefix . ale#Escape('shellcheck') . ' -s ksh93' . b:suffix
+
+Execute(The shellcheck command should allow unspecified dialect):
+ let b:ale_sh_shellcheck_dialect = ''
+
+ AssertLinter 'shellcheck',
+ \ b:prefix . ale#Escape('shellcheck') . b:suffix
+
Execute(The shellcheck command should include the dialect before options and exclusions):
let b:is_bash = 1
let b:ale_sh_shellcheck_options = '--foobar'
diff --git a/test/command_callback/test_vulture_command_callback.vader b/test/command_callback/test_vulture_command_callback.vader
new file mode 100644
index 00000000..d6c866b9
--- /dev/null
+++ b/test/command_callback/test_vulture_command_callback.vader
@@ -0,0 +1,68 @@
+Before:
+ call ale#assert#SetUpLinterTest('python', 'vulture')
+ call ale#test#SetFilename('test.py')
+
+ let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
+
+After:
+ unlet! b:bin_dir
+ unlet! b:executable
+
+ call ale#assert#TearDownLinterTest()
+
+Execute(The vulture command callback should lint file directory by default):
+ AssertLinter 'vulture',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('vulture') . ' .'
+
+Execute(The vulture command callback should lint project root, when present):
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
+
+ AssertLinter 'vulture',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
+ \ . ale#Escape('vulture') . ' .'
+
+Execute(The option for disabling change directory works and only lints file):
+ let g:ale_python_vulture_change_directory = 0
+
+ AssertLinter 'vulture', ale#Escape('vulture') . ' %s'
+
+Execute(The vulture executable should be configurable, and escaped properly):
+ let g:ale_python_vulture_executable = 'executable with spaces'
+
+ AssertLinter 'executable with spaces',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('executable with spaces') . ' .'
+
+Execute(The vulture command callback should let you set options):
+ let g:ale_python_vulture_options = '--some-option'
+
+ AssertLinter 'vulture',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('vulture') . ' --some-option .'
+
+Execute(The vulture command callback should detect virtualenv directories and switch to the project root):
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
+
+ let b:executable = ale#path#Simplify(
+ \ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/vulture'
+ \)
+
+ AssertLinter b:executable,
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
+ \ . ale#Escape(b:executable) . ' .'
+
+Execute(You should able able to use the global vulture instead):
+ silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
+ let g:ale_python_vulture_use_global = 1
+
+ AssertLinter 'vulture',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
+ \ . ale#Escape('vulture') . ' .'
+
+Execute(Setting executable to 'pipenv' appends 'run vulture'):
+ let g:ale_python_vulture_executable = 'path/to/pipenv'
+
+ AssertLinter 'path/to/pipenv',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('path/to/pipenv') . ' run vulture' . ' .'
diff --git a/test/completion/test_lsp_completion_messages.vader b/test/completion/test_lsp_completion_messages.vader
index f670e186..130f31b9 100644
--- a/test/completion/test_lsp_completion_messages.vader
+++ b/test/completion/test_lsp_completion_messages.vader
@@ -215,7 +215,7 @@ Execute(The right message should be sent for the initial LSP request):
\ }],
\ [0, 'textDocument/completion', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
- \ 'position': {'line': 0, 'character': 2},
+ \ 'position': {'line': 0, 'character': 3},
\ }],
\ ],
\ g:message_list
@@ -274,7 +274,7 @@ Execute(Two completion requests shouldn't be sent in a row):
\ }],
\ [0, 'textDocument/completion', {
\ 'textDocument': {'uri': ale#path#ToURI(expand('%:p'))},
- \ 'position': {'line': 0, 'character': 2},
+ \ 'position': {'line': 0, 'character': 3},
\ }],
\ ],
\ g:message_list
diff --git a/test/fix/test_ale_fix.vader b/test/fix/test_ale_fix.vader
index 1b1891ce..500eb71c 100644
--- a/test/fix/test_ale_fix.vader
+++ b/test/fix/test_ale_fix.vader
@@ -11,6 +11,7 @@ Before:
let g:ale_enabled = 0
let g:ale_echo_cursor = 0
let g:ale_run_synchronously = 1
+ unlet! g:ale_run_synchronously_callbacks
let g:ale_set_lists_synchronously = 1
let g:ale_fix_buffer_data = {}
let g:ale_fixers = {
@@ -59,6 +60,10 @@ Before:
return {'command': 'echo x > %t', 'read_temporary_file': 1}
endfunction
+ function CatWithTempFile(buffer, done, lines) abort
+ return {'command': 'cat %t <(echo d)'}
+ endfunction
+
function RemoveLastLine(buffer, done, lines) abort
return ['a', 'b']
endfunction
@@ -177,6 +182,7 @@ After:
Restore
unlet! g:ale_run_synchronously
unlet! g:ale_set_lists_synchronously
+ unlet! g:ale_run_synchronously_callbacks
unlet! g:ale_emulate_job_failure
unlet! b:ale_fixers
unlet! b:ale_fix_on_save
@@ -187,6 +193,7 @@ After:
delfunction CatLine
delfunction CatLineOneArg
delfunction ReplaceWithTempFile
+ delfunction CatWithTempFile
delfunction RemoveLastLine
delfunction RemoveLastLineOneArg
delfunction TestCallback
@@ -235,11 +242,13 @@ Given testft (A file with three lines):
Execute(ALEFix should complain when there are no functions to call):
ALEFix
+ call ale#test#FlushJobs()
AssertEqual 'No fixers have been defined. Try :ALEFixSuggest', GetLastMessage()
Execute(ALEFix should apply simple functions):
let g:ale_fixers.testft = ['AddCarets']
ALEFix
+ call ale#test#FlushJobs()
Expect(The first function should be used):
^a
@@ -249,6 +258,7 @@ Expect(The first function should be used):
Execute(ALEFix should apply simple functions in a chain):
let g:ale_fixers.testft = ['AddCarets', 'AddDollars']
ALEFix
+ call ale#test#FlushJobs()
Expect(Both functions should be used):
$^a
@@ -258,6 +268,7 @@ Expect(Both functions should be used):
Execute(ALEFix should allow 0 to be returned to skip functions):
let g:ale_fixers.testft = ['DoNothing', 'AddDollars']
ALEFix
+ call ale#test#FlushJobs()
Expect(Only the second function should be applied):
$a
@@ -268,6 +279,7 @@ Execute(The * fixers shouldn't be used if an empty list is set for fixers):
let g:ale_fixers.testft = []
let g:ale_fixers['*'] = ['AddDollars']
ALEFix
+ call ale#test#FlushJobs()
Expect(Nothing should be changed):
a
@@ -277,6 +289,7 @@ Expect(Nothing should be changed):
Execute(* fixers should be used if no filetype is matched):
let g:ale_fixers = {'*': ['AddDollars']}
ALEFix
+ call ale#test#FlushJobs()
Expect(The file should be changed):
$a
@@ -290,6 +303,7 @@ Execute(ALEFix should allow commands to be run):
else
let g:ale_fixers.testft = ['CatLine']
ALEFix
+ call ale#test#FlushJobs()
endif
Expect(An extra line should be added):
@@ -301,6 +315,7 @@ Expect(An extra line should be added):
Execute(ALEFix should use fixers passed in commandline when provided):
let g:ale_fixers.testft = ['RemoveLastLine']
ALEFix AddCarets AddDollars
+ call ale#test#FlushJobs()
Expect(Only fixers passed via command line should be run):
$^a
@@ -315,11 +330,28 @@ Execute(ALEFix should allow temporary files to be read):
else
let g:ale_fixers.testft = ['ReplaceWithTempFile']
ALEFix
+ call ale#test#FlushJobs()
endif
Expect(The line we wrote to the temporary file should be used here):
x
+Execute(ALEFix should not read the temporary file when the option is not set):
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['a', 'b', 'c', 'd'])
+ else
+ let g:ale_fixers.testft = ['CatWithTempFile']
+ ALEFix
+ call ale#test#FlushJobs()
+ endif
+
+Expect(An extra line should be added):
+ a
+ b
+ c
+ d
+
Execute(ALEFix should allow jobs and simple functions to be combined):
if has('win32')
" Just skip this test on Windows, we can't run it.
@@ -328,6 +360,7 @@ Execute(ALEFix should allow jobs and simple functions to be combined):
else
let g:ale_fixers.testft = ['ReplaceWithTempFile', 'AddDollars']
ALEFix
+ call ale#test#FlushJobs()
endif
Expect(The lines from the temporary file should be modified):
@@ -340,6 +373,7 @@ Execute(ALEFix should send lines modified by functions to jobs):
else
let g:ale_fixers.testft = ['AddDollars', 'CatLine']
ALEFix
+ call ale#test#FlushJobs()
endif
Expect(The lines should first be modified by the function, then the job):
@@ -352,6 +386,7 @@ Execute(ALEFix should skip commands when jobs fail to run):
let g:ale_emulate_job_failure = 1
let g:ale_fixers.testft = ['CatLine', 'AddDollars']
ALEFix
+ call ale#test#FlushJobs()
Expect(Only the second function should be applied):
$a
@@ -361,6 +396,7 @@ Expect(Only the second function should be applied):
Execute(ALEFix should handle strings for selecting a single function):
let g:ale_fixers.testft = 'AddCarets'
ALEFix
+ call ale#test#FlushJobs()
Expect(The first function should be used):
^a
@@ -371,6 +407,7 @@ Execute(ALEFix should use functions from the registry):
call ale#fix#registry#Add('add_carets', 'AddCarets', [], 'Add some carets')
let g:ale_fixers.testft = ['add_carets']
ALEFix
+ call ale#test#FlushJobs()
Expect(The registry function should be used):
^a
@@ -380,6 +417,7 @@ Expect(The registry function should be used):
Execute(ALEFix should be able to remove the last line for files):
let g:ale_fixers.testft = ['RemoveLastLine']
ALEFix
+ call ale#test#FlushJobs()
Expect(There should be only two lines):
a
@@ -388,6 +426,7 @@ Expect(There should be only two lines):
Execute(ALEFix should accept funcrefs):
let g:ale_fixers.testft = [function('RemoveLastLine')]
ALEFix
+ call ale#test#FlushJobs()
Expect(There should be only two lines):
a
@@ -401,6 +440,7 @@ Execute(ALEFix should accept lambdas):
else
let g:ale_fixers.testft = [{buffer, done, lines -> lines + ['d']}]
ALEFix
+ call ale#test#FlushJobs()
endif
Expect(There should be an extra line):
@@ -413,6 +453,7 @@ Execute(ALEFix should user buffer-local fixer settings):
let g:ale_fixers.testft = ['AddCarets', 'AddDollars']
let b:ale_fixers = {'testft': ['RemoveLastLine']}
ALEFix
+ call ale#test#FlushJobs()
Expect(There should be only two lines):
a
@@ -422,6 +463,7 @@ Execute(ALEFix should allow Lists to be used for buffer-local fixer settings):
let g:ale_fixers.testft = ['AddCarets', 'AddDollars']
let b:ale_fixers = ['RemoveLastLine']
ALEFix
+ call ale#test#FlushJobs()
Expect(There should be only two lines):
a
@@ -447,6 +489,7 @@ Execute(ALEFix should fix files on the save event):
call SetUpLinters()
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
" We should save the file.
AssertEqual ['$a', '$b', '$c'], readfile('fix_test_file')
@@ -518,6 +561,7 @@ Execute(ALEFix should still lint with no linters to be applied):
call SetUpLinters()
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
Assert !filereadable('fix_test_file'), 'The file should not have been saved'
@@ -552,6 +596,7 @@ Execute(ALEFix should still lint when nothing was fixed on save):
call SetUpLinters()
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
Assert !filereadable('fix_test_file'), 'The file should not have been saved'
@@ -597,6 +642,7 @@ Execute(ale#fix#InitBufferData() should set up the correct data):
Execute(ALEFix simple functions should be able to accept one argument, the buffer):
let g:ale_fixers.testft = ['RemoveLastLineOneArg']
ALEFix
+ call ale#test#FlushJobs()
Expect(There should be only two lines):
a
@@ -632,6 +678,7 @@ Execute(ALEFix functions returning jobs should be able to accept one argument):
else
let g:ale_fixers.testft = ['CatLine']
ALEFix
+ call ale#test#FlushJobs()
endif
Expect(An extra line should be added):
@@ -643,22 +690,26 @@ Expect(An extra line should be added):
Execute(ALE should print a message telling you something isn't a valid fixer when you type some nonsense):
let g:ale_fixers.testft = ['CatLine', 'invalidname']
ALEFix
+ call ale#test#FlushJobs()
AssertEqual 'There is no fixer named `invalidname`. Check :ALEFixSuggest', GetLastMessage()
Execute(ALE should complain about invalid fixers with minuses in the name):
let g:ale_fixers.testft = ['foo-bar']
ALEFix
+ call ale#test#FlushJobs()
AssertEqual 'There is no fixer named `foo-bar`. Check :ALEFixSuggest', GetLastMessage()
Execute(ALE should tolerate valid fixers with minuses in the name):
let g:ale_fixers.testft = ['prettier-standard']
ALEFix
+ call ale#test#FlushJobs()
Execute(Test fixing with chained callbacks):
let g:ale_fixers.testft = ['FirstChainCallback']
ALEFix
+ call ale#test#FlushJobs()
" The buffer shouldn't be piped in for earlier commands in the chain.
AssertEqual
@@ -677,6 +728,7 @@ Expect(The echoed line should be added):
Execute(Test fixing with chained callback where the first command is skipped):
let g:ale_fixers.testft = ['FirstChainCallbackSkipped']
ALEFix
+ call ale#test#FlushJobs()
Expect(The default line should be added):
a
@@ -687,6 +739,7 @@ Expect(The default line should be added):
Execute(Test fixing with chained callback where the second command is skipped):
let g:ale_fixers.testft = ['FirstChainCallbackSecondSkipped']
ALEFix
+ call ale#test#FlushJobs()
Expect(The default line should be added):
a
@@ -697,6 +750,7 @@ Expect(The default line should be added):
Execute(Test fixing with chained callback where the final callback is skipped):
let g:ale_fixers.testft = ['ChainWhereLastIsSkipped']
ALEFix
+ call ale#test#FlushJobs()
Expect(The lines should be the same):
a
@@ -706,6 +760,7 @@ Expect(The lines should be the same):
Execute(Empty output should be ignored):
let g:ale_fixers.testft = ['IgnoredEmptyOutput']
ALEFix
+ call ale#test#FlushJobs()
Expect(The lines should be the same):
a
@@ -715,6 +770,7 @@ Expect(The lines should be the same):
Execute(A temporary file shouldn't be piped into the command when disabled):
let g:ale_fixers.testft = ['EchoLineNoPipe']
ALEFix
+ call ale#test#FlushJobs()
AssertEqual
\ string(ale#job#PrepareCommand(bufnr(''), 'echo new line')),
@@ -731,6 +787,7 @@ Expect(The new line should be used):
Execute(Post-processing should work):
let g:ale_fixers.testft = ['FixWithJSONPostProcessing']
ALEFix
+ call ale#test#FlushJobs()
Expect(The lines in the JSON should be used):
x
@@ -740,5 +797,7 @@ Expect(The lines in the JSON should be used):
Execute(ALEFix should apply autocmds):
let g:ale_fixers.testft = ['AddCarets']
ALEFix
+ call ale#test#FlushJobs()
+
AssertEqual g:pre_success, 1
AssertEqual g:post_success, 1
diff --git a/test/fixers/test_black_fixer_callback.vader b/test/fixers/test_black_fixer_callback.vader
index 7843783a..25ad05db 100644
--- a/test/fixers/test_black_fixer_callback.vader
+++ b/test/fixers/test_black_fixer_callback.vader
@@ -24,11 +24,12 @@ After:
Execute(The black callback should return the correct default values):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
AssertEqual
- \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' -'},
+ \ {'command': ale#path#BufferCdString(bufnr('')) . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' -'},
\ ale#fixers#black#Fix(bufnr(''))
Execute(The black callback should include options):
let g:ale_python_black_options = '--some-option'
+ let g:ale_python_black_change_directory = 0
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
AssertEqual
@@ -37,8 +38,10 @@ Execute(The black callback should include options):
Execute(Pipenv is detected when python_black_auto_pipenv is set):
let g:ale_python_black_auto_pipenv = 1
+ let g:ale_python_black_change_directory = 0
+
call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
- AssertEqual
+ AssertEqual
\ {'command': ale#Escape('pipenv') . ' run black -'},
\ ale#fixers#black#Fix(bufnr(''))
diff --git a/test/handler/test_cypher_lint_handler.vader b/test/handler/test_cypher_lint_handler.vader
new file mode 100644
index 00000000..066adae4
--- /dev/null
+++ b/test/handler/test_cypher_lint_handler.vader
@@ -0,0 +1,21 @@
+Before:
+ runtime ale_linters/cypher/cypher_lint.vim
+
+After:
+ call ale#linter#Reset()
+
+Execute(The cypher-lint handler should handle errors for the current file correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 75,
+ \ 'type': 'E',
+ \ 'text': "Invalid input ',': expected an identifier, shortestPath, allShortestPaths or '('",
+ \ },
+ \ ],
+ \ ale_linters#cypher#cypher_lint#Handle(bufnr(''), [
+ \ "shakespeare.cql:1:75: Invalid input ',': expected an identifier, shortestPath, allShortestPaths or '('",
+ \ "CREATE (shakespeare:Author {firstname:'William', lastname:'Shakespeare'}),,",
+ \ " ^",
+ \ ])
diff --git a/test/handler/test_flake8_handler.vader b/test/handler/test_flake8_handler.vader
index fe42211a..1c9956fa 100644
--- a/test/handler/test_flake8_handler.vader
+++ b/test/handler/test_flake8_handler.vader
@@ -113,7 +113,7 @@ Execute(The flake8 handler should handle stack traces):
\ [
\ {
\ 'lnum': 1,
- \ 'text': 'An exception was thrown. See :ALEDetail',
+ \ 'text': 'ImportError: No module named parser (See :ALEDetail)',
\ 'detail': join([
\ 'Traceback (most recent call last):',
\ ' File "/usr/local/bin/flake8", line 7, in <module>',
diff --git a/test/handler/test_pylama_handler.vader b/test/handler/test_pylama_handler.vader
new file mode 100644
index 00000000..854765db
--- /dev/null
+++ b/test/handler/test_pylama_handler.vader
@@ -0,0 +1,212 @@
+Before:
+ Save g:ale_warn_about_trailing_whitespace
+
+ let g:ale_warn_about_trailing_whitespace = 1
+
+ runtime ale_linters/python/pylama.vim
+
+After:
+ Restore
+
+ call ale#linter#Reset()
+
+ silent file something_else.py
+
+Execute(The pylama handler should handle no messages):
+ AssertEqual [], ale_linters#python#pylama#Handle(bufnr(''), [])
+
+Execute(The pylama handler should handle basic warnings and syntax errors):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 8,
+ \ 'col': 1,
+ \ 'code': 'W0611',
+ \ 'type': 'W',
+ \ 'sub_type': '',
+ \ 'text': '''foo'' imported but unused [pyflakes]',
+ \ },
+ \ {
+ \ 'lnum': 8,
+ \ 'col': 0,
+ \ 'code': 'E0401',
+ \ 'type': 'E',
+ \ 'sub_type': '',
+ \ 'text': 'Unable to import ''foo'' [pylint]',
+ \ },
+ \ {
+ \ 'lnum': 10,
+ \ 'col': 1,
+ \ 'code': 'E302',
+ \ 'type': 'E',
+ \ 'sub_type': '',
+ \ 'text': 'expected 2 blank lines, found 1 [pycodestyle]',
+ \ },
+ \ {
+ \ 'lnum': 11,
+ \ 'col': 1,
+ \ 'code': 'D401',
+ \ 'type': 'W',
+ \ 'sub_type': 'style',
+ \ 'text': 'First line should be in imperative mood (''Get'', not ''Gets'') [pydocstyle]',
+ \ },
+ \ {
+ \ 'lnum': 15,
+ \ 'col': 81,
+ \ 'code': 'E501',
+ \ 'type': 'E',
+ \ 'sub_type': '',
+ \ 'text': 'line too long (96 > 80 characters) [pycodestyle]',
+ \ },
+ \ {
+ \ 'lnum': 16,
+ \ 'col': 1,
+ \ 'code': 'D203',
+ \ 'type': 'W',
+ \ 'sub_type': 'style',
+ \ 'text': '1 blank line required before class docstring (found 0) [pydocstyle]',
+ \ },
+ \ {
+ \ 'lnum': 18,
+ \ 'col': 1,
+ \ 'code': 'D107',
+ \ 'type': 'W',
+ \ 'sub_type': 'style',
+ \ 'text': 'Missing docstring in __init__ [pydocstyle]',
+ \ },
+ \ {
+ \ 'lnum': 20,
+ \ 'col': 0,
+ \ 'code': 'C4001',
+ \ 'type': 'W',
+ \ 'sub_type': 'style',
+ \ 'text': 'Invalid string quote ", should be '' [pylint]',
+ \ },
+ \ ],
+ \ ale_linters#python#pylama#Handle(bufnr(''), [
+ \ 'No config file found, using default configuration',
+ \ 'index.py:8:1: W0611 ''foo'' imported but unused [pyflakes]',
+ \ 'index.py:8:0: E0401 Unable to import ''foo'' [pylint]',
+ \ 'index.py:10:1: E302 expected 2 blank lines, found 1 [pycodestyle]',
+ \ 'index.py:11:1: D401 First line should be in imperative mood (''Get'', not ''Gets'') [pydocstyle]',
+ \ 'index.py:15:81: E501 line too long (96 > 80 characters) [pycodestyle]',
+ \ 'index.py:16:1: D203 1 blank line required before class docstring (found 0) [pydocstyle]',
+ \ 'index.py:18:1: D107 Missing docstring in __init__ [pydocstyle]',
+ \ 'index.py:20:0: C4001 Invalid string quote ", should be '' [pylint]',
+ \ ])
+
+Execute(The pylama handler should handle tracebacks with parsable messages):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'text': 'ParseError: Cannot parse file. (See :ALEDetail)',
+ \ 'detail': join([
+ \ 'Traceback (most recent call last):',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pylama/core.py", line 66, in run',
+ \ ' path, code=code, ignore=ignore, select=select, params=lparams)',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pylama/lint/pylama_pydocstyle.py", line 37, in run',
+ \ ' } for e in PyDocChecker().check_source(*check_source_args)]',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/checker.py", line 64, in check_source',
+ \ ' module = parse(StringIO(source), filename)',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 340, in __call__',
+ \ ' return self.parse(*args, **kwargs)',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 328, in parse',
+ \ ' six.raise_from(ParseError(), error)',
+ \ ' File "/usr/local/lib/python2.7/site-packages/six.py", line 737, in raise_from',
+ \ ' raise value',
+ \ 'ParseError: Cannot parse file.',
+ \ ], "\n"),
+ \ },
+ \ {
+ \ 'lnum': 11,
+ \ 'col': 1,
+ \ 'code': 'E302',
+ \ 'type': 'E',
+ \ 'sub_type': '',
+ \ 'text': 'expected 2 blank lines, found 1 [pycodestyle]',
+ \ },
+ \ {
+ \ 'lnum': 16,
+ \ 'col': 81,
+ \ 'code': 'E501',
+ \ 'type': 'E',
+ \ 'sub_type': '',
+ \ 'text': 'line too long (96 > 80 characters) [pycodestyle]',
+ \ },
+ \ ],
+ \ ale_linters#python#pylama#Handle(bufnr(''), [
+ \ 'Traceback (most recent call last):',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pylama/core.py", line 66, in run',
+ \ ' path, code=code, ignore=ignore, select=select, params=lparams)',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pylama/lint/pylama_pydocstyle.py", line 37, in run',
+ \ ' } for e in PyDocChecker().check_source(*check_source_args)]',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/checker.py", line 64, in check_source',
+ \ ' module = parse(StringIO(source), filename)',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 340, in __call__',
+ \ ' return self.parse(*args, **kwargs)',
+ \ ' File "/usr/local/lib/python2.7/site-packages/pydocstyle/parser.py", line 328, in parse',
+ \ ' six.raise_from(ParseError(), error)',
+ \ ' File "/usr/local/lib/python2.7/site-packages/six.py", line 737, in raise_from',
+ \ ' raise value',
+ \ 'ParseError: Cannot parse file.',
+ \ '',
+ \ 'index.py:11:1: E302 expected 2 blank lines, found 1 [pycodestyle]',
+ \ 'index.py:16:81: E501 line too long (96 > 80 characters) [pycodestyle]',
+ \ ])
+
+" Note: This is probably a bug, since all pylama plugins produce codes, but
+" should be handled for compatibility.
+" Note: The pylama isort plugin is distributed in the isort package.
+Execute(The pylama handler should handle messages without codes):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 0,
+ \ 'col': 0,
+ \ 'code': '',
+ \ 'type': 'W',
+ \ 'sub_type': '',
+ \ 'text': 'Incorrectly sorted imports. [isort]'
+ \ },
+ \ ],
+ \ ale_linters#python#pylama#Handle(bufnr(''), [
+ \ 'index.py:0:0: Incorrectly sorted imports. [isort]',
+ \ ])
+
+" Note: This is a pylama bug, but should be handled for compatibility.
+" See https://github.com/klen/pylama/pull/146
+Execute(The pylama handler should handle message codes followed by a colon):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 31,
+ \ 'col': 1,
+ \ 'code': 'E800',
+ \ 'type': 'E',
+ \ 'sub_type': '',
+ \ 'text': 'Found commented out code: # needs_sphinx = ''1.0'' [eradicate]',
+ \ },
+ \ ],
+ \ ale_linters#python#pylama#Handle(bufnr(''), [
+ \ 'index.py:31:1: E800: Found commented out code: # needs_sphinx = ''1.0'' [eradicate]',
+ \ ])
+
+" The directory created for %t may not comply with pylint module name config.
+" This should not be reported to users.
+Execute(The pylama handler should ignore C0103 from temp dir, not others):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 29,
+ \ 'col': 0,
+ \ 'code': 'C0103',
+ \ 'type': 'W',
+ \ 'sub_type': 'style',
+ \ 'text': 'Constant name "badname" doesn''t conform to UPPER_CASE naming style [pylint]',
+ \ },
+ \ ],
+ \ ale_linters#python#pylama#Handle(bufnr(''), [
+ \ '../../../../tmp/vmynR33/456/__init__.py:1:0: C0103 Module name "456" doesn''t conform to snake_case naming style [pylint]',
+ \ '../../../../tmp/vmynR33/456/__init__.py:29:0: C0103 Constant name "badname" doesn''t conform to UPPER_CASE naming style [pylint]',
+ \ ])
diff --git a/test/handler/test_vulture_handler.vader b/test/handler/test_vulture_handler.vader
index c6bd7643..b28055db 100644
--- a/test/handler/test_vulture_handler.vader
+++ b/test/handler/test_vulture_handler.vader
@@ -70,7 +70,7 @@ Execute(Vulture exception should be handled):
\ [
\ {
\ 'lnum': 1,
- \ 'text': 'An exception was thrown. See :ALEDetail',
+ \ 'text': 'BaddestException: Everything gone wrong (See :ALEDetail)',
\ 'detail': join([
\ 'Traceback (most recent call last):',
\ ' File "/usr/lib/python3.6/site-packages/vulture/__init__.py", line 13, in <module>',
diff --git a/test/lsp/test_reset_lsp.vader b/test/lsp/test_reset_lsp.vader
index 2bec13dc..4a1a155e 100644
--- a/test/lsp/test_reset_lsp.vader
+++ b/test/lsp/test_reset_lsp.vader
@@ -18,6 +18,9 @@ Before:
endfunction
call ale#engine#InitBufferInfo(bufnr(''))
+ " Call this function first, so we can be sure the module is loaded before we
+ " check if it exists.
+ call ale#lsp_linter#ClearLSPData()
call ale#linter#Define('testft', {
\ 'name': 'lsplinter',
@@ -68,7 +71,10 @@ Execute(ALEStopAllLSPs should clear the loclist):
\ 'linter_name': 'otherlinter',
\ },
\]
- let g:ale_buffer_info[bufnr('')].active_linter_list = ['lsplinter', 'otherlinter']
+ let g:ale_buffer_info[bufnr('')].active_linter_list = [
+ \ {'name': 'lsplinter'},
+ \ {'name': 'otherlinter'},
+ \]
ALEStopAllLSPs
@@ -87,4 +93,6 @@ Execute(ALEStopAllLSPs should clear the loclist):
\]
" The LSP linter should be removed from the active linter list.
- AssertEqual g:ale_buffer_info[bufnr('')].active_linter_list, ['otherlinter']
+ AssertEqual
+ \ ['otherlinter'],
+ \ map(copy(g:ale_buffer_info[bufnr('')].active_linter_list), 'v:val.name')
diff --git a/test/script/block-padding-checker b/test/script/block-padding-checker
index b13c9b92..2feab6d0 100755
--- a/test/script/block-padding-checker
+++ b/test/script/block-padding-checker
@@ -10,7 +10,8 @@ import re
INDENTATION_RE = re.compile(r'^ *')
COMMENT_LINE_RE = re.compile(r'^ *"')
-COMMAND_RE = re.compile(r'^ *([a-zA-Z]+)')
+COMMAND_RE = re.compile(r'^ *([a-zA-Z\\]+)')
+OPERATOR_END_RE = re.compile(r'(&&|\|\||\+|-|\*\| /)$')
START_BLOCKS = set(['if', 'for', 'while', 'try', 'function'])
END_BLOCKS = set(['endif', 'endfor', 'endwhile', 'endtry', 'endfunction'])
@@ -21,6 +22,7 @@ WHITESPACE_BEFORE_SET = START_BLOCKS | TERMINATORS
WHITESPACE_FORBIDDEN_BEFORE_SET = END_BLOCKS | MIDDLE_BLOCKS
WHITESPACE_AFTER_SET = END_BLOCKS
WHITESPACE_FORBIDDEN_AFTER_SET = START_BLOCKS | MIDDLE_BLOCKS
+SAME_INDENTATION_SET = set(['\\'])
def remove_comment_lines(line_iter):
@@ -44,7 +46,7 @@ def check_lines(line_iter):
):
yield (
line_number,
- 'Blank line forbidden after `%s`' % (command,)
+ 'Blank line forbidden after `%s`' % (previous_command,)
)
previous_line_blank = True
@@ -56,6 +58,26 @@ def check_lines(line_iter):
if command_match:
command = command_match.group(1)
+ if (
+ command in SAME_INDENTATION_SET
+ and previous_indentation_level is not None
+ and indentation_level != previous_indentation_level
+ ):
+ yield (
+ line_number,
+ 'Line continuation should match previous indentation'
+ )
+
+ if (
+ previous_indentation_level is not None
+ and indentation_level != previous_indentation_level
+ and abs(indentation_level - previous_indentation_level) != 4 # noqa
+ ):
+ yield (
+ line_number,
+ 'Indentation should be 4 spaces'
+ )
+
# Check for commands requiring blank lines before them, if they
# aren't at the start of a block.
if (
@@ -98,6 +120,12 @@ def check_lines(line_iter):
previous_line_blank = False
previous_indentation_level = indentation_level
+ if OPERATOR_END_RE.search(line):
+ yield (
+ line_number,
+ 'Put operators at the start of lines instead'
+ )
+
def main():
status = 0
diff --git a/test/sign/test_linting_sets_signs.vader b/test/sign/test_linting_sets_signs.vader
index 3ccecf45..c72b0882 100644
--- a/test/sign/test_linting_sets_signs.vader
+++ b/test/sign/test_linting_sets_signs.vader
@@ -63,5 +63,6 @@ After:
Execute(The signs should be updated after linting is done):
ALELint
+ call ale#test#FlushJobs()
AssertEqual [['1', 'ALEWarningSign'], ['2', 'ALEErrorSign']], CollectSigns()
diff --git a/test/sign/test_sign_placement.vader b/test/sign/test_sign_placement.vader
index e2d95ff0..41bed715 100644
--- a/test/sign/test_sign_placement.vader
+++ b/test/sign/test_sign_placement.vader
@@ -134,6 +134,7 @@ Given testft(A file with warnings/errors):
Execute(The current signs should be set for running a job):
ALELint
+ call ale#test#FlushJobs()
AssertEqual
\ [
diff --git a/test/smoke_test.vader b/test/smoke_test.vader
index c87f95b2..53e08a8d 100644
--- a/test/smoke_test.vader
+++ b/test/smoke_test.vader
@@ -66,7 +66,7 @@ Execute(Linters should run with the default options):
" where tests fail randomly.
for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
call ale#Queue(0, '')
- call ale#engine#WaitForJobs(2000)
+ call ale#test#WaitForJobs(2000)
let g:results = ale#test#GetLoclistWithoutModule()
@@ -110,7 +110,7 @@ Execute(Linters should run in PowerShell too):
\})
call ale#Queue(0, '')
- call ale#engine#WaitForJobs(4000)
+ call ale#test#WaitForJobs(4000)
AssertEqual [
\ {
@@ -140,7 +140,7 @@ Execute(Linters should run in PowerShell too):
Execute(Previous errors should be removed when linters change):
call ale#Queue(0, '')
- call ale#engine#WaitForJobs(2000)
+ call ale#test#WaitForJobs(2000)
call ale#linter#Reset()
@@ -167,7 +167,7 @@ Execute(Previous errors should be removed when linters change):
" where tests fail randomly.
for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
call ale#Queue(0, '')
- call ale#engine#WaitForJobs(2000)
+ call ale#test#WaitForJobs(2000)
let g:results = ale#test#GetLoclistWithoutModule()
diff --git a/test/test_ale_lint_command.vader b/test/test_ale_lint_command.vader
index bc2ebabe..ba7308dd 100644
--- a/test/test_ale_lint_command.vader
+++ b/test/test_ale_lint_command.vader
@@ -1,7 +1,9 @@
Before:
Save g:ale_buffer_info
+ Save g:ale_enabled
let g:ale_buffer_info = {}
+ let g:ale_enabled = 1
let g:expected_loclist = [{
\ 'bufnr': bufnr('%'),
@@ -58,7 +60,7 @@ Execute(ALELint should run the linters):
" Try to run the linter a few times, as it fails randomly in NeoVim.
for b:i in range(5)
ALELint
- call ale#engine#WaitForJobs(2000)
+ call ale#test#WaitForJobs(2000)
if !has('nvim')
" Sleep so the delayed list function can run.
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index db891009..d0bca329 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -10,6 +10,7 @@ Before:
let g:ale_set_signs = 1
let g:ale_set_lists_synchronously = 1
let g:ale_run_synchronously = 1
+ unlet! g:ale_run_synchronously_callbacks
let g:ale_pattern_options = {}
let g:ale_pattern_options_enabled = 1
let g:ale_set_balloons =
@@ -85,6 +86,7 @@ Before:
After:
Restore
+ unlet! g:ale_run_synchronously_callbacks
unlet! g:expected_loclist
unlet! g:expected_groups
unlet! b:ale_enabled
@@ -113,6 +115,7 @@ Execute(ALEToggle should reset everything and then run again):
AssertEqual 'foobar', &filetype
ALELint
+ call ale#test#FlushJobs()
" First check that everything is there...
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
@@ -135,6 +138,7 @@ Execute(ALEToggle should reset everything and then run again):
" Toggle ALE on, everything should be set up and run again.
ALEToggle
+ call ale#test#FlushJobs()
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
@@ -157,6 +161,7 @@ Execute(ALEToggle should skip filename keys and preserve them):
\}
ALELint
+ call ale#test#FlushJobs()
" Now Toggle ALE off.
ALEToggle
@@ -174,6 +179,7 @@ Execute(ALEToggle should skip filename keys and preserve them):
" Toggle ALE on again.
ALEToggle
+ call ale#test#FlushJobs()
AssertEqual
\ {
@@ -188,15 +194,18 @@ Execute(ALEToggle should skip filename keys and preserve them):
Execute(ALEDisable should reset everything and stay disabled):
ALELint
+ call ale#test#FlushJobs()
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
ALEDisable
+ call ale#test#FlushJobs()
AssertEqual [], ale#test#GetLoclistWithoutModule()
AssertEqual 0, g:ale_enabled
ALEDisable
+ call ale#test#FlushJobs()
AssertEqual [], ale#test#GetLoclistWithoutModule()
AssertEqual 0, g:ale_enabled
@@ -205,6 +214,7 @@ Execute(ALEEnable should enable ALE and lint again):
let g:ale_enabled = 0
ALEEnable
+ call ale#test#FlushJobs()
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
AssertEqual 1, g:ale_enabled
@@ -213,6 +223,7 @@ Execute(ALEReset should reset everything for a buffer):
AssertEqual 'foobar', &filetype
ALELint
+ call ale#test#FlushJobs()
" First check that everything is there...
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
@@ -224,6 +235,7 @@ Execute(ALEReset should reset everything for a buffer):
" Now Toggle ALE off.
ALEReset
+ call ale#test#FlushJobs()
" Everything should be cleared.
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
@@ -237,6 +249,7 @@ Execute(ALEToggleBuffer should reset everything and then run again):
AssertEqual 'foobar', &filetype
ALELint
+ call ale#test#FlushJobs()
" First check that everything is there...
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
@@ -257,6 +270,7 @@ Execute(ALEToggleBuffer should reset everything and then run again):
" Toggle ALE on, everything should be set up and run again.
ALEToggleBuffer
+ call ale#test#FlushJobs()
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
AssertEqual [0, [[2, 1000001, 'ALEErrorSign']]], ale#sign#FindCurrentSigns(bufnr('%'))
@@ -268,10 +282,12 @@ Execute(ALEToggleBuffer should reset everything and then run again):
Execute(ALEDisableBuffer should reset everything and stay disabled):
ALELint
+ call ale#test#FlushJobs()
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
ALEDisableBuffer
+ call ale#test#FlushJobs()
AssertEqual [], ale#test#GetLoclistWithoutModule()
AssertEqual 0, b:ale_enabled
@@ -280,6 +296,7 @@ Execute(ALEEnableBuffer should enable ALE and lint again):
let b:ale_enabled = 0
ALEEnableBuffer
+ call ale#test#FlushJobs()
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
AssertEqual 1, b:ale_enabled
@@ -303,6 +320,7 @@ Execute(ALEResetBuffer should reset everything for a buffer):
AssertEqual 'foobar', &filetype
ALELint
+ call ale#test#FlushJobs()
" First check that everything is there...
AssertEqual g:expected_loclist, ale#test#GetLoclistWithoutModule()
@@ -314,6 +332,7 @@ Execute(ALEResetBuffer should reset everything for a buffer):
" Now Toggle ALE off.
ALEResetBuffer
+ call ale#test#FlushJobs()
" Everything should be cleared.
Assert !has_key(g:ale_buffer_info, bufnr('')), 'The g:ale_buffer_info Dictionary was not removed'
diff --git a/test/test_command_chain.vader b/test/test_command_chain.vader
index 591f6f40..329ebc97 100644
--- a/test/test_command_chain.vader
+++ b/test/test_command_chain.vader
@@ -1,6 +1,7 @@
Before:
Save &shell, g:ale_run_synchronously
let g:ale_run_synchronously = 1
+ unlet! g:ale_run_synchronously_callbacks
if !has('win32')
set shell=/bin/sh
@@ -47,6 +48,7 @@ Before:
After:
Restore
+ unlet! g:ale_run_synchronously_callbacks
unlet! g:first_echo_called
unlet! g:second_echo_called
unlet! g:final_callback_called
@@ -63,6 +65,7 @@ Given foobar (Some imaginary filetype):
Execute(Check the results of running the chain):
AssertEqual 'foobar', &filetype
call ale#Queue(0)
+ call ale#test#FlushJobs()
Assert g:first_echo_called, 'The first chain item was not called'
Assert g:second_echo_called, 'The second chain item was not called'
diff --git a/test/test_errors_removed_after_filetype_changed.vader b/test/test_errors_removed_after_filetype_changed.vader
index 651a74f2..a47dbcd1 100644
--- a/test/test_errors_removed_after_filetype_changed.vader
+++ b/test/test_errors_removed_after_filetype_changed.vader
@@ -3,7 +3,6 @@ Before:
Save g:ale_buffer_info
Save g:ale_echo_cursor
Save g:ale_run_synchronously
- Save g:ale_run_synchronously
Save g:ale_set_highlights
Save g:ale_set_loclist
Save g:ale_set_quickfix
@@ -17,6 +16,7 @@ Before:
let g:ale_echo_cursor = 0
let g:ale_run_synchronously = 1
+ unlet! g:ale_run_synchronously_callbacks
call setloclist(0, [])
noautocmd let &filetype = 'foobar'
@@ -44,6 +44,8 @@ Before:
After:
Restore
+
+ unlet! g:ale_run_synchronously_callbacks
delfunction TestCallback
call ale#linter#Reset()
@@ -51,6 +53,7 @@ After:
Execute(Error should be removed when the filetype changes to something else we cannot check):
call ale#Queue(0)
+ call ale#test#FlushJobs()
sleep 1ms
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
@@ -58,6 +61,7 @@ Execute(Error should be removed when the filetype changes to something else we c
noautocmd let &filetype = 'foobar2'
call ale#Queue(0)
+ call ale#test#FlushJobs()
sleep 1ms
" We should get some items from the second filetype.
@@ -66,6 +70,7 @@ Execute(Error should be removed when the filetype changes to something else we c
noautocmd let &filetype = 'xxx'
call ale#Queue(0)
+ call ale#test#FlushJobs()
sleep 1ms
AssertEqual 0, len(ale#test#GetLoclistWithoutModule())
diff --git a/test/test_format_temporary_file_creation.vader b/test/test_format_temporary_file_creation.vader
index 385af908..10409400 100644
--- a/test/test_format_temporary_file_creation.vader
+++ b/test/test_format_temporary_file_creation.vader
@@ -13,6 +13,7 @@ Before:
let g:ale_echo_cursor = 0
let g:ale_enabled = 1
let g:ale_run_synchronously = 1
+ unlet! g:ale_run_synchronously_callbacks
let g:ale_set_highlights = 0
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 0
@@ -41,6 +42,7 @@ Before:
After:
Restore
+ unlet! g:ale_run_synchronously_callbacks
unlet! g:output
delfunction TestCallback
@@ -56,5 +58,6 @@ Execute(ALE should be able to read the %t file):
AssertEqual 'foobar', &filetype
ALELint
+ call ale#test#FlushJobs()
AssertEqual ['foo', 'bar', 'baz'], g:output
diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader
index 53dcea06..619a964e 100644
--- a/test/test_highlight_placement.vader
+++ b/test/test_highlight_placement.vader
@@ -9,6 +9,7 @@ Before:
Save g:ale_set_signs
let g:ale_run_synchronously = 1
+ unlet! g:ale_run_synchronously_callbacks
let g:ale_set_highlights = 1
let g:ale_set_signs = 1
let g:ale_buffer_info = {}
@@ -64,6 +65,7 @@ Before:
After:
Restore
+ unlet! g:ale_run_synchronously_callbacks
unlet! g:items
unlet! b:ale_enabled
@@ -81,6 +83,7 @@ Given testft(A Javscript file with warnings/errors):
Execute(Highlights should be set when a linter runs):
ALELint
+ call ale#test#FlushJobs()
AssertEqual
\ [
diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader
index d7a307b5..18b64db5 100644
--- a/test/test_history_saving.vader
+++ b/test/test_history_saving.vader
@@ -2,6 +2,10 @@ Before:
Save g:ale_max_buffer_history_size
Save g:ale_history_log_output
Save g:ale_run_synchronously
+ Save g:ale_enabled
+
+ let g:ale_enabled = 1
+ let g:ale_run_synchronously = 1
unlet! b:ale_fixers
unlet! b:ale_enabled
@@ -68,27 +72,19 @@ Given foobar (Some imaginary filetype):
Execute(History should be set when commands are run):
AssertEqual 'foobar', &filetype
- let g:expected_results = ['command', 'exit_code', 'job_id', 'status']
-
- " Retry this test until it works. This one can randomly fail.
- for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
- let b:ale_history = []
- call ale#Queue(0)
- call ale#engine#WaitForJobs(2000)
+ let b:ale_history = []
+ ALELint
+ call ale#test#FlushJobs()
- let g:history = filter(
- \ copy(ale#history#Get(bufnr(''))),
- \ 'v:val.job_id isnot# ''executable''',
- \)
+ let g:history = filter(
+ \ copy(ale#history#Get(bufnr(''))),
+ \ 'v:val.job_id isnot# ''executable''',
+ \)
- AssertEqual 1, len(g:history)
-
- if sort(keys(g:history[0])) == g:expected_results
- break
- endif
- endfor
-
- AssertEqual g:expected_results, sort(keys(g:history[0]))
+ AssertEqual 1, len(g:history)
+ AssertEqual
+ \ ['command', 'exit_code', 'job_id', 'status'],
+ \ sort(keys(g:history[0]))
if has('win32')
AssertEqual 'cmd /s/c "echo command history test"', g:history[0].command
@@ -106,8 +102,8 @@ Execute(History should be not set when disabled):
let g:ale_history_enabled = 0
- call ale#Queue(0)
- call ale#engine#WaitForJobs(2000)
+ ALELint
+ call ale#test#FlushJobs()
AssertEqual [], ale#history#Get(bufnr(''))
@@ -115,24 +111,21 @@ Execute(History should include command output if logging is enabled):
AssertEqual 'foobar', &filetype
let g:ale_history_log_output = 1
- let g:expected_results = ['command history test']
" Retry this test until it works. This one can randomly fail.
- for g:i in range(has('nvim-0.3') || has('win32') ? 5 : 1)
- let b:ale_history = []
- call ale#Queue(0)
- call ale#engine#WaitForJobs(2000)
+ let b:ale_history = []
+ ALELint
+ call ale#test#FlushJobs()
- let g:history = ale#history#Get(bufnr(''))
+ let g:history = ale#history#Get(bufnr(''))
- AssertEqual 1, len(g:history)
-
- if get(g:history[0], 'output', []) == g:expected_results
- break
- endif
- endfor
-
- AssertEqual g:expected_results, get(g:history[0], 'output', [])
+ AssertEqual 1, len(g:history)
+ AssertEqual
+ \ ['command history test'],
+ \ map(
+ \ copy(get(g:history[0], 'output', [])),
+ \ 'substitute(v:val, ''[\r ]*$'', '''', ''g'')'
+ \ )
Execute(History items should be popped after going over the max):
let b:ale_history = map(range(20), '{''status'': ''started'', ''job_id'': v:val, ''command'': ''foobar''}')
@@ -169,10 +162,13 @@ Execute(The history should be updated when fixers are run):
let b:ale_fixers = {'foobar': ['TestFixer']}
let b:ale_enabled = 0
- let g:ale_run_synchronously = 1
ALEFix
+ AssertEqual ['started'], map(copy(b:ale_history), 'v:val.status')
+
+ call ale#test#FlushJobs()
+
AssertEqual ['finished'], map(copy(b:ale_history), 'v:val.status')
if has('win32')
diff --git a/test/test_lint_file_linters.vader b/test/test_lint_file_linters.vader
index f67fad44..d16f4aa1 100644
--- a/test/test_lint_file_linters.vader
+++ b/test/test_lint_file_linters.vader
@@ -8,6 +8,7 @@ Before:
let g:ale_buffer_info = {}
let g:ale_run_synchronously = 1
+ unlet! g:ale_run_synchronously_callbacks
let g:ale_set_lists_synchronously = 1
let b:ale_save_event_fired = 0
@@ -89,6 +90,7 @@ After:
Restore
+ unlet! g:ale_run_synchronously_callbacks
unlet! b:ale_save_event_fired
unlet! b:ale_enabled
unlet g:buffer_result
@@ -111,6 +113,7 @@ Given foobar (Some imaginary filetype):
Execute(Running linters without 'lint_file' should run only buffer linters):
call ale#Queue(0)
+ call ale#test#FlushJobs()
AssertEqual [
\ {
@@ -131,6 +134,7 @@ Execute(Running linters with 'lint_file' should run all linters):
Assert filereadable(expand('%:p')), 'The file was not readable'
call ale#Queue(0, 'lint_file')
+ call ale#test#FlushJobs()
AssertEqual [
\ {
@@ -163,6 +167,7 @@ Execute(Linter errors from files should be kept):
Assert filereadable(expand('%:p')), 'The file was not readable'
call ale#Queue(0, 'lint_file')
+ call ale#test#FlushJobs()
" Change the results for the buffer callback.
let g:buffer_result = [
@@ -175,6 +180,7 @@ Execute(Linter errors from files should be kept):
\]
call ale#Queue(0)
+ call ale#test#FlushJobs()
AssertEqual [
\ {
@@ -202,6 +208,7 @@ Execute(Linter errors from files should be kept when no other linters are run):
Assert filereadable(expand('%:p')), 'The file was not readable'
call ale#Queue(0, 'lint_file')
+ call ale#test#FlushJobs()
AssertEqual [
\ {
@@ -240,11 +247,13 @@ Execute(The Save event should respect the buffer number):
Assert filereadable(expand('%:p')), 'The file was not readable'
call ale#events#SaveEvent(bufnr('') + 1)
+ call ale#test#FlushJobs()
" We shouldn't get any prblems yet.
AssertEqual [], GetSimplerLoclist()
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
" We should get them now we used the right buffer number.
AssertEqual [
@@ -268,6 +277,7 @@ Execute(The Save event should set b:ale_save_event_fired to 1):
call ale#linter#Reset()
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
" This flag needs to be set so windows can be opened, etc.
AssertEqual 1, b:ale_save_event_fired
@@ -276,6 +286,7 @@ Execute(b:ale_save_event_fired should be set to 0 when results are set):
let b:ale_save_event_fired = 1
call ale#engine#SetResults(bufnr(''), [])
+ call ale#test#FlushJobs()
AssertEqual 0, b:ale_save_event_fired
@@ -289,15 +300,18 @@ Execute(lint_file linters should stay running after checking without them):
" The lint_file linter should still be running.
AssertEqual
\ ['lint_file_linter', 'buffer_linter'],
- \ g:ale_buffer_info[bufnr('')].active_linter_list
+ \ map(copy(g:ale_buffer_info[bufnr('')].active_linter_list), 'v:val.name')
" We should have 1 job for each linter.
- AssertEqual 2, len(g:ale_buffer_info[bufnr('')].job_list)
+ AssertEqual
+ \ 2,
+ \ len(keys(get(get(ale#command#GetData(), bufnr(''), {}), 'jobs', {})))
- call ale#engine#WaitForJobs(2000)
+ call ale#test#WaitForJobs(2000)
Execute(The save event should not lint the buffer when ALE is disabled):
let g:ale_enabled = 0
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual [], GetSimplerLoclist()
AssertEqual 0, b:ale_save_event_fired
diff --git a/test/test_lint_on_enter_when_file_changed.vader b/test/test_lint_on_enter_when_file_changed.vader
index 67f43c17..88493005 100644
--- a/test/test_lint_on_enter_when_file_changed.vader
+++ b/test/test_lint_on_enter_when_file_changed.vader
@@ -50,6 +50,7 @@ Execute(The file changed event function should set b:ale_file_changed):
Execute(The file changed event function should lint the current buffer when it has changed):
set filetype=foobar
call ale#events#FileChangedEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual [{
\ 'bufnr': bufnr(''),
@@ -68,6 +69,7 @@ Execute(The buffer should be checked after entering it after the file has change
set filetype=foobar
call ale#events#ReadOrEnterEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual [{
\ 'bufnr': bufnr(''),
diff --git a/test/test_linting_blacklist.vader b/test/test_linting_blacklist.vader
index 73190b7f..2bcc9576 100644
--- a/test/test_linting_blacklist.vader
+++ b/test/test_linting_blacklist.vader
@@ -11,6 +11,6 @@ Given unite (A Unite.vim file):
Execute(Running ALE on a blacklisted file shouldn't change anything):
call ale#Queue(0)
- call ale#engine#WaitForJobs(2000)
+ call ale#test#WaitForJobs(2000)
AssertEqual {}, g:ale_buffer_info
diff --git a/test/test_linting_updates_loclist.vader b/test/test_linting_updates_loclist.vader
index 921cdb08..8a162703 100644
--- a/test/test_linting_updates_loclist.vader
+++ b/test/test_linting_updates_loclist.vader
@@ -64,6 +64,7 @@ Given foobar (Some JavaScript with problems):
Execute(The loclist should be updated after linting is done):
ALELint
+ call ale#test#FlushJobs()
AssertEqual
\ [
diff --git a/test/test_loclist_jumping.vader b/test/test_loclist_jumping.vader
index da9a1f57..3b6f0688 100644
--- a/test/test_loclist_jumping.vader
+++ b/test/test_loclist_jumping.vader
@@ -5,23 +5,24 @@ Before:
\ {'type': 'E', 'bufnr': bufnr('') - 1, 'lnum': 3, 'col': 2},
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 2},
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 1, 'col': 3},
- \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 1},
+ \ {'type': 'W', 'sub_type': 'style', 'bufnr': bufnr(''), 'lnum': 2, 'col': 1},
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 2},
- \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 3},
- \ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 6},
+ \ {'type': 'W', 'sub_type': 'style', 'bufnr': bufnr(''), 'lnum': 2, 'col': 3},
+ \ {'type': 'W', 'bufnr': bufnr(''), 'lnum': 2, 'col': 6},
\ {'type': 'E', 'bufnr': bufnr(''), 'lnum': 2, 'col': 700},
\ {'type': 'E', 'bufnr': bufnr('') + 1, 'lnum': 3, 'col': 2},
\ ],
\ },
\}
- function! TestJump(position, wrap, pos)
+ function! TestJump(position, wrap, filter, subtype_filter, pos)
call cursor(a:pos)
if type(a:position) == type(0)
call ale#loclist_jumping#JumpToIndex(a:position)
else
- call ale#loclist_jumping#Jump(a:position, a:wrap)
+ call ale#loclist_jumping#Jump(a:position, a:wrap, a:filter,
+ \ a:subtype_filter)
endif
return getcurpos()[1:2]
@@ -36,46 +37,61 @@ Given foobar (Some imaginary filetype):
12345678
Execute(loclist jumping should jump correctly when not wrapping):
- AssertEqual [2, 1], TestJump('before', 0, [2, 2])
- AssertEqual [1, 3], TestJump('before', 0, [2, 1])
- AssertEqual [2, 3], TestJump('after', 0, [2, 2])
- AssertEqual [2, 1], TestJump('after', 0, [1, 3])
- AssertEqual [2, 6], TestJump('after', 0, [2, 4])
- AssertEqual [2, 8], TestJump('after', 0, [2, 6])
+ AssertEqual [2, 1], TestJump('before', 0, 'any', 'any', [2, 2])
+ AssertEqual [1, 3], TestJump('before', 0, 'any', 'any', [2, 1])
+ AssertEqual [2, 3], TestJump('after', 0, 'any', 'any', [2, 2])
+ AssertEqual [2, 1], TestJump('after', 0, 'any', 'any', [1, 3])
+ AssertEqual [2, 6], TestJump('after', 0, 'any', 'any', [2, 4])
+ AssertEqual [2, 8], TestJump('after', 0, 'any', 'any', [2, 6])
Execute(loclist jumping should jump correctly when wrapping):
- AssertEqual [2, 1], TestJump('before', 1, [2, 2])
- AssertEqual [1, 3], TestJump('before', 1, [2, 1])
- AssertEqual [2, 3], TestJump('after', 1, [2, 2])
- AssertEqual [2, 1], TestJump('after', 1, [1, 3])
- AssertEqual [2, 6], TestJump('after', 1, [2, 4])
-
- AssertEqual [1, 2], TestJump('after', 1, [2, 8])
- AssertEqual [2, 8], TestJump('before', 1, [1, 2])
+ AssertEqual [2, 1], TestJump('before', 1, 'any', 'any', [2, 2])
+ AssertEqual [1, 3], TestJump('before', 1, 'any', 'any', [2, 1])
+ AssertEqual [2, 3], TestJump('after', 1, 'any', 'any', [2, 2])
+ AssertEqual [2, 1], TestJump('after', 1, 'any', 'any', [1, 3])
+ AssertEqual [2, 6], TestJump('after', 1, 'any', 'any', [2, 4])
+
+ AssertEqual [1, 2], TestJump('after', 1, 'any', 'any', [2, 8])
+ AssertEqual [2, 8], TestJump('before', 1, 'any', 'any', [1, 2])
+
+Execute(loclist jumping should jump correctly with warning filters):
+ AssertEqual [2, 1], TestJump('after', 0, 'W', 'any', [1, 2])
+ AssertEqual [2, 6], TestJump('after', 0, 'W', 'any', [2, 3])
+ AssertEqual [2, 1], TestJump('after', 1, 'W', 'any', [2, 6])
+
+Execute(loclist jumping should jump correctly with error filters):
+ AssertEqual [1, 2], TestJump('after', 1, 'E', 'any', [2, 700])
+ AssertEqual [2, 2], TestJump('before', 0, 'E', 'any', [2, 700])
+ AssertEqual [2, 2], TestJump('after', 1, 'E', 'any', [1, 3])
+
+Execute(loclist jumping should jump correctly with sub type filters):
+ AssertEqual [2, 3], TestJump('after', 0, 'any', 'style', [2, 1])
+ AssertEqual [2, 2], TestJump('after', 0, 'any', '', [1, 3])
+ AssertEqual [2, 1], TestJump('after', 1, 'any', 'style', [2, 6])
Execute(loclist jumping not jump when the loclist is empty):
let g:ale_buffer_info[bufnr('%')].loclist = []
- AssertEqual [1, 6], TestJump('before', 0, [1, 6])
- AssertEqual [1, 6], TestJump('before', 1, [1, 6])
- AssertEqual [1, 6], TestJump('after', 0, [1, 6])
- AssertEqual [1, 6], TestJump('after', 1, [1, 6])
+ AssertEqual [1, 6], TestJump('before', 0, 'any', 'any', [1, 6])
+ AssertEqual [1, 6], TestJump('before', 1, 'any', 'any', [1, 6])
+ AssertEqual [1, 6], TestJump('after', 0, 'any', 'any', [1, 6])
+ AssertEqual [1, 6], TestJump('after', 1, 'any', 'any', [1, 6])
Execute(We should be able to jump to the last item):
- AssertEqual [2, 8], TestJump(-1, 0, [1, 6])
+ AssertEqual [2, 8], TestJump(-1, 0, 'any', 'any', [1, 6])
Execute(We shouldn't move when jumping to the last item where there are none):
let g:ale_buffer_info[bufnr('%')].loclist = []
- AssertEqual [1, 6], TestJump(-1, 0, [1, 6])
+ AssertEqual [1, 6], TestJump(-1, 0, 'any', 'any', [1, 6])
Execute(We should be able to jump to the first item):
- AssertEqual [1, 2], TestJump(0, 0, [1, 6])
+ AssertEqual [1, 2], TestJump(0, 0, 'any', 'any', [1, 6])
Execute(We shouldn't move when jumping to the first item where there are none):
let g:ale_buffer_info[bufnr('%')].loclist = []
- AssertEqual [1, 6], TestJump(0, 0, [1, 6])
+ AssertEqual [1, 6], TestJump(0, 0, 'any', 'any', [1, 6])
Execute(We should be able to jump when the error line is blank):
" Add a blank line at the end.
@@ -84,7 +100,7 @@ Execute(We should be able to jump when the error line is blank):
call add(g:ale_buffer_info[bufnr('%')].loclist, {'type': 'E', 'bufnr': bufnr(''), 'lnum': 3, 'col': 1})
AssertEqual 0, len(getline(3))
- AssertEqual [2, 8], TestJump('before', 0, [3, 1])
- AssertEqual [2, 8], TestJump('before', 1, [3, 1])
- AssertEqual [3, 1], TestJump('after', 0, [3, 1])
- AssertEqual [1, 2], TestJump('after', 1, [3, 1])
+ AssertEqual [2, 8], TestJump('before', 0, 'any', 'any', [3, 1])
+ AssertEqual [2, 8], TestJump('before', 1, 'any', 'any', [3, 1])
+ AssertEqual [3, 1], TestJump('after', 0, 'any', 'any', [3, 1])
+ AssertEqual [1, 2], TestJump('after', 1, 'any', 'any', [3, 1])
diff --git a/test/test_no_linting_on_write_quit.vader b/test/test_no_linting_on_write_quit.vader
index 75de06a4..7ad08d08 100644
--- a/test/test_no_linting_on_write_quit.vader
+++ b/test/test_no_linting_on_write_quit.vader
@@ -58,6 +58,7 @@ Execute(No linting should be done on :wq or :x):
" First try just the SaveEvent, to be sure that we set errors in the test.
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
@@ -65,6 +66,7 @@ Execute(No linting should be done on :wq or :x):
call setloclist(0, [])
call ale#events#QuitEvent(bufnr(''))
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual [], ale#test#GetLoclistWithoutModule()
@@ -73,11 +75,13 @@ Execute(No linting should be for :w after :q fails):
let g:ale_fix_on_save = 0
call ale#events#QuitEvent(bufnr(''))
+ call ale#test#FlushJobs()
" Simulate 2 seconds passing.
let b:ale_quitting -= 1000
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
@@ -86,6 +90,7 @@ Execute(No linting should be done on :wq or :x after fixing files):
let g:ale_fix_on_save = 1
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
@@ -93,6 +98,7 @@ Execute(No linting should be done on :wq or :x after fixing files):
call setloclist(0, [])
call ale#events#QuitEvent(bufnr(''))
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual [], ale#test#GetLoclistWithoutModule()
@@ -101,10 +107,12 @@ Execute(Linting should be done after :q fails and fixing files):
let g:ale_fix_on_save = 1
call ale#events#QuitEvent(bufnr(''))
+ call ale#test#FlushJobs()
" Simulate 2 seconds passing.
let b:ale_quitting -= 1000
call ale#events#SaveEvent(bufnr(''))
+ call ale#test#FlushJobs()
AssertEqual 1, len(ale#test#GetLoclistWithoutModule())
diff --git a/test/test_parse_command_args.vader b/test/test_parse_command_args.vader
new file mode 100644
index 00000000..0103b967
--- /dev/null
+++ b/test/test_parse_command_args.vader
@@ -0,0 +1,52 @@
+After:
+ unlet! b:parse_result
+
+ if exists(':ParseTest')
+ 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 -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
diff --git a/test/test_python_traceback.vader b/test/test_python_traceback.vader
new file mode 100644
index 00000000..6a659986
--- /dev/null
+++ b/test/test_python_traceback.vader
@@ -0,0 +1,79 @@
+Execute(ale#python#HandleTraceback returns empty List for empty lines):
+ AssertEqual
+ \ [],
+ \ ale#python#HandleTraceback([], 10)
+
+Execute(ale#python#HandleTraceback returns traceback, when present):
+ AssertEqual
+ \ [{
+ \ 'lnum': 1,
+ \ 'text': 'Exception: Example error (See :ALEDetail)',
+ \ 'detail': join([
+ \ 'Traceback (most recent call last):',
+ \ ' File "./example.py", line 5, in <module>',
+ \ ' raise Exception(''Example message'')',
+ \ 'Exception: Example error',
+ \ ], "\n"),
+ \ }],
+ \ ale#python#HandleTraceback([
+ \ 'Traceback (most recent call last):',
+ \ ' File "./example.py", line 5, in <module>',
+ \ ' raise Exception(''Example message'')',
+ \ 'Exception: Example error',
+ \ ], 1)
+
+" SyntaxError has extra output lines about the source
+Execute(ale#python#HandleTraceback returns SyntaxError traceback):
+ AssertEqual
+ \ [{
+ \ 'lnum': 1,
+ \ 'text': 'SyntaxError: invalid syntax (See :ALEDetail)',
+ \ 'detail': join([
+ \ 'Traceback (most recent call last):',
+ \ ' File "<string>", line 1, in <module>',
+ \ ' File "example.py", line 5',
+ \ ' +',
+ \ ' ^',
+ \ 'SyntaxError: invalid syntax',
+ \ ], "\n"),
+ \ }],
+ \ ale#python#HandleTraceback([
+ \ 'Traceback (most recent call last):',
+ \ ' File "<string>", line 1, in <module>',
+ \ ' File "example.py", line 5',
+ \ ' +',
+ \ ' ^',
+ \ 'SyntaxError: invalid syntax',
+ \ ], 1)
+
+Execute(ale#python#HandleTraceback ignores traceback after line limit):
+ AssertEqual
+ \ [],
+ \ ale#python#HandleTraceback([
+ \ '',
+ \ 'Traceback (most recent call last):',
+ \ ' File "./example.py", line 5, in <module>',
+ \ ' raise Exception(''Example message'')',
+ \ 'Exception: Example error',
+ \ ], 1)
+
+Execute(ale#python#HandleTraceback doesn't include later lines in detail):
+ AssertEqual
+ \ [{
+ \ 'lnum': 1,
+ \ 'text': 'Exception: Example error (See :ALEDetail)',
+ \ 'detail': join([
+ \ 'Traceback (most recent call last):',
+ \ ' File "./example.py", line 5, in <module>',
+ \ ' raise Exception(''Example message'')',
+ \ 'Exception: Example error',
+ \ ], "\n"),
+ \ }],
+ \ ale#python#HandleTraceback([
+ \ 'Traceback (most recent call last):',
+ \ ' File "./example.py", line 5, in <module>',
+ \ ' raise Exception(''Example message'')',
+ \ 'Exception: Example error',
+ \ 'file:1:2: Style issue',
+ \ 'file:3:4: Non-style issue',
+ \ ], 1)
diff --git a/test/test_symbol_search.vader b/test/test_symbol_search.vader
index d8b7a4a6..9d50e267 100644
--- a/test/test_symbol_search.vader
+++ b/test/test_symbol_search.vader
@@ -7,6 +7,7 @@ Before:
let g:message_list = []
let g:preview_called = 0
let g:item_list = []
+ let g:options = {}
let g:capability_checked = ''
let g:conn_id = v:null
let g:WaitCallback = v:null
@@ -47,9 +48,10 @@ Before:
call add(g:expr_list, a:expr)
endfunction
- function! ale#preview#ShowSelection(item_list) abort
+ function! ale#preview#ShowSelection(item_list, options) abort
let g:preview_called = 1
let g:item_list = a:item_list
+ let g:options = a:options
endfunction
After:
@@ -63,6 +65,7 @@ After:
unlet! g:message_list
unlet! g:expr_list
unlet! b:ale_linters
+ unlet! g:options
unlet! g:item_list
unlet! g:preview_called
@@ -170,4 +173,15 @@ Execute(LSP symbol requests should be sent):
\ ],
\ g:message_list
- AssertEqual {'42': {'buffer': bufnr('')}}, ale#symbol#GetMap()
+ AssertEqual {'42': {'buffer': bufnr(''), 'use_relative_paths': 0}}, ale#symbol#GetMap()
+
+Execute('-relative' argument should enable 'use_relative_paths' in HandleLSPResponse):
+ runtime ale_linters/python/pyls.vim
+ let b:ale_linters = ['pyls']
+ call setpos('.', [bufnr(''), 1, 5, 0])
+
+ ALESymbolSearch -relative foo bar
+
+ call call(g:WaitCallback, [g:conn_id, '/foo/bar'])
+
+ AssertEqual {'42': {'buffer': bufnr(''), 'use_relative_paths': 1}}, ale#symbol#GetMap()
diff --git a/test/test_temporary_file_management.vader b/test/test_temporary_file_management.vader
index b25da7ac..9fff1ace 100644
--- a/test/test_temporary_file_management.vader
+++ b/test/test_temporary_file_management.vader
@@ -70,7 +70,7 @@ Execute(ALE should delete managed files/directories appropriately after linting)
AssertEqual 'foobar', &filetype
call ale#Queue(0)
- call ale#engine#WaitForJobs(2000)
+ call ale#test#FlushJobs()
Assert !filereadable(g:filename), 'The temporary file was not deleted'
Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
@@ -82,7 +82,7 @@ Execute(ALE should delete managed files even if no command is run):
let g:command = ''
call ale#Queue(0)
- call ale#engine#WaitForJobs(2000)
+ call ale#test#WaitForJobs(2000)
Assert !filereadable(g:filename), 'The temporary file was not deleted'
Assert !isdirectory(g:directory), 'The temporary directory was not deleted'
@@ -119,24 +119,26 @@ Execute(ALE should create and delete directories for ale#command#CreateDirectory
Assert !isdirectory(b:dir), 'The directory was not deleted'
Assert !isdirectory(b:dir2), 'The second directory was not deleted'
-Execute(ale#command#ManageFile should add the file even if the buffer info hasn't be set yet):
+Execute(ale#command#ManageFile should add the file even if the buffer info hasn't been set yet):
call ale#command#ManageFile(bufnr(''), '/foo/bar')
AssertEqual
\ {
\ bufnr(''): {
+ \ 'jobs': {},
\ 'file_list': ['/foo/bar'],
\ 'directory_list': [],
\ },
\ },
\ ale#command#GetData()
-Execute(ale#command#ManageDirectory should add the directory even if the buffer info hasn't be set yet):
+Execute(ale#command#ManageDirectory should add the directory even if the buffer info hasn't been set yet):
call ale#command#ManageDirectory(bufnr(''), '/foo/bar')
AssertEqual
\ {
\ bufnr(''): {
+ \ 'jobs': {},
\ 'file_list': [],
\ 'directory_list': ['/foo/bar'],
\ },