diff options
Diffstat (limited to 'test/command_callback')
9 files changed, 175 insertions, 2 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' . ' .' |