summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_asm_gcc_command_callbacks.vader35
-rw-r--r--test/command_callback/test_brakeman_command_callback.vader29
-rw-r--r--test/command_callback/test_c_clang_command_callbacks.vader32
-rw-r--r--test/command_callback/test_c_clang_tidy_command_callback.vader79
-rw-r--r--test/command_callback/test_c_cppcheck_command_callbacks.vader39
-rw-r--r--test/command_callback/test_c_flawfinder_command_callbacks.vader41
-rw-r--r--test/command_callback/test_c_gcc_command_callbacks.vader31
-rw-r--r--test/command_callback/test_cargo_command_callbacks.vader213
-rw-r--r--test/command_callback/test_clang_tidy_command_callback.vader74
-rw-r--r--test/command_callback/test_cpp_clang_command_callbacks.vader31
-rw-r--r--test/command_callback/test_cpp_clangcheck_command_callbacks.vader48
-rw-r--r--test/command_callback/test_cpp_cppcheck_command_callbacks.vader39
-rw-r--r--test/command_callback/test_cpp_cquery_command_callbacks.vader38
-rw-r--r--test/command_callback/test_cpp_flawfinder_command_callbacks.vader43
-rw-r--r--test/command_callback/test_cpp_gcc_command_callbacks.vader31
-rw-r--r--test/command_callback/test_cpplint_command_callbacks.vader35
-rw-r--r--test/command_callback/test_cs_mcs_command_callbacks.vader31
-rw-r--r--test/command_callback/test_cs_mcsc_command_callbacks.vader86
-rw-r--r--test/command_callback/test_cucumber_command_callback.vader23
-rw-r--r--test/command_callback/test_cuda_nvcc_command_callbacks.vader34
-rw-r--r--test/command_callback/test_dartanalyzer_command_callback.vader34
-rw-r--r--test/command_callback/test_elixir_mix_command_callbacks.vader30
-rw-r--r--test/command_callback/test_erb_command_callback.vader15
-rw-r--r--test/command_callback/test_erlang_syntaxerl_command_callback.vader95
-rw-r--r--test/command_callback/test_erubi_command_callback.vader29
-rw-r--r--test/command_callback/test_erubis_command_callback.vader15
-rw-r--r--test/command_callback/test_flake8_command_callback.vader133
-rw-r--r--test/command_callback/test_foodcritic_command_callback.vader36
-rw-r--r--test/command_callback/test_fsc_command_callback.vader12
-rw-r--r--test/command_callback/test_fusionlint_command_callback.vader29
-rw-r--r--test/command_callback/test_gawk_command_callback.vader43
-rw-r--r--test/command_callback/test_gfortran_command_callback.vader21
-rw-r--r--test/command_callback/test_gitlint_command_callback.vader67
-rw-r--r--test/command_callback/test_glslang_command_callback.vader41
-rw-r--r--test/command_callback/test_glslls_command_callback.vader38
-rw-r--r--test/command_callback/test_gobuild_command_callback.vader44
-rw-r--r--test/command_callback/test_gometalinter_command_callback.vader45
-rw-r--r--test/command_callback/test_gosimple_command_callback.vader10
-rw-r--r--test/command_callback/test_gotype_command_callback.vader12
-rw-r--r--test/command_callback/test_govet_command_callback.vader14
-rw-r--r--test/command_callback/test_haml_hamllint_command_callback.vader59
-rw-r--r--test/command_callback/test_haskell_ghc_command_callbacks.vader19
-rw-r--r--test/command_callback/test_haskell_hdevtools_command_callbacks.vader31
-rw-r--r--test/command_callback/test_htmlhint_command_callback.vader46
-rw-r--r--test/command_callback/test_idris_command_callbacks.vader35
-rw-r--r--test/command_callback/test_iverilog_command_callback.vader18
-rw-r--r--test/command_callback/test_javac_command_callback.vader125
-rw-r--r--test/command_callback/test_jscs_command_callback.vader22
-rw-r--r--test/command_callback/test_less_stylelint_command_callback.vader41
-rw-r--r--test/command_callback/test_lessc_command_callback.vader74
-rw-r--r--test/command_callback/test_lintr_command_callback.vader40
-rw-r--r--test/command_callback/test_llc_command_callback.vader34
-rw-r--r--test/command_callback/test_luac_command_callback.vader11
-rw-r--r--test/command_callback/test_luacheck_command_callback.vader21
-rw-r--r--test/command_callback/test_markdown_mdl_command_callback.vader26
-rw-r--r--test/command_callback/test_mercury_mmc_command_callback.vader39
-rw-r--r--test/command_callback/test_mypy_command_callback.vader69
-rw-r--r--test/command_callback/test_nagelfar_command_callbacks.vader35
-rw-r--r--test/command_callback/test_nasm_nasm_command_callbacks.vader43
-rw-r--r--test/command_callback/test_ocaml_ols_callbacks.vader40
-rw-r--r--test/command_callback/test_perl_command_callback.vader31
-rw-r--r--test/command_callback/test_perlcritic_command_callback.vader57
-rw-r--r--test/command_callback/test_php_langserver_callbacks.vader34
-rw-r--r--test/command_callback/test_phpmd_command_callbacks.vader16
-rw-r--r--test/command_callback/test_phpstan_command_callbacks.vader30
-rw-r--r--test/command_callback/test_pony_ponyc_command_callbacks.vader19
-rw-r--r--test/command_callback/test_prospector_command_callback.vader19
-rw-r--r--test/command_callback/test_proto_command_callback.vader17
-rw-r--r--test/command_callback/test_puglint_command_callback.vader47
-rw-r--r--test/command_callback/test_pycodestyle_command_callback.vader26
-rw-r--r--test/command_callback/test_pyflakes_command_callback.vader33
-rw-r--r--test/command_callback/test_pylint_command_callback.vader81
-rw-r--r--test/command_callback/test_pyls_command_callback.vader28
-rw-r--r--test/command_callback/test_pyre_command_callback.vader35
-rw-r--r--test/command_callback/test_pyrex_cython_command_callback.vader36
-rw-r--r--test/command_callback/test_qmlfmt_command_callback.vader13
-rw-r--r--test/command_callback/test_rails_best_practices_command_callback.vader35
-rw-r--r--test/command_callback/test_reason_ols_callbacks.vader39
-rw-r--r--test/command_callback/test_reek_command_callback.vader34
-rw-r--r--test/command_callback/test_rubocop_command_callback.vader32
-rw-r--r--test/command_callback/test_ruby_command_callback.vader20
-rw-r--r--test/command_callback/test_rust_rls_callbacks.vader34
-rw-r--r--test/command_callback/test_rustc_command_callback.vader28
-rw-r--r--test/command_callback/test_sasslint_command_callback.vader9
-rw-r--r--test/command_callback/test_scalac_command_callback.vader12
-rw-r--r--test/command_callback/test_scalastyle_command_callback.vader42
-rw-r--r--test/command_callback/test_shellcheck_command_callback.vader126
-rw-r--r--test/command_callback/test_slimlint_command_callback.vader38
-rw-r--r--test/command_callback/test_standard_command_callback.vader62
-rw-r--r--test/command_callback/test_staticcheck_command_callback.vader31
-rw-r--r--test/command_callback/test_swaglint_command_callback.vader36
-rw-r--r--test/command_callback/test_terraform_tflint_command_callback.vader29
-rw-r--r--test/command_callback/test_textlint_command_callbacks.vader70
-rw-r--r--test/command_callback/test_thrift_command_callback.vader62
-rw-r--r--test/command_callback/test_tslint_command_callback.vader35
-rw-r--r--test/command_callback/test_vint_command_callback.vader28
-rw-r--r--test/command_callback/test_write_good_command_callback.vader13
-rw-r--r--test/command_callback/test_xmllint_command_callback.vader19
-rw-r--r--test/fixers/test_tslint_fixer_callback.vader18
-rw-r--r--test/test_ale_lint_command.vader22
-rw-r--r--test/test_env_function.vader8
101 files changed, 1090 insertions, 2917 deletions
diff --git a/test/command_callback/test_asm_gcc_command_callbacks.vader b/test/command_callback/test_asm_gcc_command_callbacks.vader
index ce8b906a..5ad31186 100644
--- a/test/command_callback/test_asm_gcc_command_callbacks.vader
+++ b/test/command_callback/test_asm_gcc_command_callbacks.vader
@@ -1,39 +1,18 @@
Before:
- Save g:ale_asm_gcc_executable
- Save g:ale_asm_gcc_options
-
- unlet! g:ale_asm_gcc_executable
- unlet! b:ale_asm_gcc_executable
- unlet! g:ale_asm_gcc_options
- unlet! b:ale_asm_gcc_options
-
- runtime ale_linters/asm/gcc.vim
-
+ call ale#assert#SetUpLinterTest('asm', 'gcc')
+ call ale#test#SetFilename('test.cpp')
let b:command_tail = ' -x assembler -fsyntax-only -iquote'
- \ . ' ' . ale#Escape(getcwd())
+ \ . ' ' . ale#Escape(g:dir)
\ . ' -Wall -'
After:
- Restore
unlet! b:command_tail
- unlet! b:ale_asm_gcc_executable
- unlet! b:ale_asm_gcc_options
- call ale#linter#Reset()
-
-Execute(The executable should be configurable):
- AssertEqual 'gcc', ale_linters#asm#gcc#GetExecutable(bufnr(''))
-
- let b:ale_asm_gcc_executable = 'foobar'
- AssertEqual 'foobar', ale_linters#asm#gcc#GetExecutable(bufnr(''))
+ call ale#assert#TearDownLinterTest()
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('gcc') . b:command_tail,
- \ ale_linters#asm#gcc#GetCommand(bufnr(''))
+Execute(The executable should be configurable):
+ AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
let b:ale_asm_gcc_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . b:command_tail,
- \ ale_linters#asm#gcc#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
diff --git a/test/command_callback/test_brakeman_command_callback.vader b/test/command_callback/test_brakeman_command_callback.vader
index 1772c9d6..61be4caf 100644
--- a/test/command_callback/test_brakeman_command_callback.vader
+++ b/test/command_callback/test_brakeman_command_callback.vader
@@ -1,39 +1,24 @@
Before:
- Save g:ale_ruby_brakeman_options
-
- runtime ale_linters/ruby/brakeman.vim
-
- let g:ale_ruby_brakeman_options = ''
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('ruby', 'brakeman')
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The brakeman command callback should detect absence of a valid Rails app):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/test.rb')
- AssertEqual
- \ '',
- \ ale_linters#ruby#brakeman#GetCommand(bufnr(''))
+ AssertLinter 'brakeman', ''
Execute(The brakeman command callback should find a valid Rails app root):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb')
- AssertEqual
- \ 'brakeman -f json -q -p '
- \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app')),
- \ ale_linters#ruby#brakeman#GetCommand(bufnr(''))
+ AssertLinter 'brakeman', 'brakeman -f json -q -p '
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app'))
Execute(The brakeman command callback should include configured options):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb')
let g:ale_ruby_brakeman_options = '--combobulate'
- AssertEqual
- \ 'brakeman -f json -q --combobulate -p '
- \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app')),
- \ ale_linters#ruby#brakeman#GetCommand(bufnr(''))
+ AssertLinter 'brakeman', 'brakeman -f json -q --combobulate -p '
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/../ruby_fixtures/valid_rails_app'))
diff --git a/test/command_callback/test_c_clang_command_callbacks.vader b/test/command_callback/test_c_clang_command_callbacks.vader
index 2f6d4dd0..87f7fd06 100644
--- a/test/command_callback/test_c_clang_command_callbacks.vader
+++ b/test/command_callback/test_c_clang_command_callbacks.vader
@@ -1,39 +1,17 @@
Before:
- Save g:ale_c_clang_executable
- Save g:ale_c_clang_options
-
- unlet! g:ale_c_clang_executable
- unlet! b:ale_c_clang_executable
- unlet! g:ale_c_clang_options
- unlet! b:ale_c_clang_options
-
- runtime ale_linters/c/clang.vim
-
+ call ale#assert#SetUpLinterTest('c', 'clang')
let b:command_tail = ' -S -x c -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
\ . ' -std=c11 -Wall -'
After:
- Restore
unlet! b:command_tail
- unlet! b:ale_c_clang_executable
- unlet! b:ale_c_clang_options
- call ale#linter#Reset()
-
-Execute(The executable should be configurable):
- AssertEqual 'clang', ale_linters#c#clang#GetExecutable(bufnr(''))
-
- let b:ale_c_clang_executable = 'foobar'
- AssertEqual 'foobar', ale_linters#c#clang#GetExecutable(bufnr(''))
+ call ale#assert#TearDownLinterTest()
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('clang') . b:command_tail,
- \ ale_linters#c#clang#GetCommand(bufnr(''), [])
+Execute(The executable should be configurable):
+ AssertLinter 'clang', ['', ale#Escape('clang') . b:command_tail]
let b:ale_c_clang_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . b:command_tail,
- \ ale_linters#c#clang#GetCommand(bufnr(''), [])
+ AssertLinter 'foobar', ['', ale#Escape('foobar') . b:command_tail]
diff --git a/test/command_callback/test_c_clang_tidy_command_callback.vader b/test/command_callback/test_c_clang_tidy_command_callback.vader
index 6f75d777..582d4798 100644
--- a/test/command_callback/test_c_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_c_clang_tidy_command_callback.vader
@@ -1,77 +1,49 @@
Before:
- Save g:ale_c_clangtidy_checks
- Save g:ale_c_clangtidy_options
- Save g:ale_c_build_dir
-
- unlet! g:ale_c_build_dir
- unlet! b:ale_c_build_dir
- unlet! g:ale_c_clangtidy_checks
- unlet! b:ale_c_clangtidy_checks
- unlet! g:ale_c_clangtidy_options
- unlet! b:ale_c_clangtidy_options
-
- runtime ale_linters/c/clangtidy.vim
-
+ call ale#assert#SetUpLinterTest('c', 'clangtidy')
call ale#test#SetFilename('test.c')
After:
- unlet! b:ale_c_build_dir
- unlet! b:ale_c_clangtidy_checks
- unlet! b:ale_c_clangtidy_options
- unlet! b:ale_c_clangtidy_executable
-
- Restore
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The clangtidy command default should be correct):
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s',
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s'
Execute(You should be able to remove the -checks option for clang-tidy):
let b:ale_c_clangtidy_checks = []
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' %s',
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy') . ' %s'
Execute(You should be able to set other checks for clang-tidy):
let b:ale_c_clangtidy_checks = ['-*', 'clang-analyzer-*']
- AssertEqual
+ AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s',
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
+ \ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s'
Execute(You should be able to manually set compiler flags for clang-tidy):
let b:ale_c_clangtidy_options = '-Wall'
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s'
- \ . ' -- -Wall',
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
- \
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
+
Execute(The build directory should be configurable):
let b:ale_c_build_dir = '/foo/bar'
- AssertEqual
+ AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s'
- \ . ' -p ' . ale#Escape('/foo/bar'),
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
+ \ . ' -p ' . ale#Escape('/foo/bar')
Execute(The build directory setting should override the options):
let b:ale_c_build_dir = '/foo/bar'
let b:ale_c_clangtidy_options = '-Wall'
- AssertEqual
+ AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
\ . ' -checks=' . ale#Escape('*') . ' %s'
- \ . ' -p ' . ale#Escape('/foo/bar'),
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
+ \ . ' -p ' . ale#Escape('/foo/bar')
Execute(The build directory should be ignored for header files):
call ale#test#SetFilename('test.h')
@@ -79,24 +51,17 @@ Execute(The build directory should be ignored for header files):
let b:ale_c_build_dir = '/foo/bar'
let b:ale_c_clangtidy_options = '-Wall'
- AssertEqual
+ AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s'
- \ . ' -- -Wall',
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
- \
+ \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
+
call ale#test#SetFilename('test.h')
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s'
- \ . ' -- -Wall',
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
Execute(The executable should be configurable):
let b:ale_c_clangtidy_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar')
- \ . ' -checks=' . ale#Escape('*') . ' %s',
- \ ale_linters#c#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'foobar',
+ \ ale#Escape('foobar') . ' -checks=' . ale#Escape('*') . ' %s'
diff --git a/test/command_callback/test_c_cppcheck_command_callbacks.vader b/test/command_callback/test_c_cppcheck_command_callbacks.vader
index 1643e3e0..3fc87a79 100644
--- a/test/command_callback/test_c_cppcheck_command_callbacks.vader
+++ b/test/command_callback/test_c_cppcheck_command_callbacks.vader
@@ -1,49 +1,24 @@
Before:
- Save g:ale_c_cppcheck_executable
- Save g:ale_c_cppcheck_options
-
- unlet! g:ale_c_cppcheck_executable
- unlet! b:ale_c_cppcheck_executable
- unlet! g:ale_c_cppcheck_options
- unlet! b:ale_c_cppcheck_options
-
- runtime ale_linters/c/cppcheck.vim
+ call ale#assert#SetUpLinterTest('c', 'cppcheck')
let b:command_tail = ' -q --language=c --enable=style %t'
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
After:
- Restore
+ call ale#assert#TearDownLinterTest()
+
unlet! b:command_tail
- unlet! b:ale_c_cppcheck_executable
- unlet! b:ale_c_cppcheck_options
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
Execute(The executable should be configurable):
- AssertEqual 'cppcheck', ale_linters#c#cppcheck#GetExecutable(bufnr(''))
-
- let b:ale_c_cppcheck_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#c#cppcheck#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('cppcheck') . b:command_tail,
- \ ale_linters#c#cppcheck#GetCommand(bufnr(''))
+ AssertLinter 'cppcheck', ale#Escape('cppcheck') . b:command_tail
let b:ale_c_cppcheck_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . b:command_tail,
- \ ale_linters#c#cppcheck#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(cppcheck for C++ should detect compile_commands.json files):
call ale#test#SetFilename('cppcheck_paths/one/foo.cpp')
- AssertEqual
+ AssertLinter 'cppcheck',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) . ' && '
\ . ale#Escape('cppcheck')
- \ . ' -q --language=c --project=compile_commands.json --enable=style %t',
- \ ale_linters#c#cppcheck#GetCommand(bufnr(''))
+ \ . ' -q --language=c --project=compile_commands.json --enable=style %t'
diff --git a/test/command_callback/test_c_flawfinder_command_callbacks.vader b/test/command_callback/test_c_flawfinder_command_callbacks.vader
index 38a602dd..44573ff5 100644
--- a/test/command_callback/test_c_flawfinder_command_callbacks.vader
+++ b/test/command_callback/test_c_flawfinder_command_callbacks.vader
@@ -1,51 +1,24 @@
Before:
- Save g:ale_c_flawfinder_executable
- Save g:ale_c_flawfinder_options
- Save g:ale_c_flawfinder_minlevel
-
- unlet! g:ale_c_flawfinder_executable
- unlet! b:ale_c_flawfinder_executable
- unlet! g:ale_c_flawfinder_options
- unlet! b:ale_c_flawfinder_options
- unlet! g:ale_c_flawfinder_minlevel
- unlet! b:ale_c_flawfinder_minlevel
-
- runtime ale_linters/c/flawfinder.vim
+ call ale#assert#SetUpLinterTest('c', 'flawfinder')
After:
- unlet! b:ale_c_flawfinder_executable
- unlet! b:ale_c_flawfinder_options
- unlet! b:ale_c_flawfinder_minlevel
-
- Restore
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The flawfinder command should be correct):
- AssertEqual
- \ ale#Escape('flawfinder')
- \ . ' -CDQS --minlevel=1 %t',
- \ ale_linters#c#flawfinder#GetCommand(bufnr(''))
+ AssertLinter 'flawfinder', ale#Escape('flawfinder') . ' -CDQS --minlevel=1 %t'
Execute(The minlevel of flawfinder should be configurable):
let b:ale_c_flawfinder_minlevel = 8
- AssertEqual
- \ ale#Escape('flawfinder')
- \ . ' -CDQS --minlevel=8 %t',
- \ ale_linters#c#flawfinder#GetCommand(bufnr(''))
+ AssertLinter 'flawfinder', ale#Escape('flawfinder') . ' -CDQS --minlevel=8 %t'
Execute(Additional flawfinder options should be configurable):
let b:ale_c_flawfinder_options = ' --foobar'
- AssertEqual
- \ ale#Escape('flawfinder')
- \ . ' -CDQS --foobar --minlevel=1 %t',
- \ ale_linters#c#flawfinder#GetCommand(bufnr(''))
+ AssertLinter 'flawfinder',
+ \ ale#Escape('flawfinder') . ' -CDQS --foobar --minlevel=1 %t'
Execute(The flawfinder exectable should be configurable):
let b:ale_c_flawfinder_executable = 'foo/bar'
- AssertEqual
- \ ale#Escape('foo/bar')
- \ . ' -CDQS --minlevel=1 %t',
- \ ale_linters#c#flawfinder#GetCommand(bufnr(''))
+ AssertLinter 'foo/bar', ale#Escape('foo/bar') . ' -CDQS --minlevel=1 %t'
diff --git a/test/command_callback/test_c_gcc_command_callbacks.vader b/test/command_callback/test_c_gcc_command_callbacks.vader
index 3557576e..45514051 100644
--- a/test/command_callback/test_c_gcc_command_callbacks.vader
+++ b/test/command_callback/test_c_gcc_command_callbacks.vader
@@ -1,39 +1,18 @@
Before:
- Save g:ale_c_gcc_executable
- Save g:ale_c_gcc_options
-
- unlet! g:ale_c_gcc_executable
- unlet! b:ale_c_gcc_executable
- unlet! g:ale_c_gcc_options
- unlet! b:ale_c_gcc_options
-
- runtime ale_linters/c/gcc.vim
+ call ale#assert#SetUpLinterTest('c', 'gcc')
let b:command_tail = ' -S -x c -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
\ . ' -std=c11 -Wall -'
After:
- Restore
+ call ale#assert#TearDownLinterTest()
+
unlet! b:command_tail
- unlet! b:ale_c_gcc_executable
- unlet! b:ale_c_gcc_options
- call ale#linter#Reset()
Execute(The executable should be configurable):
- AssertEqual 'gcc', ale_linters#c#gcc#GetExecutable(bufnr(''))
-
- let b:ale_c_gcc_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#c#gcc#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('gcc') . b:command_tail,
- \ ale_linters#c#gcc#GetCommand(bufnr(''), [])
+ AssertLinter 'gcc', ['', ale#Escape('gcc') . b:command_tail]
let b:ale_c_gcc_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . b:command_tail,
- \ ale_linters#c#gcc#GetCommand(bufnr(''), [])
+ AssertLinter 'foobar', ['', ale#Escape('foobar') . b:command_tail]
diff --git a/test/command_callback/test_cargo_command_callbacks.vader b/test/command_callback/test_cargo_command_callbacks.vader
index 6bdc10b6..ac8846b0 100644
--- a/test/command_callback/test_cargo_command_callbacks.vader
+++ b/test/command_callback/test_cargo_command_callbacks.vader
@@ -1,223 +1,130 @@
Before:
- Save g:ale_rust_cargo_use_check
- Save g:ale_rust_cargo_check_all_targets
- Save g:ale_rust_cargo_check_tests
- Save g:ale_rust_cargo_check_examples
- Save g:ale_rust_cargo_default_feature_behavior
- Save g:ale_rust_cargo_include_features
- Save g:ale_rust_cargo_avoid_whole_workspace
-
- unlet! g:ale_rust_cargo_use_check
- unlet! g:ale_rust_cargo_check_all_targets
- unlet! g:ale_rust_cargo_check_tests
- unlet! g:ale_rust_cargo_check_examples
- unlet! g:ale_rust_cargo_default_feature_behavior
- unlet! g:ale_rust_cargo_include_features
- unlet! g:ale_rust_cargo_avoid_whole_workspace
-
- runtime ale_linters/rust/cargo.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('rust', 'cargo')
let g:suffix = ' --frozen --message-format=json -q'
+ " Test with version 0.22.0 by default.
+ WithChainResults ['cargo 0.22.0 (3423351a5 2017-10-06)']
+
After:
- Restore
+ call ale#assert#TearDownLinterTest()
unlet! g:suffix
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
- call ale#semver#ResetVersionCache()
-
-Execute(An empty string should be returned for the cargo executable when there's no Cargo.toml file):
- AssertEqual
- \ '',
- \ ale_linters#rust#cargo#GetCargoExecutable(bufnr(''))
+Execute(The linter should not be executed when there's no Cargo.toml file):
+ AssertLinterNotExecuted
-Execute(The executable should be returned when there is a Cargo.toml file):
+Execute(The linter should be executed when there is a Cargo.toml file):
call ale#test#SetFilename('cargo_paths/test.rs')
- AssertEqual
- \ 'cargo',
- \ ale_linters#rust#cargo#GetCargoExecutable(bufnr(''))
-
-Execute(The VersionCheck function should return the --version command):
- AssertEqual
- \ 'cargo --version',
- \ ale_linters#rust#cargo#VersionCheck(bufnr(''))
+ WithChainResults []
+ AssertLinter 'cargo',
+ \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cargo_paths')) . ' && '
+ \ . 'cargo build --frozen --message-format=json -q'
Execute(The default command should be correct):
- AssertEqual
- \ 'cargo build' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
+ WithChainResults []
+ AssertLinter '', ['cargo --version', 'cargo build' . g:suffix]
Execute(`cargo check` should be used when the version is new enough):
- AssertEqual
- \ 'cargo check' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.17.0 (3423351a5 2017-10-06)',
- \ ])
+ WithChainResults ['cargo 0.17.0 (3423351a5 2017-10-06)']
+ AssertLinter '', ['cargo --version', 'cargo check' . g:suffix]
" We should cache the version check
- AssertEqual
- \ 'cargo check' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
-
- AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
+ WithChainResults []
+ AssertLinter '', ['', 'cargo check' . g:suffix]
Execute(`cargo build` should be used when cargo is too old):
- AssertEqual
- \ 'cargo build' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.16.0 (3423351a5 2017-10-06)',
- \ ])
-
- " We should cache the version check
- AssertEqual
- \ 'cargo build' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
+ WithChainResults ['cargo 0.16.0 (3423351a5 2017-10-06)']
+ AssertLinter '', ['cargo --version', 'cargo build' . g:suffix]
- AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
+ WithChainResults []
+ AssertLinter '', ['', 'cargo build' . g:suffix]
Execute(`cargo build` should be used when g:ale_rust_cargo_use_check is set to 0):
let g:ale_rust_cargo_use_check = 0
- AssertEqual
- \ 'cargo build' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.24.0 (3423351a5 2017-10-06)',
- \ ])
+ WithChainResults ['cargo 0.24.0 (3423351a5 2017-10-06)']
+ AssertLinter '', ['cargo --version', 'cargo build' . g:suffix]
" We should cache the version check
- AssertEqual
- \ 'cargo build' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
-
- AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
+ WithChainResults []
+ AssertLinter '', ['', 'cargo build' . g:suffix]
Execute(`cargo check` should be used when the version is new enough):
- AssertEqual
- \ 'cargo check' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.22.0 (3423351a5 2017-10-06)',
- \ ])
+ AssertLinter '', ['cargo --version', 'cargo check' . g:suffix]
" We should cache the version check
- AssertEqual
- \ 'cargo check' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
-
- AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
+ WithChainResults []
+ AssertLinter '', ['', 'cargo check' . g:suffix]
Execute(--all-targets should be used when g:ale_rust_cargo_check_all_targets is set to 1):
let g:ale_rust_cargo_check_all_targets = 1
- AssertEqual
- \ 'cargo check --all-targets' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.22.0 (3423351a5 2017-10-06)',
- \ ])
+ AssertLinter '', ['cargo --version', 'cargo check --all-targets' . g:suffix]
" We should cache the version check
- AssertEqual
- \ 'cargo check --all-targets' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
-
- AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
+ WithChainResults []
+ AssertLinter '', ['', 'cargo check --all-targets' . g:suffix]
Execute(--tests should be used when g:ale_rust_cargo_check_tests is set to 1):
let g:ale_rust_cargo_check_tests = 1
- AssertEqual
- \ 'cargo check --tests' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.22.0 (3423351a5 2017-10-06)',
- \ ])
+ AssertLinter '', ['cargo --version', 'cargo check --tests' . g:suffix]
" We should cache the version check
- AssertEqual
- \ 'cargo check --tests' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
-
- AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
+ WithChainResults []
+ AssertLinter '', ['', 'cargo check --tests' . g:suffix]
Execute(--examples should be used when g:ale_rust_cargo_check_examples is set to 1):
let g:ale_rust_cargo_check_examples = 1
- AssertEqual
- \ 'cargo check --examples' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.22.0 (3423351a5 2017-10-06)',
- \ ])
+ AssertLinter '', ['cargo --version', 'cargo check --examples' . g:suffix]
" We should cache the version check
- AssertEqual
- \ 'cargo check --examples' . g:suffix,
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
-
- AssertEqual '', ale_linters#rust#cargo#VersionCheck(bufnr(''))
+ WithChainResults []
+ AssertLinter '', ['', 'cargo check --examples' . g:suffix]
Execute(--no-default-features should be used when g:ale_rust_cargo_default_feature_behavior is none):
- let g:ale_rust_cargo_default_feature_behavior = 'none'
+ let b:ale_rust_cargo_default_feature_behavior = 'none'
- AssertEqual
- \ 'cargo check' . g:suffix . ' --no-default-features',
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.22.0 (3423351a5 2017-10-06)',
- \ ])
+ AssertLinter '', ['cargo --version', 'cargo check --frozen --message-format=json -q --no-default-features']
Execute(g:ale_rust_cargo_include_features added when g:ale_rust_cargo_default_feature_behavior is none):
- let g:ale_rust_cargo_default_feature_behavior = 'none'
- let g:ale_rust_cargo_include_features = 'foo bar'
+ let b:ale_rust_cargo_default_feature_behavior = 'none'
+ let b:ale_rust_cargo_include_features = 'foo bar'
- AssertEqual
- \ 'cargo check' . g:suffix . ' --no-default-features --features ' .
- \ (fnamemodify(&shell, ':t') is? 'cmd.exe' ? '"foo bar"' : "'foo bar'"),
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.22.0 (3423351a5 2017-10-06)',
- \ ])
+ AssertLinter '', ['cargo --version', 'cargo check --frozen --message-format=json -q --no-default-features --features ' . ale#Escape('foo bar')]
Execute(g:ale_rust_cargo_include_features added and escaped):
- let g:ale_rust_cargo_default_feature_behavior = 'default'
- let g:ale_rust_cargo_include_features = "foo bar baz"
+ let b:ale_rust_cargo_default_feature_behavior = 'default'
+ let b:ale_rust_cargo_include_features = "foo bar baz"
- AssertEqual
- \ 'cargo check' . g:suffix . ' --features ' .
- \ (fnamemodify(&shell, ':t') is? 'cmd.exe' ? '"foo bar baz"' : "'foo bar baz'"),
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.22.0 (3423351a5 2017-10-06)',
- \ ])
+ AssertLinter '', ['cargo --version', 'cargo check --frozen --message-format=json -q --features ' . ale#Escape('foo bar baz')]
Execute(--all-features should be used when g:ale_rust_cargo_default_feature_behavior is all):
- let g:ale_rust_cargo_default_feature_behavior = 'all'
-
+ let b:ale_rust_cargo_default_feature_behavior = 'all'
" When all features are enabled we should ignore extra features to add
" since it won't do anything
- let g:ale_rust_cargo_include_features = 'foo bar'
+ let b:ale_rust_cargo_include_features = 'foo bar'
- AssertEqual
- \ 'cargo check' . g:suffix . ' --all-features',
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [
- \ 'cargo 0.22.0 (3423351a5 2017-10-06)',
- \ ])
+ WithChainResults ['cargo 0.22.0 (3423351a5 2017-10-06)']
+ AssertLinter '', ['cargo --version', 'cargo check --frozen --message-format=json -q --all-features']
-Execute(When a crate belongs to a workspace we chdir into the crate.):
+Execute(When a crate belongs to a workspace we should cd into the crate):
call ale#test#SetFilename('cargo_workspace_paths/subpath/test.rs')
- if ale#Has('win32')
- let test_cdprefix = "C:\\testplugin\\test\\command_callback\\cargo_workspace_paths\\subpath"
- else
- let test_cdprefix = "'/testplugin/test/command_callback/cargo_workspace_paths/subpath'"
- endif
-
- AssertEqual
- \ "cd ".test_cdprefix." && cargo build --frozen --message-format=json -q",
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
+ AssertLinter 'cargo', [
+ \ 'cargo --version',
+ \ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cargo_workspace_paths/subpath')) . ' && '
+ \ . 'cargo check --frozen --message-format=json -q',
+ \]
Execute(When a crate belongs to a workspace we chdir into the crate, unless we disabled it):
let g:ale_rust_cargo_avoid_whole_workspace = 0
call ale#test#SetFilename('cargo_workspace_paths/subpath/test.rs')
- AssertEqual
- \ "cargo build --frozen --message-format=json -q",
- \ ale_linters#rust#cargo#GetCommand(bufnr(''), [])
+ AssertLinter 'cargo', [
+ \ 'cargo --version',
+ \ 'cargo check --frozen --message-format=json -q',
+ \]
diff --git a/test/command_callback/test_clang_tidy_command_callback.vader b/test/command_callback/test_clang_tidy_command_callback.vader
index f82efffe..f28609ee 100644
--- a/test/command_callback/test_clang_tidy_command_callback.vader
+++ b/test/command_callback/test_clang_tidy_command_callback.vader
@@ -1,74 +1,46 @@
Before:
- Save g:ale_cpp_clangtidy_checks
- Save g:ale_cpp_clangtidy_options
- Save g:ale_c_build_dir
-
- unlet! g:ale_c_build_dir
- unlet! b:ale_c_build_dir
- unlet! g:ale_cpp_clangtidy_checks
- unlet! b:ale_cpp_clangtidy_checks
- unlet! g:ale_cpp_clangtidy_options
- unlet! b:ale_cpp_clangtidy_options
-
- runtime ale_linters/cpp/clangtidy.vim
-
+ call ale#assert#SetUpLinterTest('cpp', 'clangtidy')
call ale#test#SetFilename('test.cpp')
After:
- unlet! b:ale_c_build_dir
- unlet! b:ale_cpp_clangtidy_checks
- unlet! b:ale_cpp_clangtidy_options
- unlet! b:ale_cpp_clangtidy_executable
-
- Restore
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The clangtidy command default should be correct):
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s',
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s'
Execute(You should be able to remove the -checks option for clang-tidy):
let b:ale_cpp_clangtidy_checks = []
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' %s',
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'clang-tidy', ale#Escape('clang-tidy') . ' %s'
Execute(You should be able to set other checks for clang-tidy):
let b:ale_cpp_clangtidy_checks = ['-*', 'clang-analyzer-*']
- AssertEqual
+ AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s',
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
+ \ . ' -checks=' . ale#Escape('-*,clang-analyzer-*') . ' %s'
Execute(You should be able to manually set compiler flags for clang-tidy):
let b:ale_cpp_clangtidy_options = '-Wall'
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
\
Execute(The build directory should be configurable):
let b:ale_c_build_dir = '/foo/bar'
- AssertEqual
+ AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar'),
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
+ \ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar')
Execute(The build directory setting should override the options):
let b:ale_c_build_dir = '/foo/bar'
let b:ale_cpp_clangtidy_options = '-Wall'
- AssertEqual
+ AssertLinter 'clang-tidy',
\ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar'),
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
+ \ . ' -checks=' . ale#Escape('*') . ' %s -p ' . ale#Escape('/foo/bar')
Execute(The build directory should be ignored for header files):
call ale#test#SetFilename('test.h')
@@ -76,22 +48,16 @@ Execute(The build directory should be ignored for header files):
let b:ale_c_build_dir = '/foo/bar'
let b:ale_cpp_clangtidy_options = '-Wall'
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
- \
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
+
call ale#test#SetFilename('test.hpp')
- AssertEqual
- \ ale#Escape('clang-tidy')
- \ . ' -checks=' . ale#Escape('*') . ' %s -- -Wall',
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'clang-tidy',
+ \ ale#Escape('clang-tidy') . ' -checks=' . ale#Escape('*') . ' %s -- -Wall'
Execute(The executable should be configurable):
let b:ale_cpp_clangtidy_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar')
- \ . ' -checks=' . ale#Escape('*') . ' %s',
- \ ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
+ AssertLinter 'foobar',
+ \ ale#Escape('foobar') . ' -checks=' . ale#Escape('*') . ' %s'
diff --git a/test/command_callback/test_cpp_clang_command_callbacks.vader b/test/command_callback/test_cpp_clang_command_callbacks.vader
index 8c671115..3a5ea945 100644
--- a/test/command_callback/test_cpp_clang_command_callbacks.vader
+++ b/test/command_callback/test_cpp_clang_command_callbacks.vader
@@ -1,39 +1,16 @@
Before:
- Save g:ale_cpp_clang_executable
- Save g:ale_cpp_clang_options
-
- unlet! g:ale_cpp_clang_executable
- unlet! b:ale_cpp_clang_executable
- unlet! g:ale_cpp_clang_options
- unlet! b:ale_cpp_clang_options
-
- runtime ale_linters/cpp/clang.vim
-
+ call ale#assert#SetUpLinterTest('cpp', 'clang')
let b:command_tail = ' -S -x c++ -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
\ . ' -std=c++14 -Wall -'
After:
- Restore
unlet! b:command_tail
- unlet! b:ale_cpp_clang_executable
- unlet! b:ale_cpp_clang_options
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
- AssertEqual 'clang++', ale_linters#cpp#clang#GetExecutable(bufnr(''))
-
- let b:ale_cpp_clang_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#cpp#clang#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('clang++') . b:command_tail,
- \ ale_linters#cpp#clang#GetCommand(bufnr(''), [])
+ AssertLinter 'clang++', ale#Escape('clang++') . b:command_tail
let b:ale_cpp_clang_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . b:command_tail,
- \ ale_linters#cpp#clang#GetCommand(bufnr(''), [])
+ AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
diff --git a/test/command_callback/test_cpp_clangcheck_command_callbacks.vader b/test/command_callback/test_cpp_clangcheck_command_callbacks.vader
index f708c52d..7aa09eed 100644
--- a/test/command_callback/test_cpp_clangcheck_command_callbacks.vader
+++ b/test/command_callback/test_cpp_clangcheck_command_callbacks.vader
@@ -1,63 +1,35 @@
Before:
- Save g:ale_cpp_clangcheck_executable
- Save g:ale_cpp_clangcheck_options
-
- unlet! g:ale_cpp_clangcheck_executable
- unlet! b:ale_cpp_clangcheck_executable
- unlet! g:ale_cpp_clangcheck_options
- unlet! b:ale_cpp_clangcheck_options
-
- runtime ale_linters/cpp/clangcheck.vim
+ call ale#assert#SetUpLinterTest('cpp', 'clangcheck')
After:
- Restore
- unlet! b:command_tail
- unlet! b:ale_cpp_clangcheck_executable
- unlet! b:ale_cpp_clangcheck_options
- unlet! b:ale_c_build_dir
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
- AssertEqual 'clang-check', ale_linters#cpp#clangcheck#GetExecutable(bufnr(''))
-
- let b:ale_cpp_clangcheck_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#cpp#clangcheck#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
+ AssertLinter 'clang-check',
\ ale#Escape('clang-check')
- \ . ' -analyze %s'
- \ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text',
- \ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
+ \ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text'
let b:ale_cpp_clangcheck_executable = 'foobar'
" The extra arguments in the command are used to prevent .plist files from
" being generated.
- AssertEqual
+ AssertLinter 'foobar',
\ ale#Escape('foobar')
- \ . ' -analyze %s'
- \ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text',
- \ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
+ \ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text'
Execute(The options should be configurable):
let b:ale_cpp_clangcheck_options = '--something'
- AssertEqual
+ AssertLinter 'clang-check',
\ ale#Escape('clang-check')
\ . ' -analyze %s'
\ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text'
- \ . ' --something',
- \ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
+ \ . ' --something'
Execute(The build directory should be used when set):
let b:ale_cpp_clangcheck_options = '--something'
let b:ale_c_build_dir = '/foo/bar'
- AssertEqual
+ AssertLinter 'clang-check',
\ ale#Escape('clang-check')
- \ . ' -analyze %s '
- \ . '--something -p '
- \ . ale#Escape('/foo/bar'),
- \ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))
+ \ . ' -analyze %s --something -p ' . ale#Escape('/foo/bar')
diff --git a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader
index 2c9d7298..3a7ada2c 100644
--- a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader
+++ b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader
@@ -1,49 +1,22 @@
Before:
- Save g:ale_cpp_cppcheck_executable
- Save g:ale_cpp_cppcheck_options
-
- unlet! g:ale_cpp_cppcheck_executable
- unlet! b:ale_cpp_cppcheck_executable
- unlet! g:ale_cpp_cppcheck_options
- unlet! b:ale_cpp_cppcheck_options
-
- runtime ale_linters/cpp/cppcheck.vim
-
+ call ale#assert#SetUpLinterTest('cpp', 'cppcheck')
let b:command_tail = ' -q --language=c++ --enable=style %t'
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
After:
- Restore
unlet! b:command_tail
- unlet! b:ale_cpp_cppcheck_executable
- unlet! b:ale_cpp_cppcheck_options
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
- AssertEqual 'cppcheck', ale_linters#cpp#cppcheck#GetExecutable(bufnr(''))
-
- let b:ale_cpp_cppcheck_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#cpp#cppcheck#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('cppcheck') . b:command_tail,
- \ ale_linters#cpp#cppcheck#GetCommand(bufnr(''))
+ AssertLinter 'cppcheck', ale#Escape('cppcheck') . b:command_tail
let b:ale_cpp_cppcheck_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . b:command_tail,
- \ ale_linters#cpp#cppcheck#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
Execute(cppcheck for C++ should detect compile_commands.json files):
call ale#test#SetFilename('cppcheck_paths/one/foo.cpp')
- AssertEqual
+ AssertLinter 'cppcheck',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cppcheck_paths/one')) . ' && '
\ . ale#Escape('cppcheck')
- \ . ' -q --language=c++ --project=compile_commands.json --enable=style %t',
- \ ale_linters#cpp#cppcheck#GetCommand(bufnr(''))
+ \ . ' -q --language=c++ --project=compile_commands.json --enable=style %t'
diff --git a/test/command_callback/test_cpp_cquery_command_callbacks.vader b/test/command_callback/test_cpp_cquery_command_callbacks.vader
index 89a3e225..b355d052 100644
--- a/test/command_callback/test_cpp_cquery_command_callbacks.vader
+++ b/test/command_callback/test_cpp_cquery_command_callbacks.vader
@@ -2,47 +2,21 @@
" Description: A language server for C++
Before:
- Save g:ale_cpp_cquery_executable
- Save g:ale_cpp_cquery_cache_directory
-
- unlet! g:ale_cpp_cquery_executable
- unlet! b:ale_cpp_cquery_executable
- unlet! g:ale_cpp_cquery_cache_directory
- unlet! b:ale_cpp_cquery_cache_directory
-
- runtime ale_linters/cpp/cquery.vim
+ call ale#assert#SetUpLinterTest('cpp', 'cquery')
After:
- Restore
- unlet! b:ale_cpp_cquery_executable
- unlet! b:ale_cpp_cquery_cache_directory
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
- AssertEqual 'cquery', ale_linters#cpp#cquery#GetExecutable(bufnr(''))
-
- let b:ale_cpp_cquery_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#cpp#cquery#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('cquery'),
- \ ale_linters#cpp#cquery#GetCommand(bufnr(''))
+ AssertLinter 'cquery', ale#Escape('cquery')
let b:ale_cpp_cquery_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar'),
- \ ale_linters#cpp#cquery#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar')
Execute(The cache directory should be configurable):
- AssertEqual
- \ {'cacheDirectory': expand('$HOME/.cache/cquery')},
- \ ale_linters#cpp#cquery#GetInitializationOptions(bufnr(''))
+ AssertLSPOptions {'cacheDirectory': expand('$HOME/.cache/cquery')}
let b:ale_cpp_cquery_cache_directory = '/foo/bar'
- AssertEqual
- \ {'cacheDirectory': '/foo/bar'},
- \ ale_linters#cpp#cquery#GetInitializationOptions(bufnr(''))
+ AssertLSPOptions {'cacheDirectory': '/foo/bar'}
diff --git a/test/command_callback/test_cpp_flawfinder_command_callbacks.vader b/test/command_callback/test_cpp_flawfinder_command_callbacks.vader
index 8769ec96..3f4067ea 100644
--- a/test/command_callback/test_cpp_flawfinder_command_callbacks.vader
+++ b/test/command_callback/test_cpp_flawfinder_command_callbacks.vader
@@ -1,51 +1,26 @@
Before:
- Save g:ale_cpp_flawfinder_executable
- Save g:ale_cpp_flawfinder_options
- Save g:ale_cpp_flawfinder_minlevel
-
- unlet! g:ale_cpp_flawfinder_executable
- unlet! b:ale_cpp_flawfinder_executable
- unlet! g:ale_cpp_flawfinder_options
- unlet! b:ale_cpp_flawfinder_options
- unlet! g:ale_cpp_flawfinder_minlevel
- unlet! b:ale_cpp_flawfinder_minlevel
-
- runtime ale_linters/cpp/flawfinder.vim
+ call ale#assert#SetUpLinterTest('cpp', 'flawfinder')
After:
- unlet! b:ale_cpp_flawfinder_executable
- unlet! b:ale_cpp_flawfinder_options
- unlet! b:ale_cpp_flawfinder_minlevel
-
- Restore
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The flawfinder command should be correct):
- AssertEqual
- \ ale#Escape('flawfinder')
- \ . ' -CDQS --minlevel=1 %t',
- \ ale_linters#cpp#flawfinder#GetCommand(bufnr(''))
+ AssertLinter 'flawfinder',
+ \ ale#Escape('flawfinder') . ' -CDQS --minlevel=1 %t'
Execute(The minlevel of flawfinder should be configurable):
let b:ale_cpp_flawfinder_minlevel = 8
- AssertEqual
- \ ale#Escape('flawfinder')
- \ . ' -CDQS --minlevel=8 %t',
- \ ale_linters#cpp#flawfinder#GetCommand(bufnr(''))
+ AssertLinter 'flawfinder',
+ \ ale#Escape('flawfinder') . ' -CDQS --minlevel=8 %t'
Execute(Additional flawfinder options should be configurable):
let b:ale_cpp_flawfinder_options = ' --foobar'
- AssertEqual
- \ ale#Escape('flawfinder')
- \ . ' -CDQS --foobar --minlevel=1 %t',
- \ ale_linters#cpp#flawfinder#GetCommand(bufnr(''))
+ AssertLinter 'flawfinder',
+ \ ale#Escape('flawfinder') . ' -CDQS --foobar --minlevel=1 %t'
Execute(The flawfinder exectable should be configurable):
let b:ale_cpp_flawfinder_executable = 'foo/bar'
- AssertEqual
- \ ale#Escape('foo/bar')
- \ . ' -CDQS --minlevel=1 %t',
- \ ale_linters#cpp#flawfinder#GetCommand(bufnr(''))
+ AssertLinter 'foo/bar', ale#Escape('foo/bar') . ' -CDQS --minlevel=1 %t'
diff --git a/test/command_callback/test_cpp_gcc_command_callbacks.vader b/test/command_callback/test_cpp_gcc_command_callbacks.vader
index 7abebf4c..f9fad8c8 100644
--- a/test/command_callback/test_cpp_gcc_command_callbacks.vader
+++ b/test/command_callback/test_cpp_gcc_command_callbacks.vader
@@ -1,39 +1,16 @@
Before:
- Save g:ale_cpp_gcc_executable
- Save g:ale_cpp_gcc_options
-
- unlet! g:ale_cpp_gcc_executable
- unlet! b:ale_cpp_gcc_executable
- unlet! g:ale_cpp_gcc_options
- unlet! b:ale_cpp_gcc_options
-
- runtime ale_linters/cpp/gcc.vim
-
+ call ale#assert#SetUpLinterTest('cpp', 'gcc')
let b:command_tail = ' -S -x c++ -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
\ . ' -std=c++14 -Wall -'
After:
- Restore
unlet! b:command_tail
- unlet! b:ale_cpp_gcc_executable
- unlet! b:ale_cpp_gcc_options
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
- AssertEqual 'gcc', ale_linters#cpp#gcc#GetExecutable(bufnr(''))
-
- let b:ale_cpp_gcc_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#cpp#gcc#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('gcc') . b:command_tail,
- \ ale_linters#cpp#gcc#GetCommand(bufnr(''), [])
+ AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
let b:ale_cpp_gcc_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . b:command_tail,
- \ ale_linters#cpp#gcc#GetCommand(bufnr(''), [])
+ AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
diff --git a/test/command_callback/test_cpplint_command_callbacks.vader b/test/command_callback/test_cpplint_command_callbacks.vader
index 34746a1b..d5fd457b 100644
--- a/test/command_callback/test_cpplint_command_callbacks.vader
+++ b/test/command_callback/test_cpplint_command_callbacks.vader
@@ -1,42 +1,17 @@
Before:
- Save g:ale_cpp_cpplint_executable
- Save g:ale_cpp_cpplint_options
-
- unlet! g:ale_cpp_cpplint_executable
- unlet! b:ale_cpp_cpplint_executable
- unlet! g:ale_cpp_cpplint_options
- unlet! b:ale_cpp_cpplint_options
-
- runtime ale_linters/cpp/cpplint.vim
+ call ale#assert#SetUpLinterTest('cpp', 'cpplint')
After:
- Restore
- unlet! b:command_tail
- unlet! b:ale_cpp_cpplint_executable
- unlet! b:ale_cpp_cpplint_options
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
- AssertEqual 'cpplint', ale_linters#cpp#cpplint#GetExecutable(bufnr(''))
+ AssertLinter 'cpplint', ale#Escape('cpplint') . ' %s'
let b:ale_cpp_cpplint_executable = 'foobar'
- AssertEqual 'foobar', ale_linters#cpp#cpplint#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('cpplint') . ' %s',
- \ ale_linters#cpp#cpplint#GetCommand(bufnr(''))
-
- let b:ale_cpp_cpplint_executable = 'foobar'
+ AssertLinter 'foobar', ale#Escape('foobar') . ' %s'
- AssertEqual
- \ ale#Escape('foobar') . ' %s',
- \ ale_linters#cpp#cpplint#GetCommand(bufnr(''))
- \
Execute(The options should be configurable):
let b:ale_cpp_cpplint_options = '--something'
- AssertEqual
- \ ale#Escape('cpplint') . ' --something %s',
- \ ale_linters#cpp#cpplint#GetCommand(bufnr(''))
+ AssertLinter 'cpplint', ale#Escape('cpplint') . ' --something %s'
diff --git a/test/command_callback/test_cs_mcs_command_callbacks.vader b/test/command_callback/test_cs_mcs_command_callbacks.vader
index 30f067ea..dbebd106 100644
--- a/test/command_callback/test_cs_mcs_command_callbacks.vader
+++ b/test/command_callback/test_cs_mcs_command_callbacks.vader
@@ -1,34 +1,13 @@
Before:
- Save g:ale_cs_mcs_options
-
- unlet! g:ale_cs_mcs_options
-
- runtime ale_linters/cs/mcs.vim
-
- let b:command_tail = ' -unsafe --parse'
+ call ale#assert#SetUpLinterTest('cs', 'mcs')
After:
- Restore
- unlet! b:command_tail
- unlet! b:ale_cs_mcs_options
- call ale#linter#Reset()
-
-Execute(Check for proper default command):
+ call ale#assert#TearDownLinterTest()
- let b:command = ale_linters#cs#mcs#GetCommand(bufnr(''))
- let b:command = substitute(b:command,'\s\+',' ','g')
-
- AssertEqual
- \ b:command,
- \ 'mcs -unsafe --parse %t'
+Execute(The default command should be correct):
+ AssertLinter 'mcs', 'mcs -unsafe --parse %t'
Execute(The options should be be used in the command):
-
let b:ale_cs_mcs_options = '-pkg:dotnet'
- let b:command = ale_linters#cs#mcs#GetCommand(bufnr(''))
- let b:command = substitute(b:command,'\s\+',' ','g')
-
- AssertEqual
- \ b:command,
- \ 'mcs' . b:command_tail . ' ' . b:ale_cs_mcs_options . ' %t',
+ AssertLinter 'mcs', 'mcs -unsafe --parse -pkg:dotnet %t'
diff --git a/test/command_callback/test_cs_mcsc_command_callbacks.vader b/test/command_callback/test_cs_mcsc_command_callbacks.vader
index cb52c969..20ddb28b 100644
--- a/test/command_callback/test_cs_mcsc_command_callbacks.vader
+++ b/test/command_callback/test_cs_mcsc_command_callbacks.vader
@@ -1,93 +1,47 @@
Before:
- Save g:ale_cs_mcsc_options
- Save g:ale_cs_mcsc_source
- Save g:ale_cs_mcsc_assembly_path
- Save g:ale_cs_mcsc_assemblies
- Save g:ale_buffer_info
-
- let g:ale_buffer_info = {bufnr(''): {'temporary_file_list': []}}
-
- unlet! g:ale_cs_mcsc_options
- unlet! g:ale_cs_mcsc_source
- unlet! g:ale_cs_mcsc_assembly_path
- unlet! g:ale_cs_mcsc_assemblies
-
- let g:prefix = ' -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
-
- function! GetCommand()
- let l:command = ale_linters#cs#mcsc#GetCommand(bufnr(''))
- let l:command = join(split(l:command))
-
- return substitute(l:command, ':[^ ]\+ -t:module', ':TEMP -t:module', '')
- endfunction
-
- runtime ale_linters/cs/mcsc.vim
+ call ale#assert#SetUpLinterTest('cs', 'mcsc')
After:
- Restore
-
- unlet! b:ale_cs_mcsc_options
- unlet! g:ale_cs_mcsc_source
- unlet! g:ale_cs_mcsc_assembly_path
- unlet! g:ale_cs_mcsc_assemblies
- unlet! g:ale_prefix
-
- delfunction GetCommand
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The mcsc linter should return the correct default command):
- AssertEqual
- \ ale#path#BufferCdString(bufnr(''))
- \ . 'mcs -unsafe' . g:prefix,
- \ GetCommand()
+ AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
+ \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
Execute(The options should be be used in the command):
let g:ale_cs_mcsc_options = '-pkg:dotnet'
- AssertEqual
- \ ale#path#BufferCdString(bufnr(''))
- \ . 'mcs -unsafe -pkg:dotnet' . g:prefix,
- \ GetCommand()
+ AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
+ \ . 'mcs -unsafe -pkg:dotnet -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
Execute(The souce path should be be used in the command):
let g:ale_cs_mcsc_source = '../foo/bar'
- AssertEqual
- \ 'cd ' . ale#Escape('../foo/bar') . ' && '
- \ . 'mcs -unsafe' . g:prefix,
- \ GetCommand()
+ AssertLinter 'mcs', 'cd ' . ale#Escape('../foo/bar') . ' && '
+ \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
Execute(The list of search pathes for assemblies should be be used in the command if not empty):
let g:ale_cs_mcsc_assembly_path = ['/usr/lib/mono', '../foo/bar']
- AssertEqual
- \ ale#path#BufferCdString(bufnr(''))
- \ . 'mcs -unsafe'
- \ . ' -lib:' . ale#Escape('/usr/lib/mono') . ',' . ale#Escape('../foo/bar')
- \ . g:prefix,
- \ GetCommand()
+ AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
+ \ . 'mcs -unsafe'
+ \ . ' -lib:' . ale#Escape('/usr/lib/mono') . ',' . ale#Escape('../foo/bar')
+ \ . ' -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
let g:ale_cs_mcsc_assembly_path = []
- AssertEqual
- \ ale#path#BufferCdString(bufnr(''))
- \ . 'mcs -unsafe' . g:prefix,
- \ GetCommand()
+ AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
+ \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
Execute(The list of assemblies should be be used in the command if not empty):
let g:ale_cs_mcsc_assemblies = ['foo.dll', 'bar.dll']
- AssertEqual
- \ ale#path#BufferCdString(bufnr(''))
- \ . 'mcs -unsafe'
- \ . ' -r:' . ale#Escape('foo.dll') . ',' . ale#Escape('bar.dll')
- \ . g:prefix,
- \ GetCommand()
+ AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
+ \ . 'mcs -unsafe'
+ \ . ' -r:' . ale#Escape('foo.dll') . ',' . ale#Escape('bar.dll')
+ \ . ' -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
let g:ale_cs_mcsc_assemblies = []
- AssertEqual
- \ ale#path#BufferCdString(bufnr(''))
- \ . 'mcs -unsafe' . g:prefix,
- \ GetCommand()
+ AssertLinter 'mcs', 'cd ' . ale#Escape(g:dir) . ' && '
+ \ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
diff --git a/test/command_callback/test_cucumber_command_callback.vader b/test/command_callback/test_cucumber_command_callback.vader
index d09a5712..7a8457fc 100644
--- a/test/command_callback/test_cucumber_command_callback.vader
+++ b/test/command_callback/test_cucumber_command_callback.vader
@@ -1,25 +1,18 @@
Before:
- runtime ale_linters/ruby/rubocop.vim
- call ale#test#SetDirectory('/testplugin/test/')
+ call ale#assert#SetUpLinterTest('cucumber', 'cucumber')
After:
- Restore
-
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(Should require the nearest features dir, if one is found):
- call ale#test#SetFilename('cucumber_fixtures/features/cuke.feature')
+ call ale#test#SetFilename('../cucumber_fixtures/features/cuke.feature')
- AssertEqual
- \ 'cucumber --dry-run --quiet --strict --format=json '
- \ . '-r ' . ale#Escape(ale#path#Simplify(g:dir . '/cucumber_fixtures/features/')) . ' %t',
- \ ale_linters#cucumber#cucumber#GetCommand(bufnr(''))
+ AssertLinter 'cucumber',
+ \ 'cucumber --dry-run --quiet --strict --format=json '
+ \ . '-r ' . ale#Escape(ale#path#Simplify(g:dir . '/../cucumber_fixtures/features/')) . ' %t'
Execute(Should require nothing if no features dir is found):
call ale#test#SetFilename('something/without/a/features/dir')
- AssertEqual
- \ 'cucumber --dry-run --quiet --strict --format=json '
- \ . ' %t',
- \ ale_linters#cucumber#cucumber#GetCommand(bufnr(''))
+ AssertLinter 'cucumber',
+ \ 'cucumber --dry-run --quiet --strict --format=json %t'
diff --git a/test/command_callback/test_cuda_nvcc_command_callbacks.vader b/test/command_callback/test_cuda_nvcc_command_callbacks.vader
index af199d37..9e2b5ac6 100644
--- a/test/command_callback/test_cuda_nvcc_command_callbacks.vader
+++ b/test/command_callback/test_cuda_nvcc_command_callbacks.vader
@@ -1,36 +1,14 @@
Before:
- Save g:ale_cuda_nvcc_executable
- Save g:ale_cuda_nvcc_options
-
- unlet! g:ale_cuda_nvcc_executable
- unlet! b:ale_cuda_nvcc_executable
- unlet! g:ale_cuda_nvcc_options
- unlet! b:ale_cuda_nvcc_options
-
- runtime ale_linters/cuda/nvcc.vim
+ call ale#assert#SetUpLinterTest('cuda', 'nvcc')
After:
- Restore
- unlet! b:ale_cuda_nvcc_executable
- unlet! b:ale_cuda_nvcc_options
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
- AssertEqual 'nvcc', ale_linters#cuda#nvcc#GetExecutable(bufnr(''))
-
- let b:ale_cuda_nvcc_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#cuda#nvcc#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('nvcc') . ' -cuda -std=c++11 %s'
- \ . ' -o ' . g:ale#util#nul_file,
- \ ale_linters#cuda#nvcc#GetCommand(bufnr(''))
+ AssertLinter 'nvcc',
+ \ ale#Escape('nvcc') . ' -cuda -std=c++11 %s -o ' . g:ale#util#nul_file
let b:ale_cuda_nvcc_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . ' -cuda -std=c++11 %s'
- \ . ' -o ' . g:ale#util#nul_file,
- \ ale_linters#cuda#nvcc#GetCommand(bufnr(''))
+ AssertLinter 'foobar',
+ \ ale#Escape('foobar') . ' -cuda -std=c++11 %s -o ' . g:ale#util#nul_file
diff --git a/test/command_callback/test_dartanalyzer_command_callback.vader b/test/command_callback/test_dartanalyzer_command_callback.vader
index c7b51396..62b1d636 100644
--- a/test/command_callback/test_dartanalyzer_command_callback.vader
+++ b/test/command_callback/test_dartanalyzer_command_callback.vader
@@ -1,40 +1,20 @@
Before:
- Save g:ale_dart_dartanalyzer_executable
- unlet! g:ale_dart_dartanalyzer_executable
-
- runtime ale_linters/dart/dartanalyzer.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('dart', 'dartanalyzer')
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command and executable should be correct):
- AssertEqual
- \ 'dartanalyzer',
- \ ale_linters#dart#dartanalyzer#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('dartanalyzer') . ' %s',
- \ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
+ AssertLinter 'dartanalyzer', ale#Escape('dartanalyzer') . ' %s'
Execute(The executable should be configurable):
- let g:ale_dart_dartanalyzer_executable = '/usr/lib/dart/bin/dartanalyzer'
+ let g:ale_dart_dartanalyzer_executable = 'foobar'
- AssertEqual
- \ '/usr/lib/dart/bin/dartanalyzer',
- \ ale_linters#dart#dartanalyzer#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('/usr/lib/dart/bin/dartanalyzer') . ' %s',
- \ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' %s'
Execute(The .packages file should be set if detected):
call ale#test#SetFilename('dart_paths/foo')
- AssertEqual
- \ ale#Escape('dartanalyzer')
+ AssertLinter 'dartanalyzer', ale#Escape('dartanalyzer')
\ . ' --packages ' . ale#Escape(ale#path#Simplify(g:dir . '/dart_paths/.packages'))
- \ . ' %s',
- \ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
+ \ . ' %s'
diff --git a/test/command_callback/test_elixir_mix_command_callbacks.vader b/test/command_callback/test_elixir_mix_command_callbacks.vader
index 67785881..18fb13ed 100644
--- a/test/command_callback/test_elixir_mix_command_callbacks.vader
+++ b/test/command_callback/test_elixir_mix_command_callbacks.vader
@@ -1,37 +1,19 @@
Before:
- runtime ale_linters/elixir/mix.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
- let g:project_root = ale#path#Simplify(g:dir . '/mix_paths/wrapped_project')
+ call ale#assert#SetUpLinterTest('elixir', 'mix')
let g:env_prefix = has('win32')
- \ ? 'set MIX_BUILD_PATH=TEMP && '
- \ : 'MIX_BUILD_PATH=TEMP '
-
-
- function! GetCommand(buffer) abort
- let l:command = ale_linters#elixir#mix#GetCommand(a:buffer)
-
- return substitute(l:command, 'MIX_BUILD_PATH=[^ ]\+', 'MIX_BUILD_PATH=TEMP', '')
- endfunction
+ \ ? 'set MIX_BUILD_PATH=' . ale#Escape('TEMP_DIR') . ' && '
+ \ : 'MIX_BUILD_PATH=' . ale#Escape('TEMP_DIR') . ' '
After:
- Restore
-
unlet! g:env_prefix
- unlet! g:project_root
-
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
- delfunction GetCommand
+ call ale#assert#TearDownLinterTest()
Execute(The default mix command should be correct):
call ale#test#SetFilename('mix_paths/wrapped_project/lib/app.ex')
- AssertEqual
- \ GetCommand(bufnr('')),
- \ ale#path#CdString(g:project_root)
+ AssertLinter 'mix',
+ \ ale#path#CdString(ale#path#Simplify(g:dir . '/mix_paths/wrapped_project'))
\ . g:env_prefix
\ . 'mix compile %s'
diff --git a/test/command_callback/test_erb_command_callback.vader b/test/command_callback/test_erb_command_callback.vader
index 481f64f9..c29d9215 100644
--- a/test/command_callback/test_erb_command_callback.vader
+++ b/test/command_callback/test_erb_command_callback.vader
@@ -1,21 +1,16 @@
Before:
- runtime ale_linters/eruby/erb.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('eruby', 'erb')
After:
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(Executable should not contain any filter code by default):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb')
- AssertEqual
- \ 'erb -P -T - -x %t | ruby -c',
- \ ale_linters#eruby#erb#GetCommand(bufnr(''))
+ AssertLinter 'erb', 'erb -P -T - -x %t | ruby -c'
Execute(Executable should filter invalid eRuby when inside a Rails project):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb')
- AssertEqual
- \ 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c',
- \ ale_linters#eruby#erb#GetCommand(bufnr(''))
+ AssertLinter 'erb',
+ \ 'ruby -r erb -e ' . ale#Escape('puts ERB.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c'
diff --git a/test/command_callback/test_erlang_syntaxerl_command_callback.vader b/test/command_callback/test_erlang_syntaxerl_command_callback.vader
index a9a1a500..28cff9b9 100644
--- a/test/command_callback/test_erlang_syntaxerl_command_callback.vader
+++ b/test/command_callback/test_erlang_syntaxerl_command_callback.vader
@@ -1,66 +1,45 @@
Before:
- Save g:ale_erlang_syntaxerl_executable
-
- unlet! g:ale_erlang_syntaxerl_executable
- unlet! b:ale_erlang_syntaxerl_executable
-
- runtime ale_linters/erlang/syntaxerl.vim
+ call ale#assert#SetUpLinterTest('erlang', 'syntaxerl')
After:
- Restore
-
- call ale#linter#Reset()
-
-Execute (The executable should be correct):
- AssertEqual 'syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr(''))
-
- let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl'
- AssertEqual '/some/other/syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr(''))
-
- let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
- AssertEqual '/yet/another/syntaxerl', ale_linters#erlang#syntaxerl#GetExecutable(bufnr(''))
-
+ call ale#assert#TearDownLinterTest()
-Execute (The executable should be presented in the feature check command):
- let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl'
+Execute (The default commands should be correct):
+ AssertLinter 'syntaxerl', [
+ \ ale#Escape('syntaxerl') . ' -h',
+ \ ale#Escape('syntaxerl') . ' %t',
+ \]
- AssertEqual
- \ ale#Escape('/some/other/syntaxerl') . ' -h',
- \ ale_linters#erlang#syntaxerl#FeatureCheck(bufnr(''))
+Execute (The executable should be configurable):
+ let b:ale_erlang_syntaxerl_executable = 'foobar'
- let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
-
- AssertEqual
- \ ale#Escape('/yet/another/syntaxerl') . ' -h',
- \ ale_linters#erlang#syntaxerl#FeatureCheck(bufnr(''))
-
-Execute (The executable should be presented in the command):
- let g:ale_erlang_syntaxerl_executable = '/some/other/syntaxerl'
-
- AssertEqual
- \ ale#Escape('/some/other/syntaxerl') . ' %t',
- \ ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [])
-
- let b:ale_erlang_syntaxerl_executable = '/yet/another/syntaxerl'
-
- AssertEqual
- \ ale#Escape('/yet/another/syntaxerl') . ' %t',
- \ ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [])
+ AssertLinter 'foobar', [
+ \ ale#Escape('foobar') . ' -h',
+ \ ale#Escape('foobar') . ' %t',
+ \]
Execute (The -b option should be used when available):
- AssertEqual ale#Escape('syntaxerl') . ' %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [
- \ 'Syntax checker for Erlang (0.14.0)',
- \ 'Usage: syntaxerl [-d | --debug] <FILENAME>',
- \ ' syntaxerl <-h | --help>',
- \ ' -d, --debug Enable debug output',
- \ ' -h, --help Show this message',
- \ ])
-
- AssertEqual ale#Escape('syntaxerl') . ' -b %s %t', ale_linters#erlang#syntaxerl#GetCommand(bufnr(''), [
- \ 'Syntax checker for Erlang (0.14.0)',
- \ 'Usage: syntaxerl [-b | --base <FILENAME>] [-d | --debug] <FILENAME>',
- \ ' syntaxerl <-h | --help>',
- \ ' -b, --base Set original filename',
- \ ' -d, --debug Enable debug output',
- \ ' -h, --help Show this message',
- \ ])
+ WithChainResults [
+ \ 'Syntax checker for Erlang (0.14.0)',
+ \ 'Usage: syntaxerl [-d | --debug] <FILENAME>',
+ \ ' syntaxerl <-h | --help>',
+ \ ' -d, --debug Enable debug output',
+ \ ' -h, --help Show this message',
+ \]
+ AssertLinter 'syntaxerl', [
+ \ ale#Escape('syntaxerl') . ' -h',
+ \ ale#Escape('syntaxerl') . ' %t',
+ \]
+
+ WithChainResults [
+ \ 'Syntax checker for Erlang (0.14.0)',
+ \ 'Usage: syntaxerl [-b | --base <FILENAME>] [-d | --debug] <FILENAME>',
+ \ ' syntaxerl <-h | --help>',
+ \ ' -b, --base Set original filename',
+ \ ' -d, --debug Enable debug output',
+ \ ' -h, --help Show this message',
+ \]
+ AssertLinter 'syntaxerl', [
+ \ ale#Escape('syntaxerl') . ' -h',
+ \ ale#Escape('syntaxerl') . ' -b %s %t',
+ \]
diff --git a/test/command_callback/test_erubi_command_callback.vader b/test/command_callback/test_erubi_command_callback.vader
index 1953d763..0643efc2 100644
--- a/test/command_callback/test_erubi_command_callback.vader
+++ b/test/command_callback/test_erubi_command_callback.vader
@@ -1,31 +1,32 @@
Before:
- runtime ale_linters/eruby/erubi.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('eruby', 'erubi')
After:
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(Executable should not contain any filter code by default):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb')
- AssertEqual
+ AssertLinter 'ruby', [
+ \ 'ruby -r erubi/capture_end -e ' . ale#Escape('""'),
\ 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read).src') . '< %t | ruby -c',
- \ ale_linters#eruby#erubi#GetCommand(bufnr(''), [])
+ \]
Execute(Executable should filter invalid eRuby when inside a Rails project):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb')
- AssertEqual
+ AssertLinter 'ruby', [
+ \ 'ruby -r erubi/capture_end -e ' . ale#Escape('""'),
\ 'ruby -r erubi/capture_end -e ' . ale#Escape('puts Erubi::CaptureEndEngine.new($stdin.read.gsub(%{<%=},%{<%}), nil, %{-}).src') . '< %t | ruby -c',
- \ ale_linters#eruby#erubi#GetCommand(bufnr(''), [])
+ \]
-Execute(Command should be blank if the first command in the chain return output):
- let output_lines = [
- \ "/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- erubi/capture_end (LoadError)",
- \ " from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'",
+Execute(Command should be blank if the first command in the chain returns output):
+ WithChainResults [
+ \ "/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- erubi/capture_end (LoadError)",
+ \ " from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'",
\]
- AssertEqual
+ AssertLinter 'ruby', [
+ \ 'ruby -r erubi/capture_end -e ' . ale#Escape('""'),
\ '',
- \ ale_linters#eruby#erubi#GetCommand(bufnr(''), output_lines)
+ \]
diff --git a/test/command_callback/test_erubis_command_callback.vader b/test/command_callback/test_erubis_command_callback.vader
index 574dd684..c9cdb80f 100644
--- a/test/command_callback/test_erubis_command_callback.vader
+++ b/test/command_callback/test_erubis_command_callback.vader
@@ -1,21 +1,16 @@
Before:
- runtime ale_linters/eruby/erubis.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('eruby', 'erubis')
After:
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(Executable should not contain any filter code by default):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/file.rb')
- AssertEqual
- \ 'erubis -x %t | ruby -c',
- \ ale_linters#eruby#erubis#GetCommand(bufnr(''))
+ AssertLinter 'erubis', 'erubis -x %t | ruby -c'
Execute(Executable should filter invalid eRuby when inside a Rails project):
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/app/views/my_great_view.html.erb')
- AssertEqual
- \ 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c',
- \ ale_linters#eruby#erubis#GetCommand(bufnr(''))
+ AssertLinter 'erubis',
+ \ 'ruby -r erubis -e ' . ale#Escape('puts Erubis::Eruby.new($stdin.read.gsub(%{<%=},%{<%})).src') . '< %t | ruby -c'
diff --git a/test/command_callback/test_flake8_command_callback.vader b/test/command_callback/test_flake8_command_callback.vader
index 1cc50836..f12b6747 100644
--- a/test/command_callback/test_flake8_command_callback.vader
+++ b/test/command_callback/test_flake8_command_callback.vader
@@ -1,91 +1,75 @@
Before:
- Save g:ale_python_flake8_executable
- Save g:ale_python_flake8_options
- Save g:ale_python_flake8_use_global
- Save g:ale_python_flake8_change_directory
-
- unlet! g:ale_python_flake8_executable
- unlet! g:ale_python_flake8_args
- unlet! g:ale_python_flake8_options
- unlet! g:ale_python_flake8_use_global
- unlet! g:ale_python_flake8_change_directory
-
+ call ale#assert#SetUpLinterTest('python', 'flake8')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
- runtime ale_linters/python/flake8.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ WithChainResults ['3.0.0']
After:
- Restore
-
- unlet! g:ale_python_flake8_args
-
- unlet! b:bin_dir
unlet! b:executable
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
- call ale#semver#ResetVersionCache()
+ unlet! b:bin_dir
+ call ale#assert#TearDownLinterTest()
Execute(The flake8 callbacks should return the correct default values):
- AssertEqual
- \ 'flake8',
- \ ale_linters#python#flake8#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
- \ ale_linters#python#flake8#VersionCheck(bufnr(''))
- AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
+ \]
+
+ " The version check should be cached.
+ WithChainResults []
+ AssertLinter 'flake8', [
+ \ '',
+ \ ale#path#BufferCdString(bufnr(''))
+ \ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
+ \]
" Try with older versions.
call ale#semver#ResetVersionCache()
- AssertEqual
+ WithChainResults ['2.9.9']
+ AssertLinter 'flake8', [
+ \ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
+ \]
Execute(The option for disabling changing directories should work):
let g:ale_python_flake8_change_directory = 0
- AssertEqual
+ AssertLinter 'flake8', [
+ \ ale#Escape('flake8') . ' --version',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
+ \]
Execute(The flake8 command callback should let you set options):
let g:ale_python_flake8_options = '--some-option'
- AssertEqual
+ WithChainResults ['3.0.4']
+ AssertLinter 'flake8', [
+ \ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('flake8')
- \ . ' --some-option --format=default'
- \ . ' --stdin-display-name %s -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.4'])
+ \ . ale#Escape('flake8') . ' --some-option'
+ \ . ' --format=default --stdin-display-name %s -',
+ \]
call ale#semver#ResetVersionCache()
-
- AssertEqual
+ WithChainResults ['2.9.9']
+ AssertLinter 'flake8', [
+ \ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('flake8')
- \ . ' --some-option --format=default -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
+ \ . ale#Escape('flake8') . ' --some-option --format=default -',
+ \]
Execute(You should be able to set a custom executable and it should be escaped):
let g:ale_python_flake8_executable = 'executable with spaces'
- AssertEqual
- \ 'executable with spaces',
- \ ale_linters#python#flake8#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'executable with spaces', [
\ ale#Escape('executable with spaces') . ' --version',
- \ ale_linters#python#flake8#VersionCheck(bufnr(''))
- AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('executable with spaces')
\ . ' --format=default'
\ . ' --stdin-display-name %s -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
+ \]
Execute(The flake8 callbacks should detect virtualenv directories):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
@@ -94,17 +78,13 @@ Execute(The flake8 callbacks should detect virtualenv directories):
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/flake8'
\)
- AssertEqual
- \ b:executable,
- \ ale_linters#python#flake8#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter b:executable, [
\ ale#Escape(b:executable) . ' --version',
- \ ale_linters#python#flake8#VersionCheck(bufnr(''))
- AssertEqual
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape(b:executable)
- \ . ' --format=default --stdin-display-name %s -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
+ \ . ale#Escape(b:executable)
+ \ . ' --format=default'
+ \ . ' --stdin-display-name %s -',
+ \]
Execute(The FindProjectRoot should detect the project root directory for namespace package via Manifest.in):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_manifest/namespace/foo/bar.py')
@@ -148,37 +128,32 @@ Execute(Using `python -m flake8` should be supported for running flake8):
let g:ale_python_flake8_executable = 'python'
let g:ale_python_flake8_options = '-m flake8 --some-option'
- AssertEqual
- \ 'python',
- \ ale_linters#python#flake8#GetExecutable(bufnr(''))
- AssertEqual
+ WithChainResults ['2.9.9']
+ AssertLinter 'python', [
\ ale#Escape('python') . ' -m flake8 --version',
- \ ale_linters#python#flake8#VersionCheck(bufnr(''))
- AssertEqual
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('python') . ' -m flake8 --some-option --format=default -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
+ \ . ale#Escape('python')
+ \ . ' -m flake8 --some-option --format=default -'
+ \]
call ale#semver#ResetVersionCache()
" Leading spaces shouldn't matter
let g:ale_python_flake8_options = ' -m flake8 --some-option'
- AssertEqual
- \ 'python',
- \ ale_linters#python#flake8#GetExecutable(bufnr(''))
- AssertEqual
+ WithChainResults ['2.9.9']
+ AssertLinter 'python', [
\ ale#Escape('python') . ' -m flake8 --version',
- \ ale_linters#python#flake8#VersionCheck(bufnr(''))
- AssertEqual
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('python') . ' -m flake8 --some-option --format=default -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['2.9.9'])
+ \ . ale#Escape('python')
+ \ . ' -m flake8 --some-option --format=default -'
+ \]
-Execute(Setting executable to 'pipenv' appends 'run flake8'):
+Execute(Setting executable to 'pipenv' should append 'run flake8'):
let g:ale_python_flake8_executable = 'path/to/pipenv'
- AssertEqual
+ " FIXME: pipenv should check the vresion with flake8.
+ WithChainResults []
+ AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('path/to/pipenv') . ' run flake8 --format=default --stdin-display-name %s -',
- \ ale_linters#python#flake8#GetCommand(bufnr(''), ['3.0.0'])
+ \ . ale#Escape('path/to/pipenv') . ' run flake8 --format=default -'
diff --git a/test/command_callback/test_foodcritic_command_callback.vader b/test/command_callback/test_foodcritic_command_callback.vader
index e3ad8a70..c5564cb1 100644
--- a/test/command_callback/test_foodcritic_command_callback.vader
+++ b/test/command_callback/test_foodcritic_command_callback.vader
@@ -1,44 +1,18 @@
Before:
- Save g:ale_chef_foodcritic_executable
- Save g:ale_chef_foodcritic_options
-
- unlet! g:ale_chef_foodcritic_executable
- unlet! g:ale_chef_foodcritic_options
-
- call ale#test#SetDirectory('/testplugin/test')
-
- runtime ale_linters/chef/foodcritic.vim
+ call ale#assert#SetUpLinterTest('chef', 'foodcritic')
After:
- Restore
-
- unlet! b:ale_chef_foodcritic_executable
- unlet! b:ale_chef_foodcritic_options
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual
- \ 'foodcritic',
- \ ale_linters#chef#foodcritic#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('foodcritic') . ' %s',
- \ ale_linters#chef#foodcritic#GetCommand(bufnr(''))
+ AssertLinter 'foodcritic', ale#Escape('foodcritic') . ' %s'
Execute(Extra options should be included with escapeed tildes (~)):
let b:ale_chef_foodcritic_options = '-t ~F011'
- AssertEqual
- \ ale#Escape('foodcritic') . ' -t \~F011 %s',
- \ ale_linters#chef#foodcritic#GetCommand(bufnr(''))
+ AssertLinter 'foodcritic', ale#Escape('foodcritic') . ' -t \~F011 %s'
Execute(The executable should be configurable):
let b:ale_chef_foodcritic_executable = 'foobar'
- AssertEqual
- \ 'foobar',
- \ ale_linters#chef#foodcritic#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('foobar') . ' %s',
- \ ale_linters#chef#foodcritic#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' %s'
diff --git a/test/command_callback/test_fsc_command_callback.vader b/test/command_callback/test_fsc_command_callback.vader
index 451fa108..5fb5e7fa 100644
--- a/test/command_callback/test_fsc_command_callback.vader
+++ b/test/command_callback/test_fsc_command_callback.vader
@@ -1,17 +1,13 @@
Before:
- runtime ale_linters/scala/fsc.vim
+ call ale#assert#SetUpLinterTest('scala', 'fsc')
After:
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Given scala(An empty Scala file):
Execute(The default executable and command should be correct):
- AssertEqual 'fsc', ale_linters#scala#fsc#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('fsc') . ' -Ystop-after:parser %t',
- \ ale_linters#scala#fsc#GetCommand(bufnr(''))
+ AssertLinter 'fsc', ale#Escape('fsc') . ' -Ystop-after:parser %t'
Given scala.sbt(An empty SBT file):
Execute(fsc should not be run for sbt files):
- AssertEqual '', ale_linters#scala#fsc#GetExecutable(bufnr(''))
- AssertEqual '', ale_linters#scala#fsc#GetCommand(bufnr(''))
+ AssertLinter '', ''
diff --git a/test/command_callback/test_fusionlint_command_callback.vader b/test/command_callback/test_fusionlint_command_callback.vader
index 34a44133..1c63b811 100644
--- a/test/command_callback/test_fusionlint_command_callback.vader
+++ b/test/command_callback/test_fusionlint_command_callback.vader
@@ -1,34 +1,19 @@
Before:
- Save g:ale_fuse_fusionlint_options
- Save g:ale_fuse_fusionlint_executable
-
- unlet! g:ale_fuse_fusionlint_options
- unlet! g:ale_fuse_fusionlint_executable
-
- runtime ale_linters/fuse/fusionlint.vim
+ call ale#assert#SetUpLinterTest('fuse', 'fusionlint')
After:
- Restore
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The fuse fusionlint command callback should return the correct default string):
- AssertEqual ale#Escape('fusion-lint') . ' --filename %s -i',
- \ join(split(ale_linters#fuse#fusionlint#GetCommand(1)))
+ AssertLinter 'fusion-lint', ale#Escape('fusion-lint') . ' --filename %s -i'
Execute(The fuse fusionlint command callback should let you set options):
let g:ale_fuse_fusionlint_options = '--example-option argument'
- AssertEqual
- \ ale#Escape('fusion-lint')
- \ . ' --example-option argument --filename %s -i',
- \ join(split(ale_linters#fuse#fusionlint#GetCommand(1)))
+ AssertLinter 'fusion-lint',
+ \ ale#Escape('fusion-lint') . ' --example-option argument --filename %s -i'
Execute(The fusionlint executable should be configurable):
- let g:ale_fuse_fusionlint_executable = 'util/linter.fuse'
+ let g:ale_fuse_fusionlint_executable = 'foobar'
- AssertEqual 'util/linter.fuse', ale_linters#fuse#fusionlint#GetExecutable(1)
- AssertEqual
- \ ale#Escape('util/linter.fuse')
- \ . ' --filename %s -i',
- \ join(split(ale_linters#fuse#fusionlint#GetCommand(1)))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --filename %s -i'
diff --git a/test/command_callback/test_gawk_command_callback.vader b/test/command_callback/test_gawk_command_callback.vader
index ae128fe5..6bc0a438 100644
--- a/test/command_callback/test_gawk_command_callback.vader
+++ b/test/command_callback/test_gawk_command_callback.vader
@@ -1,40 +1,25 @@
Before:
- Save g:ale_awk_gawk_executable
- Save g:ale_awk_gawk_options
- unlet! g:ale_awk_gawk_executable
- unlet! g:ale_awk_gawk_options
-
- runtime ale_linters/awk/gawk.vim
+ call ale#assert#SetUpLinterTest('awk', 'gawk')
After:
- Restore
- unlet! b:command_tail
- unlet! b:ale_awk_gawk_executable
- unlet! b:ale_awk_gawk_options
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
-Execute(The executable should be used in the command):
- AssertEqual
- \ 'gawk'
- \ . " --source 'BEGIN { exit } END { exit 1 }'"
- \ . ' ' . '-f %t --lint /dev/null',
- \ ale_linters#awk#gawk#GetCommand(bufnr(''))
+Execute(The default command should be correct):
+ AssertLinter 'gawk',
+ \ ale#Escape('gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
+ \ . ' -f %t --lint /dev/null'
+Execute(The executable should be configurable):
let b:ale_awk_gawk_executable = '/other/gawk'
- AssertEqual
- \ '/other/gawk'
- \ . " --source 'BEGIN { exit } END { exit 1 }'"
- \ . ' ' . '-f %t --lint /dev/null',
- \ ale_linters#awk#gawk#GetCommand(bufnr(''))
+ AssertLinter '/other/gawk',
+ \ ale#Escape('/other/gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
+ \ . ' -f %t --lint /dev/null'
+Execute(The options should be configurable):
let b:ale_awk_gawk_executable = 'gawk'
let b:ale_awk_gawk_options = '--something'
- AssertEqual
- \ 'gawk'
- \ . " --source 'BEGIN { exit } END { exit 1 }'"
- \ . ' --something'
- \ . ' ' . '-f %t --lint /dev/null',
- \ ale_linters#awk#gawk#GetCommand(bufnr(''))
+ AssertLinter 'gawk',
+ \ ale#Escape('gawk') . ' --source ''BEGIN { exit } END { exit 1 }'''
+ \ . ' --something -f %t --lint /dev/null'
diff --git a/test/command_callback/test_gfortran_command_callback.vader b/test/command_callback/test_gfortran_command_callback.vader
index 501e92fd..a6ab50cd 100644
--- a/test/command_callback/test_gfortran_command_callback.vader
+++ b/test/command_callback/test_gfortran_command_callback.vader
@@ -1,31 +1,24 @@
Before:
- runtime ale_linters/fortran/gcc.vim
+ call ale#assert#SetUpLinterTest('fortran', 'gcc')
After:
- call ale#linter#Reset()
- let g:ale_fortran_gcc_options = '-Wall'
- let g:ale_fortran_gcc_use_free_form = 1
- let g:ale_fortran_gcc_executable = 'gcc'
+ call ale#assert#TearDownLinterTest()
Execute(The fortran gcc command callback should return the correct default string):
- AssertEqual 'gcc -S -x f95 -fsyntax-only -ffree-form -Wall -',
- \ join(split(ale_linters#fortran#gcc#GetCommand(1)))
+ AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffree-form -Wall -'
Execute(The fortran gcc command callback should let you set options):
let g:ale_fortran_gcc_options = '-Wotherthings'
- AssertEqual 'gcc -S -x f95 -fsyntax-only -ffree-form -Wotherthings -',
- \ join(split(ale_linters#fortran#gcc#GetCommand(1)))
+ AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffree-form -Wotherthings -'
Execute(The fortran gcc command callback should let you use -ffixed-form):
let g:ale_fortran_gcc_use_free_form = 0
- AssertEqual 'gcc -S -x f95 -fsyntax-only -ffixed-form -Wall -',
- \ join(split(ale_linters#fortran#gcc#GetCommand(1)))
+ AssertLinter 'gcc', 'gcc -S -x f95 -fsyntax-only -ffixed-form -Wall -'
Execute(The fortran executable should be configurable):
let g:ale_fortran_gcc_executable = 'gfortran'
- AssertEqual 'gfortran', ale_linters#fortran#gcc#GetExecutable(1)
- AssertEqual 'gfortran -S -x f95 -fsyntax-only -ffree-form -Wall -',
- \ join(split(ale_linters#fortran#gcc#GetCommand(1)))
+ AssertLinter 'gfortran',
+ \ 'gfortran -S -x f95 -fsyntax-only -ffree-form -Wall -'
diff --git a/test/command_callback/test_gitlint_command_callback.vader b/test/command_callback/test_gitlint_command_callback.vader
index 6ff95ea9..7927b064 100644
--- a/test/command_callback/test_gitlint_command_callback.vader
+++ b/test/command_callback/test_gitlint_command_callback.vader
@@ -1,84 +1,43 @@
Before:
- Save g:ale_gitcommit_gitlint_executable
- Save g:ale_gitcommit_gitlint_options
- Save g:ale_gitcommit_gitlint_use_global
-
- unlet! g:ale_gitcommit_gitlint_executable
- unlet! g:ale_gitcommit_gitlint_options
- unlet! g:ale_gitcommit_gitlint_use_global
-
- runtime ale_linters/gitcommit/gitlint.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('gitcommit', 'gitlint')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
- let b:command_tail = ' lint'
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
-
unlet! b:bin_dir
unlet! b:executable
+ call ale#assert#TearDownLinterTest()
+
Execute(The gitlint callbacks should return the correct default values):
- AssertEqual
- \ 'gitlint',
- \ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('gitlint') . b:command_tail,
- \ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
+ AssertLinter 'gitlint', ale#Escape('gitlint') . ' lint'
Execute(The gitlint executable should be configurable, and escaped properly):
let g:ale_gitcommit_gitlint_executable = 'executable with spaces'
- AssertEqual
- \ 'executable with spaces',
- \ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('executable with spaces') . b:command_tail,
- \ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
+ AssertLinter 'executable with spaces',
+ \ ale#Escape('executable with spaces') . ' lint'
Execute(The gitlint command callback should let you set options):
let g:ale_gitcommit_gitlint_options = '--some-option'
- AssertEqual
- \ ale#Escape('gitlint') . ' --some-option' . b:command_tail,
- \ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
+ AssertLinter 'gitlint', ale#Escape('gitlint') . ' --some-option lint'
Execute(The gitlint callbacks shouldn't detect virtualenv directories where they don't exist):
- silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/COMMIT_EDITMSG')
+ call ale#test#SetFilename('python_paths/no_virtualenv/subdir/foo/COMMIT_EDITMSG')
- AssertEqual
- \ 'gitlint',
- \ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('gitlint') . b:command_tail,
- \ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
+ AssertLinter 'gitlint', ale#Escape('gitlint') . ' lint'
Execute(The gitlint callbacks should detect virtualenv directories):
- silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/COMMIT_EDITMSG')
-
+ call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/COMMIT_EDITMSG')
let b:executable = ale#path#Simplify(
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/gitlint'
\)
- AssertEqual
- \ b:executable,
- \ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape(b:executable) . b:command_tail,
- \ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
+ AssertLinter b:executable, ale#Escape(b:executable) . ' lint'
Execute(You should able able to use the global gitlint instead):
- silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/COMMIT_EDITMSG')
+ call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/COMMIT_EDITMSG')
let g:ale_gitcommit_gitlint_use_global = 1
- AssertEqual
- \ 'gitlint',
- \ ale_linters#gitcommit#gitlint#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('gitlint') . b:command_tail,
- \ ale_linters#gitcommit#gitlint#GetCommand(bufnr(''))
+ AssertLinter 'gitlint', ale#Escape('gitlint') . ' lint'
diff --git a/test/command_callback/test_glslang_command_callback.vader b/test/command_callback/test_glslang_command_callback.vader
index 1b1722a4..980406af 100644
--- a/test/command_callback/test_glslang_command_callback.vader
+++ b/test/command_callback/test_glslang_command_callback.vader
@@ -1,40 +1,19 @@
Before:
- Save g:ale_glsl_glslang_executable
- Save g:ale_glsl_glslang_options
-
- unlet! g:ale_glsl_glslang_executable
- unlet! g:ale_glsl_glslang_options
-
- runtime ale_linters/glsl/glslang.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('glsl', 'glslang')
After:
- Restore
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
-Execute(Executable should default to glslangValidator):
- AssertEqual
- \ 'glslangValidator',
- \ ale_linters#glsl#glslang#GetExecutable(bufnr(''))
+Execute(The default command should be correct):
+ AssertLinter 'glslangValidator', ale#Escape('glslangValidator') . ' -C %t'
-Execute(Executable should be configurable):
- let g:ale_glsl_glslang_executable = 'foobar'
- AssertEqual
- \ 'foobar',
- \ ale_linters#glsl#glslang#GetExecutable(bufnr(''))
+Execute(The executable should be configurable):
+ let b:ale_glsl_glslang_executable = 'foobar'
-Execute(Command should use executable):
- AssertEqual
- \ 'glslangValidator -C %t',
- \ ale_linters#glsl#glslang#GetCommand(bufnr(''))
-
- let g:ale_glsl_glslang_executable = 'foobar'
- AssertEqual
- \ 'foobar -C %t',
- \ ale_linters#glsl#glslang#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' -C %t'
Execute(Options should work):
let g:ale_glsl_glslang_options = '--test'
- AssertEqual
- \ 'glslangValidator --test -C %t',
- \ ale_linters#glsl#glslang#GetCommand(bufnr(''))
+
+ AssertLinter 'glslangValidator',
+ \ ale#Escape('glslangValidator') . ' --test -C %t'
diff --git a/test/command_callback/test_glslls_command_callback.vader b/test/command_callback/test_glslls_command_callback.vader
index e64c2352..133c2a2f 100644
--- a/test/command_callback/test_glslls_command_callback.vader
+++ b/test/command_callback/test_glslls_command_callback.vader
@@ -1,37 +1,19 @@
Before:
- Save g:ale_glsl_glslls_executable
- Save g:ale_glsl_glslls_logfile
-
- unlet! g:ale_glsl_glslls_executable
- unlet! g:ale_glsl_glslls_logfile
-
- runtime ale_linters/glsl/glslls.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('glsl', 'glslls')
After:
- Restore
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
-Execute(Executable should default to 'glslls'):
- AssertEqual
- \ 'glslls',
- \ ale_linters#glsl#glslls#GetExecutable(bufnr(''))
+Execute(The default command should be correct):
+ AssertLinter 'glslls', ale#Escape('glslls') . ' --stdin'
Execute(Executable should be configurable):
- let g:ale_glsl_glslls_executable = 'foobar'
- AssertEqual
- \ 'foobar',
- \ ale_linters#glsl#glslls#GetExecutable(bufnr(''))
+ let b:ale_glsl_glslls_executable = 'foobar'
-Execute(Command should use executable):
- let command1 = ale_linters#glsl#glslls#GetCommand(bufnr(''))
- AssertEqual command1, ale#Escape('glslls') . ' --stdin'
-
- let g:ale_glsl_glslls_executable = 'foobar'
- let command2 = ale_linters#glsl#glslls#GetCommand(bufnr(''))
- AssertEqual command2, ale#Escape('foobar') . ' --stdin'
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin'
Execute(Setting logfile should work):
- let g:ale_glsl_glslls_logfile = '/tmp/test.log'
- let command = ale_linters#glsl#glslls#GetCommand(bufnr(''))
- AssertEqual command, ale#Escape('glslls') . ' --verbose -l /tmp/test.log --stdin'
+ let b:ale_glsl_glslls_logfile = '/tmp/test.log'
+
+ AssertLinter 'glslls',
+ \ ale#Escape('glslls') . ' --verbose -l /tmp/test.log --stdin'
diff --git a/test/command_callback/test_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader
index 240f29c6..86113728 100644
--- a/test/command_callback/test_gobuild_command_callback.vader
+++ b/test/command_callback/test_gobuild_command_callback.vader
@@ -1,52 +1,36 @@
Before:
- Save g:ale_go_gobuild_options
-
- unlet! g:ale_go_gobuild_options
+ call ale#assert#SetUpLinterTest('go', 'gobuild')
let g:env_prefix = has('win32')
\ ? 'set GOPATH=' . ale#Escape('/foo/bar') . ' && '
\ : 'GOPATH=' . ale#Escape('/foo/bar') . ' '
-
- runtime ale_linters/go/gobuild.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
call ale_linters#go#gobuild#ResetEnv()
-After:
- Restore
+ WithChainResults ['/foo/bar', '/foo/baz']
+After:
unlet! g:env_prefix
+ call ale#assert#TearDownLinterTest()
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
-
-Execute(The default gobuild command should be correct):
- AssertEqual
- \ ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz']),
+Execute(The default commands should be correct):
+ AssertLinter 'go', [
+ \ 'go env GOPATH GOROOT',
\ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'go test -c -o /dev/null ./'
-
-Execute(The command for getting GOPATH should be correct):
- AssertEqual ale_linters#go#gobuild#GoEnv(bufnr('')), 'go env GOPATH GOROOT'
-
- call ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz'])
+ \]
" We shouldn't run `go env` many times after we've got it.
- AssertEqual ale_linters#go#gobuild#GoEnv(bufnr('')), ''
-
-Execute(The GOPATH output should be used after it has been read once):
- call ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz'])
-
- AssertEqual
- \ ale_linters#go#gobuild#GetCommand(bufnr(''), []),
+ AssertLinter 'go', [
+ \ '',
\ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'go test -c -o /dev/null ./'
+ \]
Execute(Extra options should be supported):
let g:ale_go_gobuild_options = '--foo-bar'
- AssertEqual
- \ ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz']),
+ AssertLinter 'go', [
+ \ 'go env GOPATH GOROOT',
\ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'go test --foo-bar -c -o /dev/null ./'
+ \]
diff --git a/test/command_callback/test_gometalinter_command_callback.vader b/test/command_callback/test_gometalinter_command_callback.vader
index 93a541c8..d788c5bd 100644
--- a/test/command_callback/test_gometalinter_command_callback.vader
+++ b/test/command_callback/test_gometalinter_command_callback.vader
@@ -1,61 +1,38 @@
Before:
- Save b:ale_go_gometalinter_executable
- Save b:ale_go_gometalinter_options
- Save b:ale_go_gometalinter_lint_package
-
- let b:ale_go_gometalinter_executable = 'gometalinter'
- let b:ale_go_gometalinter_options = ''
- let b:ale_go_gometalinter_lint_package = 0
-
- runtime ale_linters/go/gometalinter.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('go', 'gometalinter')
call ale#test#SetFilename('test.go')
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
-Execute(The gometalinter callback should return the right defaults):
- AssertEqual
- \ 'gometalinter',
- \ ale_linters#go#gometalinter#GetExecutable(bufnr(''))
- AssertEqual
+Execute(The gometalinter defaults should be correct):
+ AssertLinter 'gometalinter',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
- \ . ' .',
- \ ale_linters#go#gometalinter#GetCommand(bufnr(''))
+ \ . ' .'
Execute(The gometalinter callback should use a configured executable):
let b:ale_go_gometalinter_executable = 'something else'
- AssertEqual
- \ 'something else',
- \ ale_linters#go#gometalinter#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'something else',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('something else')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
- \ . ' .',
- \ ale_linters#go#gometalinter#GetCommand(bufnr(''))
+ \ . ' .'
Execute(The gometalinter callback should use configured options):
let b:ale_go_gometalinter_options = '--foobar'
- AssertEqual
+ AssertLinter 'gometalinter',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
- \ . ' --foobar' . ' .',
- \ ale_linters#go#gometalinter#GetCommand(bufnr(''))
+ \ . ' --foobar' . ' .'
Execute(The gometalinter `lint_package` option should use the correct command):
let b:ale_go_gometalinter_lint_package = 1
- AssertEqual
+ AssertLinter 'gometalinter',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
- \ . ale#Escape('gometalinter') . ' .',
- \ ale_linters#go#gometalinter#GetCommand(bufnr(''))
+ \ . ale#Escape('gometalinter') . ' .'
diff --git a/test/command_callback/test_gosimple_command_callback.vader b/test/command_callback/test_gosimple_command_callback.vader
index a0b1f468..7b8c66ae 100644
--- a/test/command_callback/test_gosimple_command_callback.vader
+++ b/test/command_callback/test_gosimple_command_callback.vader
@@ -1,12 +1,10 @@
Before:
- runtime ale_linters/go/gosimple.vim
+ call ale#assert#SetUpLinterTest('go', 'gosimple')
call ale#test#SetFilename('../go_files/testfile2.go')
After:
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default gosimple command should be correct):
- AssertEqual 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
- \ . ' gosimple .',
- \ ale_linters#go#gosimple#GetCommand(bufnr(''))
-
+ AssertLinter 'gosimple',
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && gosimple .'
diff --git a/test/command_callback/test_gotype_command_callback.vader b/test/command_callback/test_gotype_command_callback.vader
index 4fba3344..da9ceaf3 100644
--- a/test/command_callback/test_gotype_command_callback.vader
+++ b/test/command_callback/test_gotype_command_callback.vader
@@ -1,15 +1,15 @@
Before:
- runtime ale_linters/go/gotype.vim
+ call ale#assert#SetUpLinterTest('go', 'gotype')
call ale#test#SetFilename('../go_files/testfile2.go')
After:
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default gotype command should be correct):
- AssertEqual 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
- \ . ' gotype .',
- \ ale_linters#go#gotype#GetCommand(bufnr(''))
+ AssertLinter 'gotype',
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && gotype .'
Execute(The gotype callback should ignore test files):
call ale#test#SetFilename('bla_test.go')
- AssertEqual 0, ale_linters#go#gotype#GetCommand(bufnr(''))
+
+ AssertLinter 'gotype', ''
diff --git a/test/command_callback/test_govet_command_callback.vader b/test/command_callback/test_govet_command_callback.vader
index a9b29605..a73118ae 100644
--- a/test/command_callback/test_govet_command_callback.vader
+++ b/test/command_callback/test_govet_command_callback.vader
@@ -1,16 +1,8 @@
Before:
- runtime ale_linters/go/govet.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('go', 'govet')
After:
- Restore
-
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual
- \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
- \ . ' go vet .',
- \ ale_linters#go#govet#GetCommand(bufnr(''))
+ AssertLinter 'go', 'cd ' . ale#Escape(expand('%:p:h')) . ' && go vet .'
diff --git a/test/command_callback/test_haml_hamllint_command_callback.vader b/test/command_callback/test_haml_hamllint_command_callback.vader
index 0d9b1e06..a59446ca 100644
--- a/test/command_callback/test_haml_hamllint_command_callback.vader
+++ b/test/command_callback/test_haml_hamllint_command_callback.vader
@@ -1,72 +1,37 @@
Before:
- runtime ale_linters/haml/hamllint.vim
+ call ale#assert#SetUpLinterTest('haml', 'hamllint')
let g:default_command = 'haml-lint %t'
- call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
- Restore
-
- unlet! g:default_command
unlet! b:conf
+ unlet! b:conf_hamllint
+ unlet! b:conf_rubocop
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual g:default_command, ale_linters#haml#hamllint#GetCommand(bufnr(''))
+ AssertLinter 'haml-lint', 'haml-lint %t'
Execute(The command should have the .rubocop.yml prepended as an env var if one exists):
call ale#test#SetFilename('../hamllint-test-files/rubocop-yml/subdir/file.haml')
let b:conf = ale#path#Simplify(g:dir . '/../hamllint-test-files/rubocop-yml/.rubocop.yml')
- if has('win32')
- " Windows uses 'set var=... && command'
- AssertEqual
- \ 'set HAML_LINT_RUBOCOP_CONF='
- \ . ale#Escape(b:conf)
- \ . ' && ' . g:default_command,
- \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
- else
- " Unix uses 'var=... command'
- AssertEqual
- \ 'HAML_LINT_RUBOCOP_CONF='
- \ . ale#Escape(b:conf)
- \ . ' ' . g:default_command,
- \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
- endif
+ AssertLinter 'haml-lint',
+ \ ale#Env('HAML_LINT_RUBOCOP_CONF', b:conf) . 'haml-lint %t'
Execute(The command should have the nearest .haml-lint.yml set as --config if it exists):
call ale#test#SetFilename('../hamllint-test-files/haml-lint-yml/subdir/file.haml')
let b:conf = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-yml/.haml-lint.yml')
- AssertEqual
- \ 'haml-lint --config '
- \ . ale#Escape(b:conf)
- \ . ' %t',
- \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
+ AssertLinter 'haml-lint',
+ \ 'haml-lint --config ' . ale#Escape(b:conf) . ' %t',
Execute(The command should include a .rubocop.yml and a .haml-lint if both are found):
call ale#test#SetFilename('../hamllint-test-files/haml-lint-and-rubocop/subdir/file.haml')
let b:conf_hamllint = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-and-rubocop/.haml-lint.yml')
let b:conf_rubocop = ale#path#Simplify(g:dir . '/../hamllint-test-files/haml-lint-and-rubocop/.rubocop.yml')
- if has('win32')
- " Windows uses 'set var=... && command'
- AssertEqual
- \ 'set HAML_LINT_RUBOCOP_CONF='
- \ . ale#Escape(b:conf_rubocop)
- \ . ' && haml-lint --config '
- \ . ale#Escape(b:conf_hamllint)
- \ . ' %t',
- \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
- else
- " Unix uses 'var=... command'
- AssertEqual
- \ 'HAML_LINT_RUBOCOP_CONF='
- \ . ale#Escape(b:conf_rubocop)
- \ . ' haml-lint --config '
- \ . ale#Escape(b:conf_hamllint)
- \ . ' %t',
- \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
- endif
+ AssertLinter 'haml-lint',
+ \ ale#Env('HAML_LINT_RUBOCOP_CONF', b:conf_rubocop)
+ \ . 'haml-lint --config ' . ale#Escape(b:conf_hamllint) . ' %t'
diff --git a/test/command_callback/test_haskell_ghc_command_callbacks.vader b/test/command_callback/test_haskell_ghc_command_callbacks.vader
index edaf2b98..2f33477d 100644
--- a/test/command_callback/test_haskell_ghc_command_callbacks.vader
+++ b/test/command_callback/test_haskell_ghc_command_callbacks.vader
@@ -1,23 +1,12 @@
Before:
- Save g:ale_haskell_ghc_options
-
- unlet! g:ale_haskell_ghc_options
- unlet! b:ale_haskell_ghc_options
-
- runtime ale_linters/haskell/ghc.vim
+ call ale#assert#SetUpLinterTest('haskell', 'ghc')
After:
- Restore
- unlet! b:ale_haskell_ghc_options
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The options should be used in the command):
- AssertEqual
- \ 'ghc -fno-code -v0 %t',
- \ ale_linters#haskell#ghc#GetCommand(bufnr(''))
+ AssertLinter 'ghc', 'ghc -fno-code -v0 %t'
let b:ale_haskell_ghc_options = 'foobar'
- AssertEqual
- \ 'ghc foobar %t',
- \ ale_linters#haskell#ghc#GetCommand(bufnr(''))
+ AssertLinter 'ghc', 'ghc foobar %t'
diff --git a/test/command_callback/test_haskell_hdevtools_command_callbacks.vader b/test/command_callback/test_haskell_hdevtools_command_callbacks.vader
index c5320c5c..0ef2f0e3 100644
--- a/test/command_callback/test_haskell_hdevtools_command_callbacks.vader
+++ b/test/command_callback/test_haskell_hdevtools_command_callbacks.vader
@@ -1,37 +1,16 @@
Before:
- Save g:ale_haskell_hdevtools_executable
- Save g:ale_haskell_hdevtools_options
-
- unlet! g:ale_haskell_hdevtools_executable
- unlet! b:ale_haskell_hdevtools_executable
- unlet! g:ale_haskell_hdevtools_options
- unlet! b:ale_haskell_hdevtools_options
-
- runtime ale_linters/haskell/hdevtools.vim
+ call ale#assert#SetUpLinterTest('haskell', 'hdevtools')
let b:command_tail = ' check -g -Wall -p %s %t'
After:
- Restore
unlet! b:command_tail
- unlet! b:ale_haskell_hdevtools_executable
- unlet! b:ale_haskell_hdevtools_options
- call ale#linter#Reset()
-Execute(The executable should be configurable):
- AssertEqual 'hdevtools', ale_linters#haskell#hdevtools#GetExecutable(bufnr(''))
+ call ale#assert#TearDownLinterTest()
- let b:ale_haskell_hdevtools_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#haskell#hdevtools#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('hdevtools') . b:command_tail,
- \ ale_linters#haskell#hdevtools#GetCommand(bufnr(''))
+Execute(The executable should be configurable):
+ AssertLinter 'hdevtools', ale#Escape('hdevtools') . b:command_tail
let b:ale_haskell_hdevtools_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . b:command_tail,
- \ ale_linters#haskell#hdevtools#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
diff --git a/test/command_callback/test_htmlhint_command_callback.vader b/test/command_callback/test_htmlhint_command_callback.vader
index 5bb21a6b..d3f209f8 100644
--- a/test/command_callback/test_htmlhint_command_callback.vader
+++ b/test/command_callback/test_htmlhint_command_callback.vader
@@ -1,71 +1,51 @@
Before:
- Save g:ale_html_htmlhint_options
- Save g:ale_html_htmlhint_executable
- Save g:ale_html_htmlhint_use_global
-
- unlet! g:ale_html_htmlhint_options
- unlet! g:ale_html_htmlhint_executable
- unlet! g:ale_html_htmlhint_use_global
-
- runtime ale_linters/html/htmlhint.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('html', 'htmlhint')
call ale#test#SetFilename('htmlhint_paths/test.html')
let g:node_executable = ale#path#Simplify(
- \ g:dir
- \ . '/htmlhint_paths/node_modules/.bin/htmlhint'
+ \ g:dir . '/htmlhint_paths/node_modules/.bin/htmlhint'
\)
let g:config_path = ale#path#Simplify(
- \ g:dir
- \ . '/htmlhint_paths/with_config/.htmlhintrc'
+ \ g:dir . '/htmlhint_paths/with_config/.htmlhintrc'
\)
After:
- Restore
-
unlet! g:node_executable
unlet! g:config_path
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual
- \ ale#Escape(g:node_executable) . ' --format=unix %t',
- \ ale_linters#html#htmlhint#GetCommand(bufnr(''))
+ AssertLinter g:node_executable,
+ \ ale#Escape(g:node_executable) . ' --format=unix %t'
Execute(The global executable should be uesd if the option is set):
let g:ale_html_htmlhint_executable = 'foo'
let g:ale_html_htmlhint_use_global = 1
- AssertEqual
- \ ale#Escape('foo') . ' --format=unix %t',
- \ ale_linters#html#htmlhint#GetCommand(bufnr(''))
+ AssertLinter 'foo', ale#Escape('foo') . ' --format=unix %t',
" This is so old configurations which might include this still work.
Execute(--format=unix should be removed from the options if added):
let g:ale_html_htmlhint_options = '--format=unix'
- AssertEqual
- \ ale#Escape(g:node_executable) . ' --format=unix %t',
- \ ale_linters#html#htmlhint#GetCommand(bufnr(''))
+ AssertLinter g:node_executable,
+ \ ale#Escape(g:node_executable) . ' --format=unix %t'
Execute(The configuration file should be automatically detected):
call ale#test#SetFilename('htmlhint_paths/with_config/test.html')
- AssertEqual
+ AssertLinter g:node_executable,
\ ale#Escape(g:node_executable)
\ . ' --config ' . ale#Escape(g:config_path)
- \ . ' --format=unix %t',
- \ ale_linters#html#htmlhint#GetCommand(bufnr(''))
+ \ . ' --format=unix %t'
" This is so old configurations which might include the config will work.
Execute(The configuration file should be configurable through the options variable):
call ale#test#SetFilename('htmlhint_paths/with_config/test.html')
let g:ale_html_htmlhint_options = '--config=/foo/bar/.htmlhintrc'
- AssertEqual
+ AssertLinter g:node_executable,
\ ale#Escape(g:node_executable)
\ . ' --config=/foo/bar/.htmlhintrc'
- \ . ' --format=unix %t',
- \ ale_linters#html#htmlhint#GetCommand(bufnr(''))
+ \ . ' --format=unix %t'
diff --git a/test/command_callback/test_idris_command_callbacks.vader b/test/command_callback/test_idris_command_callbacks.vader
index 03a69f39..ce7cd270 100644
--- a/test/command_callback/test_idris_command_callbacks.vader
+++ b/test/command_callback/test_idris_command_callbacks.vader
@@ -1,42 +1,21 @@
Before:
- Save g:ale_idris_idris_executable
- Save g:ale_idris_idris_options
-
- unlet! g:ale_idris_idris_executable
- unlet! b:ale_idris_idris_executable
- unlet! g:ale_idris_idris_options
- unlet! b:ale_idris_idris_options
-
- runtime ale_linters/idris/idris.vim
+ call ale#assert#SetUpLinterTest('idris', 'idris')
After:
- Restore
unlet! b:command_tail
- unlet! b:ale_idris_idris_executable
- unlet! b:ale_idris_idris_options
- call ale#linter#Reset()
-
-Execute(The executable should be configurable):
- AssertEqual 'idris', ale_linters#idris#idris#GetExecutable(bufnr(''))
-
- let b:ale_idris_idris_executable = 'foobar'
- AssertEqual 'foobar', ale_linters#idris#idris#GetExecutable(bufnr(''))
+ call ale#assert#TearDownLinterTest()
Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('idris') . ' --total --warnpartial --warnreach --warnipkg --check %s',
- \ ale_linters#idris#idris#GetCommand(bufnr(''))
+ AssertLinter 'idris',
+ \ ale#Escape('idris') . ' --total --warnpartial --warnreach --warnipkg --check %s'
let b:ale_idris_idris_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . ' --total --warnpartial --warnreach --warnipkg --check %s',
- \ ale_linters#idris#idris#GetCommand(bufnr(''))
+ AssertLinter 'foobar',
+ \ ale#Escape('foobar') . ' --total --warnpartial --warnreach --warnipkg --check %s'
Execute(The options should be configurable):
let b:ale_idris_idris_options = '--something'
- AssertEqual
- \ ale#Escape('idris') . ' --something --check %s',
- \ ale_linters#idris#idris#GetCommand(bufnr(''))
+ AssertLinter 'idris', ale#Escape('idris') . ' --something --check %s'
diff --git a/test/command_callback/test_iverilog_command_callback.vader b/test/command_callback/test_iverilog_command_callback.vader
index 2c633178..d7a29f05 100644
--- a/test/command_callback/test_iverilog_command_callback.vader
+++ b/test/command_callback/test_iverilog_command_callback.vader
@@ -1,24 +1,14 @@
Before:
- Save g:ale_verilog_iverilog_options
-
- unlet! g:ale_verilog_iverilog_options
-
- runtime ale_linters/verilog/iverilog.vim
+ call ale#assert#SetUpLinterTest('verilog', 'iverilog')
After:
- Restore
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default iverilog command should be correct):
- AssertEqual
- \ 'iverilog -t null -Wall %t',
- \ ale_linters#verilog#iverilog#GetCommand(bufnr(''))
+ AssertLinter 'iverilog', 'iverilog -t null -Wall %t'
Execute(iverilog options should be configurable):
" Additional args for the linter
let g:ale_verilog_iverilog_options = '-y.'
- AssertEqual
- \ 'iverilog -t null -Wall -y. %t',
- \ ale_linters#verilog#iverilog#GetCommand(bufnr(''))
+ AssertLinter 'iverilog', 'iverilog -t null -Wall -y. %t'
diff --git a/test/command_callback/test_javac_command_callback.vader b/test/command_callback/test_javac_command_callback.vader
index b0d0e7c7..07a0794a 100644
--- a/test/command_callback/test_javac_command_callback.vader
+++ b/test/command_callback/test_javac_command_callback.vader
@@ -1,15 +1,10 @@
Before:
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
- Save g:ale_java_javac_executable
- Save g:ale_java_javac_options
- Save g:ale_java_javac_classpath
-
- unlet! g:ale_java_javac_executable
- unlet! g:ale_java_javac_options
- unlet! g:ale_java_javac_classpath
+ call ale#assert#SetUpLinterTest('java', 'javac')
+ call ale#test#SetFilename('dummy.java')
let g:cp_sep = has('unix') ? ':' : ';'
+ let g:prefix = 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
+ \ . ale#Escape('javac') . ' -Xlint'
function! GetCommand(previous_output) abort
let l:command = ale_linters#java#javac#GetCommand(
@@ -25,69 +20,58 @@ Before:
return join(l:split_command)
endfunction
- runtime ale_linters/java/javac.vim
- call ale#engine#InitBufferInfo(bufnr(''))
-
- call ale#test#SetFilename('dummy.java')
-
- let g:prefix = 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
- \ . ale#Escape('javac') . ' -Xlint'
-
After:
- call ale#test#RestoreDirectory()
-
- Restore
-
unlet! g:cp_sep
unlet! g:prefix
delfunction GetCommand
- call ale#linter#Reset()
- " We need to clean up the buffer to remove the temporary directories created
- " for the command.
- call ale#engine#Cleanup(bufnr(''))
+ call ale#assert#TearDownLinterTest()
Execute(The javac callback should return the correct default value):
- AssertEqual g:prefix . ' -d TEMP %t', GetCommand([])
+ AssertLinter 'javac', g:prefix . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should use g:ale_java_javac_classpath correctly):
let g:ale_java_javac_classpath = 'foo.jar'
- AssertEqual
+ AssertLinter 'javac',
\ g:prefix
\ . ' -cp ' . ale#Escape('foo.jar')
- \ . ' -d TEMP %t',
- \ GetCommand([])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The executable should be configurable):
let g:ale_java_javac_executable = 'foobar'
- AssertEqual 'foobar', ale_linters#java#javac#GetExecutable(bufnr(''))
-
- AssertEqual
+ AssertLinter 'foobar',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('foobar') . ' -Xlint'
- \ . ' -d TEMP %t',
- \ GetCommand([])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should include discovered classpaths):
- AssertEqual
+ WithChainResults [
+ \ '[DEBUG] Ignore this.',
+ \ '[INFO] Something we should ignore.',
+ \ '/foo/bar.jar',
+ \ '/xyz/abc.jar',
+ \]
+
+ AssertLinter 'javac',
\ g:prefix
\ . ' -cp '
\ . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep))
- \ . ' -d TEMP %t',
- \ GetCommand([
- \ '[DEBUG] Ignore this.',
- \ '[INFO] Something we should ignore.',
- \ '/foo/bar.jar',
- \ '/xyz/abc.jar',
- \ ])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should combine discovered classpaths and manual ones):
let g:ale_java_javac_classpath = 'configured.jar'
- AssertEqual
+ WithChainResults [
+ \ '[DEBUG] Ignore this.',
+ \ '[INFO] Something we should ignore.',
+ \ '/foo/bar.jar',
+ \ '/xyz/abc.jar',
+ \]
+
+ AssertLinter 'javac',
\ g:prefix
\ . ' -cp '
\ . ale#Escape(join(
@@ -98,17 +82,11 @@ Execute(The javac callback should combine discovered classpaths and manual ones)
\ ],
\ g:cp_sep
\ ))
- \ . ' -d TEMP %t',
- \ GetCommand([
- \ '[DEBUG] Ignore this.',
- \ '[INFO] Something we should ignore.',
- \ '/foo/bar.jar',
- \ '/xyz/abc.jar',
- \ ])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
let g:ale_java_javac_classpath = 'configured.jar' . g:cp_sep . 'configured2.jar'
- AssertEqual
+ AssertLinter 'javac',
\ g:prefix
\ . ' -cp '
\ . ale#Escape(join(
@@ -120,55 +98,46 @@ Execute(The javac callback should combine discovered classpaths and manual ones)
\ ],
\ g:cp_sep
\ ))
- \ . ' -d TEMP %t',
- \ GetCommand([
- \ '[DEBUG] Ignore this.',
- \ '[INFO] Something we should ignore.',
- \ '/foo/bar.jar',
- \ '/xyz/abc.jar',
- \ ])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should detect source directories):
call ale#engine#Cleanup(bufnr(''))
noautocmd e! java_paths/src/main/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr(''))
- AssertEqual
+ AssertLinter 'javac',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint'
\ . ' -sourcepath ' . ale#Escape(
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/')
\ )
- \ . ' -d TEMP %t',
- \ GetCommand([])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should combine detected source directories and classpaths):
call ale#engine#Cleanup(bufnr(''))
call ale#test#SetFilename('java_paths/src/main/java/com/something/dummy.java')
call ale#engine#InitBufferInfo(bufnr(''))
- AssertEqual
+ WithChainResults [
+ \ '[DEBUG] Ignore this.',
+ \ '[INFO] Something we should ignore.',
+ \ '/foo/bar.jar',
+ \ '/xyz/abc.jar',
+ \]
+ AssertLinter 'javac',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint'
\ . ' -cp ' . ale#Escape(join(['/foo/bar.jar', '/xyz/abc.jar'], g:cp_sep))
\ . ' -sourcepath ' . ale#Escape(
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/')
\ )
- \ . ' -d TEMP %t',
- \ GetCommand([
- \ '[DEBUG] Ignore this.',
- \ '[INFO] Something we should ignore.',
- \ '/foo/bar.jar',
- \ '/xyz/abc.jar',
- \ ])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should use g:ale_java_javac_options correctly):
let g:ale_java_javac_options = '--anything --else'
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [])
- AssertEqual
- \ g:prefix
- \ . ' -d TEMP --anything --else %t',
- \ GetCommand([])
+ AssertLinter 'javac',
+ \ g:prefix . ' -d ' . ale#Escape('TEMP_DIR') . ' --anything --else %t'
Execute(The javac callback should include src/test/java for test paths):
call ale#engine#Cleanup(bufnr(''))
@@ -177,25 +146,23 @@ Execute(The javac callback should include src/test/java for test paths):
noautocmd e! java_paths/src/test/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr(''))
- AssertEqual
+ AssertLinter 'javac',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint'
\ . ' -sourcepath ' . ale#Escape(join([
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/'),
\ ale#path#Simplify(g:dir . '/java_paths/src/test/java/'),
\ ], g:cp_sep))
- \ . ' -d TEMP %t',
- \ GetCommand([])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should include src/main/jaxb when available):
call ale#engine#Cleanup(bufnr(''))
noautocmd e! java_paths_with_jaxb/src/main/java/com/something/dummy
call ale#engine#InitBufferInfo(bufnr(''))
- AssertEqual
+ AssertLinter 'javac',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' . ale#Escape('javac') . ' -Xlint'
\ . ' -sourcepath ' . ale#Escape(join([
\ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/java/'),
\ ale#path#Simplify(g:dir . '/java_paths_with_jaxb/src/main/jaxb/'),
\ ], g:cp_sep))
- \ . ' -d TEMP %t',
- \ GetCommand([])
+ \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
diff --git a/test/command_callback/test_jscs_command_callback.vader b/test/command_callback/test_jscs_command_callback.vader
index f118c039..7cdf5467 100644
--- a/test/command_callback/test_jscs_command_callback.vader
+++ b/test/command_callback/test_jscs_command_callback.vader
@@ -1,25 +1,15 @@
Before:
- runtime ale_linters/javascript/jscs.vim
+ call ale#assert#SetUpLinterTest('javascript', 'jscs')
After:
- call ale#linter#Reset()
- let g:ale_javascript_jscs_executable = 'jscs'
+ call ale#assert#TearDownLinterTest()
Execute(Should return the correct default values):
- AssertEqual
- \ 'jscs',
- \ ale_linters#javascript#jscs#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('jscs') . ' --reporter inline --no-colors -',
- \ ale_linters#javascript#jscs#GetCommand(bufnr(''))
-
+ AssertLinter 'jscs',
+ \ ale#Escape('jscs') . ' --reporter inline --no-colors -'
Execute(Should allow using a custom executable):
let g:ale_javascript_jscs_executable = 'foobar'
- AssertEqual
- \ 'foobar',
- \ ale_linters#javascript#jscs#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('foobar') . ' --reporter inline --no-colors -',
- \ ale_linters#javascript#jscs#GetCommand(bufnr(''))
+ AssertLinter 'foobar',
+ \ ale#Escape('foobar') . ' --reporter inline --no-colors -'
diff --git a/test/command_callback/test_less_stylelint_command_callback.vader b/test/command_callback/test_less_stylelint_command_callback.vader
index a5912ecf..8d23deb6 100644
--- a/test/command_callback/test_less_stylelint_command_callback.vader
+++ b/test/command_callback/test_less_stylelint_command_callback.vader
@@ -1,31 +1,10 @@
Before:
- Save g:ale_less_stylelint_executable
- Save g:ale_less_stylelint_use_global
- Save g:ale_less_stylelint_options
-
+ call ale#assert#SetUpLinterTest('less', 'stylelint')
unlet! b:executable
- unlet! g:ale_less_stylelint_executable
- unlet! g:ale_less_stylelint_use_global
- unlet! g:ale_less_stylelint_options
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
- call ale#test#SetFilename('testfile.less')
-
- runtime ale_linters/less/stylelint.vim
-
After:
- Restore
-
unlet! b:executable
- unlet! b:ale_less_stylelint_executable
- unlet! b:ale_less_stylelint_use_global
- unlet! b:ale_less_stylelint_options
-
- call ale#test#SetFilename('test.txt')
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(node_modules directories should be discovered):
call ale#test#SetFilename('stylelint_paths/nested/testfile.less')
@@ -35,10 +14,7 @@ Execute(node_modules directories should be discovered):
\ . '/stylelint_paths/node_modules/.bin/stylelint'
\)
- AssertEqual b:executable, ale_linters#less#stylelint#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape(b:executable) . ' --stdin-filename %s',
- \ ale_linters#less#stylelint#GetCommand(bufnr(''))
+ AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin-filename %s'
Execute(The global override should work):
let b:ale_less_stylelint_executable = 'foobar'
@@ -46,15 +22,10 @@ Execute(The global override should work):
call ale#test#SetFilename('stylelint_paths/nested/testfile.less')
- AssertEqual 'foobar', ale_linters#less#stylelint#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('foobar') . ' --stdin-filename %s',
- \ ale_linters#less#stylelint#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin-filename %s'
Execute(Extra options should be configurable):
let b:ale_less_stylelint_options = '--whatever'
- AssertEqual 'stylelint', ale_linters#less#stylelint#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('stylelint') . ' --whatever --stdin-filename %s',
- \ ale_linters#less#stylelint#GetCommand(bufnr(''))
+ AssertLinter 'stylelint',
+ \ ale#Escape('stylelint') . ' --whatever --stdin-filename %s'
diff --git a/test/command_callback/test_lessc_command_callback.vader b/test/command_callback/test_lessc_command_callback.vader
index ec2899d1..79f57d06 100644
--- a/test/command_callback/test_lessc_command_callback.vader
+++ b/test/command_callback/test_lessc_command_callback.vader
@@ -1,31 +1,13 @@
Before:
- Save g:ale_less_lessc_executable
- Save g:ale_less_lessc_use_global
- Save g:ale_less_lessc_options
-
- unlet! b:executable
-
- unlet! g:ale_less_lessc_executable
- unlet! g:ale_less_lessc_use_global
- unlet! g:ale_less_lessc_options
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('less', 'lessc')
call ale#test#SetFilename('testfile.less')
- runtime ale_linters/less/lessc.vim
+ unlet! b:executable
After:
- Restore
-
unlet! b:executable
- unlet! b:ale_less_lessc_executable
- unlet! b:ale_less_lessc_use_global
- unlet! b:ale_less_lessc_options
-
- call ale#test#SetFilename('test.txt')
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(node_modules directories should be discovered):
call ale#test#SetFilename('lessc_paths/nested/testfile.less')
@@ -35,17 +17,11 @@ Execute(node_modules directories should be discovered):
\ . '/lessc_paths/node_modules/.bin/lessc'
\)
- AssertEqual
- \ b:executable,
- \ ale_linters#less#lessc#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape(b:executable)
- \ . ' --no-color --lint'
- \ . ' --include-path='
- \ . ale#Escape(ale#path#Simplify(g:dir . '/lessc_paths/nested'))
- \ . ' -',
- \ ale_linters#less#lessc#GetCommand(bufnr(''))
+ AssertLinter b:executable, ale#Escape(b:executable)
+ \ . ' --no-color --lint'
+ \ . ' --include-path='
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/lessc_paths/nested'))
+ \ . ' -'
Execute(The global override should work):
let b:ale_less_lessc_executable = 'foobar'
@@ -53,30 +29,18 @@ Execute(The global override should work):
call ale#test#SetFilename('lessc_paths/nested/testfile.less')
- AssertEqual
- \ 'foobar',
- \ ale_linters#less#lessc#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape('foobar')
- \ . ' --no-color --lint'
- \ . ' --include-path='
- \ . ale#Escape(ale#path#Simplify(g:dir . '/lessc_paths/nested'))
- \ . ' -',
- \ ale_linters#less#lessc#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar')
+ \ . ' --no-color --lint'
+ \ . ' --include-path='
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/lessc_paths/nested'))
+ \ . ' -'
Execute(Extra options should be configurable):
let b:ale_less_lessc_options = '--whatever'
- AssertEqual
- \ 'lessc',
- \ ale_linters#less#lessc#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape('lessc')
- \ . ' --no-color --lint'
- \ . ' --include-path='
- \ . ale#Escape(ale#path#Simplify(g:dir))
- \ . ' --whatever'
- \ . ' -',
- \ ale_linters#less#lessc#GetCommand(bufnr(''))
+ AssertLinter 'lessc', ale#Escape('lessc')
+ \ . ' --no-color --lint'
+ \ . ' --include-path='
+ \ . ale#Escape(ale#path#Simplify(g:dir))
+ \ . ' --whatever'
+ \ . ' -'
diff --git a/test/command_callback/test_lintr_command_callback.vader b/test/command_callback/test_lintr_command_callback.vader
index 2f7dfb1d..8a0e6c1c 100644
--- a/test/command_callback/test_lintr_command_callback.vader
+++ b/test/command_callback/test_lintr_command_callback.vader
@@ -1,48 +1,36 @@
Before:
- Save g:ale_r_lintr_options
-
- unlet! g:ale_r_lintr_options
- unlet! b:ale_r_lintr_options
-
- runtime ale_linters/r/lintr.vim
+ call ale#assert#SetUpLinterTest('r', 'lintr')
After:
- Restore
-
- unlet! b:ale_r_lintr_options
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default lintr command should be correct):
- AssertEqual
+ AssertLinter 'Rscript',
\ 'cd ' . ale#Escape(getcwd()) . ' && '
\ . 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
- \ . 'lint(cache = FALSE, commandArgs(TRUE), '
- \ . 'with_defaults())')
- \ . ' %t',
- \ ale_linters#r#lintr#GetCommand(bufnr(''))
+ \ . 'lint(cache = FALSE, commandArgs(TRUE), '
+ \ . 'with_defaults())')
+ \ . ' %t'
Execute(The lintr options should be configurable):
let b:ale_r_lintr_options = 'with_defaults(object_usage_linter = NULL)'
- AssertEqual
+ AssertLinter 'Rscript',
\ 'cd ' . ale#Escape(getcwd()) . ' && '
\ . 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
- \ . 'lint(cache = FALSE, commandArgs(TRUE), '
- \ . 'with_defaults(object_usage_linter = NULL))')
- \ . ' %t',
- \ ale_linters#r#lintr#GetCommand(bufnr(''))
+ \ . 'lint(cache = FALSE, commandArgs(TRUE), '
+ \ . 'with_defaults(object_usage_linter = NULL))')
+ \ . ' %t'
Execute(If the lint_package flag is set, lintr::lint_package should be called):
let b:ale_r_lintr_lint_package = 1
- AssertEqual
+ AssertLinter 'Rscript',
\ 'cd ' . ale#Escape(getcwd()) . ' && '
\ . 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
- \ . 'lint_package(cache = FALSE, '
- \ . 'linters = with_defaults())')
- \ . ' %t',
- \ ale_linters#r#lintr#GetCommand(bufnr(''))
+ \ . 'lint_package(cache = FALSE, '
+ \ . 'linters = with_defaults())')
+ \ . ' %t'
diff --git a/test/command_callback/test_llc_command_callback.vader b/test/command_callback/test_llc_command_callback.vader
index 296b277a..a0caaa48 100644
--- a/test/command_callback/test_llc_command_callback.vader
+++ b/test/command_callback/test_llc_command_callback.vader
@@ -1,10 +1,5 @@
Before:
- Save g:ale_llvm_llc_executable
-
- unlet! g:ale_llvm_llc_executable
- unlet! b:ale_llvm_llc_executable
-
- runtime ale_linters/llvm/llc.vim
+ call ale#assert#SetUpLinterTest('llvm', 'llc')
function! AssertHasPrefix(str, prefix) abort
let msg = printf("'%s' is expected to be prefixed with '%s'", a:str, a:prefix)
@@ -12,28 +7,15 @@ Before:
endfunction
After:
- unlet! g:ale_llvm_llc_executable
- unlet! b:ale_llvm_llc_executable
delfunction AssertHasPrefix
- Restore
-Execute(llc command is customizable):
- let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
- call AssertHasPrefix(cmd, ale#Escape('llc'))
+ call ale#assert#TearDownLinterTest()
- let g:ale_llvm_llc_executable = 'llc-5.0'
- let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
- call AssertHasPrefix(cmd, ale#Escape('llc-5.0'))
+Execute(The llc command should be customizable):
+ AssertLinter 'llc',
+ \ ale#Escape('llc') . ' -filetype=null -o=' . g:ale#util#nul_file
- let b:ale_llvm_llc_executable = 'llc-4.0'
- let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
- call AssertHasPrefix(cmd, ale#Escape('llc-4.0'))
-
-Execute(GetCommand() escapes the returned path):
- let b:ale_llvm_llc_executable = '/path/space contained/llc'
- let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
- call AssertHasPrefix(cmd, ale#Escape('/path/space contained/llc'))
+ let g:ale_llvm_llc_executable = 'llc-5.0'
-Execute(GetExecutable() does not escape the returned path):
- let b:ale_llvm_llc_executable = '/path/space contained/llc'
- AssertEqual ale_linters#llvm#llc#GetExecutable(bufnr('')), '/path/space contained/llc'
+ AssertLinter 'llc-5.0',
+ \ ale#Escape('llc-5.0') . ' -filetype=null -o=' . g:ale#util#nul_file
diff --git a/test/command_callback/test_luac_command_callback.vader b/test/command_callback/test_luac_command_callback.vader
index f9eb4d3f..8a2345ec 100644
--- a/test/command_callback/test_luac_command_callback.vader
+++ b/test/command_callback/test_luac_command_callback.vader
@@ -1,16 +1,13 @@
Before:
- runtime ale_linters/lua/luac.vim
+ call ale#assert#SetUpLinterTest('lua', 'luac')
After:
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual ale#Escape('luac') . ' -p -',
- \ join(split(ale_linters#lua#luac#GetCommand(1)))
+ AssertLinter 'luac', ale#Escape('luac') . ' -p - '
Execute(The luac executable should be configurable):
let g:ale_lua_luac_executable = 'luac.sh'
- AssertEqual 'luac.sh', ale_linters#lua#luac#GetExecutable(1)
- AssertEqual ale#Escape('luac.sh') . ' -p -',
- \ join(split(ale_linters#lua#luac#GetCommand(1)))
+ AssertLinter 'luac.sh', ale#Escape('luac.sh') . ' -p - '
diff --git a/test/command_callback/test_luacheck_command_callback.vader b/test/command_callback/test_luacheck_command_callback.vader
index 6f7f3a00..58d0cdc0 100644
--- a/test/command_callback/test_luacheck_command_callback.vader
+++ b/test/command_callback/test_luacheck_command_callback.vader
@@ -1,24 +1,23 @@
Before:
- runtime ale_linters/lua/luacheck.vim
+ call ale#assert#SetUpLinterTest('lua', 'luacheck')
After:
- call ale#linter#Reset()
- let g:ale_lua_luacheck_options = ''
- let g:ale_lua_luacheck_executable = 'luacheck'
+ call ale#assert#TearDownLinterTest()
Execute(The lua luacheck command callback should return the correct default string):
- AssertEqual ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -',
- \ join(split(ale_linters#lua#luacheck#GetCommand(1)))
+ AssertLinter 'luacheck',
+ \ ale#Escape('luacheck') . ' --formatter plain --codes --filename %s -'
Execute(The lua luacheck command callback should let you set options):
let g:ale_lua_luacheck_options = '--config filename'
- AssertEqual ale#Escape('luacheck') . ' --config filename --formatter plain --codes --filename %s -',
- \ join(split(ale_linters#lua#luacheck#GetCommand(1)))
+ AssertLinter 'luacheck',
+ \ ale#Escape('luacheck')
+ \ . ' --config filename'
+ \ . ' --formatter plain --codes --filename %s -'
Execute(The luacheck executable should be configurable):
let g:ale_lua_luacheck_executable = 'luacheck.sh'
- AssertEqual 'luacheck.sh', ale_linters#lua#luacheck#GetExecutable(1)
- AssertEqual ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -',
- \ join(split(ale_linters#lua#luacheck#GetCommand(1)))
+ AssertLinter 'luacheck.sh',
+ \ ale#Escape('luacheck.sh') . ' --formatter plain --codes --filename %s -'
diff --git a/test/command_callback/test_markdown_mdl_command_callback.vader b/test/command_callback/test_markdown_mdl_command_callback.vader
index 2fb9a206..e029bf9b 100644
--- a/test/command_callback/test_markdown_mdl_command_callback.vader
+++ b/test/command_callback/test_markdown_mdl_command_callback.vader
@@ -1,35 +1,19 @@
Before:
- Save g:ale_markdown_mdl_executable
- Save g:ale_markdown_mdl_options
-
- unlet! g:ale_markdown_mdl_executable
- unlet! g:ale_markdown_mdl_options
-
- runtime ale_linters/markdown/mdl.vim
+ call ale#assert#SetUpLinterTest('markdown', 'mdl')
After:
- Restore
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual ale_linters#markdown#mdl#GetExecutable(bufnr('')), 'mdl'
- AssertEqual
- \ ale_linters#markdown#mdl#GetCommand(bufnr('')),
- \ ale#Escape('mdl')
+ AssertLinter 'mdl', ale#Escape('mdl')
Execute(The executable and options should be configurable):
let g:ale_markdown_mdl_executable = 'foo bar'
let g:ale_markdown_mdl_options = '--wat'
- AssertEqual ale_linters#markdown#mdl#GetExecutable(bufnr('')), 'foo bar'
- AssertEqual
- \ ale_linters#markdown#mdl#GetCommand(bufnr('')),
- \ ale#Escape('foo bar') . ' --wat'
+ AssertLinter 'foo bar', ale#Escape('foo bar') . ' --wat'
Execute(Setting bundle appends 'exec mdl'):
let g:ale_markdown_mdl_executable = 'path to/bundle'
- AssertEqual
- \ ale#Escape('path to/bundle') . ' exec mdl',
- \ ale_linters#markdown#mdl#GetCommand(bufnr(''))
+ AssertLinter 'path to/bundle', ale#Escape('path to/bundle') . ' exec mdl'
diff --git a/test/command_callback/test_mercury_mmc_command_callback.vader b/test/command_callback/test_mercury_mmc_command_callback.vader
index 7ebf49c3..2948e799 100644
--- a/test/command_callback/test_mercury_mmc_command_callback.vader
+++ b/test/command_callback/test_mercury_mmc_command_callback.vader
@@ -1,42 +1,25 @@
Before:
- Save g:ale_mercury_mmc_executable
- Save g:ale_mercury_mmc_options
-
- unlet! g:ale_mercury_mmc_executable
- unlet! b:ale_mercury_mmc_executable
- unlet! g:ale_mercury_mmc_options
- unlet! b:ale_mercury_mmc_options
-
- runtime ale_linters/mercury/mmc.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('mercury', 'mmc')
+ call ale#test#SetFilename('dummy')
After:
- unlet! b:ale_mercury_mmc_executable
- unlet! b:ale_mercury_mmc_options
-
- Restore
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual
+ AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr(''))
- \ . 'mmc --errorcheck-only --make --output-compile-error-lines 100 dummy',
- \
- \ ale_linters#mercury#mmc#GetCommand(bufnr(''))
+ \ . 'mmc --errorcheck-only --make --output-compile-error-lines 100 dummy'
Execute(The executable should be configurable):
let b:ale_mercury_mmc_executable = 'foo'
- AssertEqual
+
+ AssertLinter 'foo',
\ ale#path#BufferCdString(bufnr(''))
- \ . 'foo --errorcheck-only --make --output-compile-error-lines 100 dummy',
- \
- \ ale_linters#mercury#mmc#GetCommand(bufnr(''))
+ \ . 'foo --errorcheck-only --make --output-compile-error-lines 100 dummy'
Execute(The options should be configurable):
let b:ale_mercury_mmc_options = '--bar'
- AssertEqual
+
+ AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr(''))
- \ . 'mmc --errorcheck-only --bar dummy',
- \
- \ ale_linters#mercury#mmc#GetCommand(bufnr(''))
+ \ . 'mmc --errorcheck-only --bar dummy'
diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader
index 0fb4cc54..988dfb1b 100644
--- a/test/command_callback/test_mypy_command_callback.vader
+++ b/test/command_callback/test_mypy_command_callback.vader
@@ -1,106 +1,71 @@
Before:
- Save g:ale_python_mypy_executable
- Save g:ale_python_mypy_options
- Save g:ale_python_mypy_use_global
-
- unlet! g:ale_python_mypy_executable
- unlet! g:ale_python_mypy_options
- unlet! g:ale_python_mypy_use_global
+ call ale#assert#SetUpLinterTest('python', 'mypy')
+ call ale#test#SetFilename('test.py')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
- runtime ale_linters/python/mypy.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
- call ale#test#SetFilename('test.py')
-
After:
- Restore
-
unlet! b:bin_dir
unlet! b:executable
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The mypy callbacks should return the correct default values):
- AssertEqual
- \ 'mypy',
- \ ale_linters#python#mypy#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'mypy',
\ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy')
\ . ' --show-column-numbers '
- \ . '--shadow-file %s %t %s',
- \ ale_linters#python#mypy#GetCommand(bufnr(''))
+ \ . '--shadow-file %s %t %s'
Execute(The mypy executable should be configurable, and escaped properly):
let g:ale_python_mypy_executable = 'executable with spaces'
- AssertEqual
- \ 'executable with spaces',
- \ ale_linters#python#mypy#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'executable with spaces',
\ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('executable with spaces')
\ . ' --show-column-numbers '
- \ . '--shadow-file %s %t %s',
- \ ale_linters#python#mypy#GetCommand(bufnr(''))
+ \ . '--shadow-file %s %t %s'
Execute(The mypy command callback should let you set options):
let g:ale_python_mypy_options = '--some-option'
- AssertEqual
+ AssertLinter 'mypy',
\ 'cd ' . ale#Escape(g:dir) . ' && ' . ale#Escape('mypy')
\ . ' --show-column-numbers --some-option '
- \ . '--shadow-file %s %t %s',
- \ ale_linters#python#mypy#GetCommand(bufnr(''))
+ \ . '--shadow-file %s %t %s'
Execute(The mypy command should switch directories to the detected project root):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
- AssertEqual
- \ 'mypy',
- \ ale_linters#python#mypy#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'mypy',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
\ . ' && ' . ale#Escape('mypy')
\ . ' --show-column-numbers '
- \ . '--shadow-file %s %t %s',
- \ ale_linters#python#mypy#GetCommand(bufnr(''))
+ \ . '--shadow-file %s %t %s'
Execute(The mypy callbacks 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 . '/mypy')
- AssertEqual
- \ b:executable,
- \ ale_linters#python#mypy#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter b:executable,
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ' && ' . ale#Escape(b:executable)
\ . ' --show-column-numbers '
- \ . '--shadow-file %s %t %s',
- \ ale_linters#python#mypy#GetCommand(bufnr(''))
+ \ . '--shadow-file %s %t %s'
Execute(You should able able to use the global mypy instead):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_mypy_use_global = 1
- AssertEqual
- \ 'mypy',
- \ ale_linters#python#mypy#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'mypy',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ' && ' . ale#Escape('mypy')
\ . ' --show-column-numbers '
- \ . '--shadow-file %s %t %s',
- \ ale_linters#python#mypy#GetCommand(bufnr(''))
+ \ . '--shadow-file %s %t %s'
Execute(Setting executable to 'pipenv' appends 'run mypy'):
let g:ale_python_mypy_executable = 'path/to/pipenv'
- AssertEqual
+ AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run mypy'
- \ . ' --show-column-numbers --shadow-file %s %t %s',
- \ ale_linters#python#mypy#GetCommand(bufnr(''))
+ \ . ' --show-column-numbers --shadow-file %s %t %s'
diff --git a/test/command_callback/test_nagelfar_command_callbacks.vader b/test/command_callback/test_nagelfar_command_callbacks.vader
index 5c6be7f1..94bb1d53 100644
--- a/test/command_callback/test_nagelfar_command_callbacks.vader
+++ b/test/command_callback/test_nagelfar_command_callbacks.vader
@@ -1,42 +1,19 @@
Before:
- Save g:ale_tcl_nagelfar_executable
- Save g:ale_tcl_nagelfar_options
-
- unlet! g:ale_tcl_nagelfar_executable
- unlet! b:ale_tcl_nagelfar_executable
- unlet! g:ale_tcl_nagelfar_options
- unlet! b:ale_tcl_nagelfar_options
-
- runtime ale_linters/tcl/nagelfar.vim
+ call ale#assert#SetUpLinterTest('tcl', 'nagelfar')
After:
- Restore
unlet! b:command_tail
- unlet! b:ale_tcl_nagelfar_executable
- unlet! b:ale_tcl_nagelfar_options
- call ale#linter#Reset()
-Execute(The executable should be configurable):
- AssertEqual 'nagelfar.tcl', ale_linters#tcl#nagelfar#GetExecutable(bufnr(''))
+ call ale#assert#TearDownLinterTest()
- let b:ale_tcl_nagelfar_executable = 'foobar'
-
- AssertEqual 'foobar', ale_linters#tcl#nagelfar#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('nagelfar.tcl') . ' %s',
- \ ale_linters#tcl#nagelfar#GetCommand(bufnr(''))
+Execute(The executable should be configurable):
+ AssertLinter 'nagelfar.tcl', ale#Escape('nagelfar.tcl') . ' %s'
let b:ale_tcl_nagelfar_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . ' %s',
- \ ale_linters#tcl#nagelfar#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' %s'
Execute(The options should be configurable):
let b:ale_tcl_nagelfar_options = '--something'
- AssertEqual
- \ ale#Escape('nagelfar.tcl') . ' --something %s',
- \ ale_linters#tcl#nagelfar#GetCommand(bufnr(''))
+ AssertLinter 'nagelfar.tcl', ale#Escape('nagelfar.tcl') . ' --something %s'
diff --git a/test/command_callback/test_nasm_nasm_command_callbacks.vader b/test/command_callback/test_nasm_nasm_command_callbacks.vader
index 5053e536..4e0cf608 100644
--- a/test/command_callback/test_nasm_nasm_command_callbacks.vader
+++ b/test/command_callback/test_nasm_nasm_command_callbacks.vader
@@ -1,13 +1,5 @@
Before:
- Save g:ale_nasm_nasm_executable
- Save g:ale_nasm_nasm_options
-
- unlet! g:ale_nasm_nasm_executable
- unlet! b:ale_nasm_nasm_executable
- unlet! g:ale_nasm_nasm_options
- unlet! b:ale_nasm_nasm_options
-
- runtime ale_linters/nasm/nasm.vim
+ call ale#assert#SetUpLinterTest('nasm', 'nasm')
let b:command_tail =
\ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' %s'
@@ -15,38 +7,25 @@ Before:
\ ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w+orphan-labels %s'
After:
- Restore
unlet! b:command_tail
unlet! b:command_tail_opt
- unlet! b:ale_nasm_nasm_executable
- unlet! b:ale_nasm_nasm_options
- call ale#linter#Reset()
-
-Execute(The executable should be configurable):
- AssertEqual 'nasm', ale_linters#nasm#nasm#GetExecutable(bufnr(''))
- let b:ale_nasm_nasm_executable = '/opt/nasm/nasm'
+ call ale#assert#TearDownLinterTest()
- AssertEqual '/opt/nasm/nasm', ale_linters#nasm#nasm#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('nasm') . b:command_tail,
- \ ale_linters#nasm#nasm#GetCommand(bufnr(''))
+Execute(The executable should be configurable):
+ AssertLinter 'nasm', ale#Escape('nasm') . b:command_tail,
let b:ale_nasm_nasm_executable = '~/nasm'
- AssertEqual
- \ ale#Escape('~/nasm') . b:command_tail,
- \ ale_linters#nasm#nasm#GetCommand(bufnr(''))
+ AssertLinter '~/nasm', ale#Escape('~/nasm') . b:command_tail
Execute(The options should be configurable):
- AssertEqual '', ale_linters#nasm#nasm#GetOptions(bufnr(''))
let b:ale_nasm_nasm_options = '-w-macro-params'
- AssertEqual '-w-macro-params', ale_linters#nasm#nasm#GetOptions(bufnr(''))
+
+ AssertLinter 'nasm', ale#Escape('nasm')
+ \ . ' -X gnu -I ' . ale#Escape(getcwd() . (has('win32') ? '\' : '/')) . ' -w-macro-params %s'
Execute(The options should be used in command):
- let b:ale_nasm_nasm_options = '-w+orphan-labels'
- AssertEqual
- \ ale#Escape('nasm') . b:command_tail_opt,
- \ ale_linters#nasm#nasm#GetCommand(bufnr(''))
+ let b:ale_nasm_nasm_options = '-w+orphan-labels'
+
+ AssertLinter 'nasm', ale#Escape('nasm') . b:command_tail_opt
diff --git a/test/command_callback/test_ocaml_ols_callbacks.vader b/test/command_callback/test_ocaml_ols_callbacks.vader
index d10898fa..c77e2909 100644
--- a/test/command_callback/test_ocaml_ols_callbacks.vader
+++ b/test/command_callback/test_ocaml_ols_callbacks.vader
@@ -1,54 +1,40 @@
Before:
- Save &filetype
- Save g:ale_ocaml_ols_executable
- Save g:ale_ocaml_ols_use_global
+ call ale#assert#SetUpLinterTest('ocaml', 'ols')
+ Save &filetype
let &filetype = 'ocaml'
- unlet! g:ale_ocaml_ols_executable
- unlet! g:ale_ocaml_ols_use_global
-
- runtime ale_linters/ocaml/ols.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The language string should be correct):
- AssertEqual 'ocaml', ale#handlers#ols#GetLanguage(bufnr(''))
+ AssertLSPLanguage 'ocaml'
Execute(The default executable should be correct):
- AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('ocaml-language-server') . ' --stdio',
- \ ale#handlers#ols#GetCommand(bufnr(''))
+ AssertLinter 'ocaml-language-server',
+ \ ale#Escape('ocaml-language-server') . ' --stdio'
Execute(The project root should be detected correctly):
- AssertEqual '', ale#handlers#ols#GetProjectRoot(bufnr(''))
+ AssertLSPProject ''
call ale#test#SetFilename('ols_paths/file.ml')
- AssertEqual
- \ ale#path#Simplify(g:dir . '/ols_paths'),
- \ ale#handlers#ols#GetProjectRoot(bufnr(''))
+ AssertLSPProject ale#path#Simplify(g:dir . '/ols_paths')
Execute(The local executable should be used when available):
call ale#test#SetFilename('ols_paths/file.ml')
- AssertEqual
- \ ale#path#Simplify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server'),
- \ ale#handlers#ols#GetExecutable(bufnr(''))
+ AssertLinter ale#path#Simplify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server'),
+ \ ale#Escape(ale#path#Simplify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server')) . ' --stdio'
Execute(The gloabl executable should always be used when use_global is set):
let g:ale_ocaml_ols_use_global = 1
call ale#test#SetFilename('ols_paths/file.ml')
- AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr(''))
+ AssertLinter 'ocaml-language-server',
+ \ ale#Escape('ocaml-language-server') . ' --stdio'
Execute(The executable should be configurable):
let g:ale_ocaml_ols_executable = 'foobar'
- AssertEqual 'foobar', ale#handlers#ols#GetExecutable(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --stdio'
diff --git a/test/command_callback/test_perl_command_callback.vader b/test/command_callback/test_perl_command_callback.vader
index ba85e53b..3c4b661c 100644
--- a/test/command_callback/test_perl_command_callback.vader
+++ b/test/command_callback/test_perl_command_callback.vader
@@ -1,37 +1,14 @@
Before:
- Save g:ale_perl_perl_executable
- Save g:ale_perl_perl_options
-
- unlet! g:ale_perl_perl_executable
- unlet! g:ale_perl_perl_options
-
- runtime ale_linters/perl/perl.vim
+ call ale#assert#SetUpLinterTest('perl', 'perl')
After:
- Restore
-
- unlet! b:ale_perl_perl_executable
- unlet! b:ale_perl_perl_options
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default Perl command callback should be correct):
- AssertEqual
- \ 'perl',
- \ ale_linters#perl#perl#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape('perl') . ' -c -Mwarnings -Ilib %t',
- \ ale_linters#perl#perl#GetCommand(bufnr(''))
+ AssertLinter 'perl', ale#Escape('perl') . ' -c -Mwarnings -Ilib %t'
Execute(Overriding the executable and command should work):
let b:ale_perl_perl_executable = 'foobar'
let b:ale_perl_perl_options = '-w'
- AssertEqual
- \ 'foobar',
- \ ale_linters#perl#perl#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape('foobar') . ' -w %t',
- \ ale_linters#perl#perl#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' -w %t'
diff --git a/test/command_callback/test_perlcritic_command_callback.vader b/test/command_callback/test_perlcritic_command_callback.vader
index e8d8cc18..0f1e2856 100644
--- a/test/command_callback/test_perlcritic_command_callback.vader
+++ b/test/command_callback/test_perlcritic_command_callback.vader
@@ -1,67 +1,36 @@
Before:
- Save g:ale_perl_perlcritic_profile
- Save g:ale_perl_perlcritic_options
- Save g:ale_perl_perlcritic_executable
- Save g:ale_perl_perlcritic_showrules
-
- unlet! g:ale_perl_perlcritic_options
- unlet! g:ale_perl_perlcritic_executable
- unlet! g:ale_perl_perlcritic_showrules
- let g:ale_perl_perlcritic_profile = ''
-
- runtime ale_linters/perl/perlcritic.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('perl', 'perlcritic')
call ale#test#SetFilename('test.pl')
+ let g:ale_perl_perlcritic_profile = ''
After:
- Restore
-
- unlet! b:ale_perl_perlcritic_profile
- unlet! b:ale_perl_perlcritic_options
- unlet! b:ale_perl_perlcritic_executable
- unlet! b:ale_perl_perlcritic_showrules
unlet! b:readme_path
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The command should be correct with g:ale_perl_perlcritic_showrules off):
let b:ale_perl_perlcritic_showrules = 0
- AssertEqual
- \ ale#Escape('perlcritic')
- \ . ' --verbose ' . ale#Escape('%l:%c %m\n')
- \ . ' --nocolor',
- \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
+ AssertLinter 'perlcritic', ale#Escape('perlcritic')
+ \ . ' --verbose ' . ale#Escape('%l:%c %m\n') . ' --nocolor'
Execute(The command should be correct with g:ale_perl_perlcritic_showrules on):
let b:ale_perl_perlcritic_showrules = 1
- AssertEqual
- \ ale#Escape('perlcritic')
- \ . ' --verbose ' . ale#Escape('%l:%c %m [%p]\n')
- \ . ' --nocolor',
- \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
+ AssertLinter 'perlcritic', ale#Escape('perlcritic')
+ \ . ' --verbose ' . ale#Escape('%l:%c %m [%p]\n') . ' --nocolor'
Execute(The command search for the profile file when set):
let b:ale_perl_perlcritic_profile = 'README.md'
let b:readme_path = ale#path#Simplify(expand('%:p:h:h:h') . '/README.md')
- AssertEqual
- \ ale#Escape('perlcritic')
- \ . ' --verbose ' . ale#Escape('%l:%c %m\n')
- \ . ' --nocolor'
- \ . ' --profile ' . ale#Escape(b:readme_path),
- \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
+ AssertLinter 'perlcritic', ale#Escape('perlcritic')
+ \ . ' --verbose ' . ale#Escape('%l:%c %m\n') . ' --nocolor'
+ \ . ' --profile ' . ale#Escape(b:readme_path)
Execute(Extra options should be set appropriately):
let b:ale_perl_perlcritic_options = 'beep boop'
- AssertEqual
- \ ale#Escape('perlcritic')
- \ . ' --verbose ' . ale#Escape('%l:%c %m\n')
- \ . ' --nocolor'
- \ . ' beep boop',
- \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
+ AssertLinter 'perlcritic', ale#Escape('perlcritic')
+ \ . ' --verbose ' . ale#Escape('%l:%c %m\n') . ' --nocolor'
+ \ . ' beep boop'
diff --git a/test/command_callback/test_php_langserver_callbacks.vader b/test/command_callback/test_php_langserver_callbacks.vader
index ebcae0e7..3b0a427e 100644
--- a/test/command_callback/test_php_langserver_callbacks.vader
+++ b/test/command_callback/test_php_langserver_callbacks.vader
@@ -1,49 +1,29 @@
Before:
- Save g:ale_php_langserver_executable
- Save g:ale_php_langserver_config_path
- Save g:ale_php_langserver_use_global
-
- unlet! g:ale_php_langserver_executable
- unlet! g:ale_php_langserver_config_path
- unlet! g:ale_php_langserver_use_global
-
- runtime ale_linters/php/langserver.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('php', 'langserver')
After:
- Restore
-
if isdirectory(g:dir . '/.git')
call delete(g:dir . '/.git', 'd')
endif
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default executable path should be correct):
- AssertEqual
- \ 'php-language-server.php',
- \ ale_linters#php#langserver#GetExecutable(bufnr(''))
- AssertEqual
- \ 'php ' . ale#Escape('php-language-server.php'),
- \ ale_linters#php#langserver#GetCommand(bufnr(''))
+ AssertLinter 'php-language-server.php',
+ \ 'php ' . ale#Escape('php-language-server.php')
Execute(Vendor executables should be detected):
call ale#test#SetFilename('php-langserver-project/test.php')
- AssertEqual
+ AssertLinter
\ ale#path#Simplify(g:dir . '/php-langserver-project/vendor/bin/php-language-server.php'),
- \ ale_linters#php#langserver#GetExecutable(bufnr(''))
- AssertEqual
\ 'php ' . ale#Escape(ale#path#Simplify(
\ g:dir
\ . '/php-langserver-project/vendor/bin/php-language-server.php'
- \ )),
- \ ale_linters#php#langserver#GetCommand(bufnr(''))
+ \ ))
Execute(The project path should be correct for .git directories):
call ale#test#SetFilename('php-langserver-project/test.php')
call mkdir(g:dir . '/.git')
- AssertEqual g:dir, ale_linters#php#langserver#GetProjectRoot(bufnr(''))
+ AssertLSPProject g:dir
diff --git a/test/command_callback/test_phpmd_command_callbacks.vader b/test/command_callback/test_phpmd_command_callbacks.vader
index 928b9771..64922820 100644
--- a/test/command_callback/test_phpmd_command_callbacks.vader
+++ b/test/command_callback/test_phpmd_command_callbacks.vader
@@ -1,20 +1,12 @@
Before:
- Save g:ale_php_phpmd_executable
-
- unlet! g:ale_php_phpmd_executable
-
- runtime ale_linters/php/phpmd.vim
+ call ale#assert#SetUpLinterTest('php', 'phpmd')
After:
- Restore
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(Custom executables should be used for the executable and command):
let g:ale_php_phpmd_executable = 'phpmd_test'
- AssertEqual 'phpmd_test', ale_linters#php#phpmd#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'phpmd_test',
\ ale#Escape('phpmd_test')
- \ . ' %s text cleancode,codesize,controversial,design,naming,unusedcode --ignore-violations-on-exit %t',
- \ ale_linters#php#phpmd#GetCommand(bufnr(''))
+ \ . ' %s text cleancode,codesize,controversial,design,naming,unusedcode --ignore-violations-on-exit %t'
diff --git a/test/command_callback/test_phpstan_command_callbacks.vader b/test/command_callback/test_phpstan_command_callbacks.vader
index 169c5bb7..c7db587a 100644
--- a/test/command_callback/test_phpstan_command_callbacks.vader
+++ b/test/command_callback/test_phpstan_command_callbacks.vader
@@ -1,38 +1,24 @@
Before:
- Save g:ale_php_phpstan_executable
- Save g:ale_php_phpstan_level
- Save g:ale_php_phpstan_configuration
-
- unlet! g:ale_php_phpstan_executable
- unlet! g:ale_php_phpstan_level
- unlet! g:ale_php_phpstan_configuration
-
- runtime ale_linters/php/phpstan.vim
+ call ale#assert#SetUpLinterTest('php', 'phpstan')
After:
- Restore
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(Custom executables should be used for the executable and command):
let g:ale_php_phpstan_executable = 'phpstan_test'
- AssertEqual 'phpstan_test', ale_linters#php#phpstan#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('phpstan_test') . ' analyze -l4 --errorFormat raw %s',
- \ ale_linters#php#phpstan#GetCommand(bufnr(''))
+ AssertLinter 'phpstan_test',
+ \ ale#Escape('phpstan_test') . ' analyze -l4 --errorFormat raw %s'
Execute(project with level set to 3):
call ale#test#SetFilename('phpstan-test-files/foo/test.php')
let g:ale_php_phpstan_level = 3
- AssertEqual
- \ ale#Escape('phpstan') . ' analyze -l3 --errorFormat raw %s',
- \ ale_linters#php#phpstan#GetCommand(bufnr(''))
+ AssertLinter 'phpstan',
+ \ ale#Escape('phpstan') . ' analyze -l3 --errorFormat raw %s'
Execute(Custom phpstan configuration file):
let g:ale_php_phpstan_configuration = 'phpstan_config'
- AssertEqual
- \ ale#Escape('phpstan') . ' analyze -l4 --errorFormat raw -c phpstan_config %s',
- \ ale_linters#php#phpstan#GetCommand(bufnr(''))
+ AssertLinter 'phpstan',
+ \ ale#Escape('phpstan') . ' analyze -l4 --errorFormat raw -c phpstan_config %s'
diff --git a/test/command_callback/test_pony_ponyc_command_callbacks.vader b/test/command_callback/test_pony_ponyc_command_callbacks.vader
index 7acbfa9d..3a3b32ec 100644
--- a/test/command_callback/test_pony_ponyc_command_callbacks.vader
+++ b/test/command_callback/test_pony_ponyc_command_callbacks.vader
@@ -1,23 +1,12 @@
Before:
- Save g:ale_pony_ponyc_options
-
- unlet! g:ale_pony_ponyc_options
- unlet! b:ale_pony_ponyc_options
-
- runtime ale_linters/pony/ponyc.vim
+ call ale#assert#SetUpLinterTest('pony', 'ponyc')
After:
- Restore
- unlet! b:ale_pony_ponyc_options
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The options should be used in the command):
- AssertEqual
- \ ale#Escape('ponyc') . ' --pass paint',
- \ ale_linters#pony#ponyc#GetCommand(bufnr(''))
+ AssertLinter 'ponyc', ale#Escape('ponyc') . ' --pass paint'
let b:ale_pony_ponyc_options = 'foobar'
- AssertEqual
- \ ale#Escape('ponyc') . ' foobar',
- \ ale_linters#pony#ponyc#GetCommand(bufnr(''))
+ AssertLinter 'ponyc', ale#Escape('ponyc') . ' foobar'
diff --git a/test/command_callback/test_prospector_command_callback.vader b/test/command_callback/test_prospector_command_callback.vader
index 04cd58ed..316b9883 100644
--- a/test/command_callback/test_prospector_command_callback.vader
+++ b/test/command_callback/test_prospector_command_callback.vader
@@ -1,23 +1,12 @@
Before:
- Save g:ale_python_mypy_executable
- Save g:ale_python_mypy_options
-
- unlet! g:ale_python_mypy_executable
- unlet! g:ale_python_mypy_options
-
- runtime ale_linters/python/prospector.vim
+ call ale#assert#SetUpLinterTest('python', 'prospector')
After:
- Restore
-
- unlet! b:executable
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(Setting executable to 'pipenv' appends 'run prospector'):
let g:ale_python_prospector_executable = 'path/to/pipenv'
- AssertEqual
+ AssertLinter 'path/to/pipenv',
\ ale#Escape('path/to/pipenv') . ' run prospector'
- \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s',
- \ ale_linters#python#prospector#GetCommand(bufnr(''))
+ \ . ' --messages-only --absolute-paths --zero-exit --output-format json %s'
diff --git a/test/command_callback/test_proto_command_callback.vader b/test/command_callback/test_proto_command_callback.vader
index 76050c61..726588c0 100644
--- a/test/command_callback/test_proto_command_callback.vader
+++ b/test/command_callback/test_proto_command_callback.vader
@@ -1,21 +1,16 @@
Before:
+ call ale#assert#SetUpLinterTest('proto', 'protoc_gen_lint')
call ale#test#SetFilename('test.proto')
After:
- Restore
-
- unlet! b:ale_proto_protoc_gen_lint_options
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual
- \ 'protoc' . ' -I ' . ale#Escape(getcwd()) . ' --lint_out=. ' . '%s',
- \ ale_linters#proto#protoc_gen_lint#GetCommand(bufnr(''))
+ AssertLinter 'protoc',
+ \ 'protoc' . ' -I ' . ale#Escape(getcwd()) . ' --lint_out=. ' . '%s'
Execute(The callback should include any additional options):
let b:ale_proto_protoc_gen_lint_options = '--some-option'
- AssertEqual
- \ 'protoc' . ' -I ' . ale#Escape(getcwd()) . ' --some-option --lint_out=. ' . '%s',
- \ ale_linters#proto#protoc_gen_lint#GetCommand(bufnr(''))
+ AssertLinter 'protoc',
+ \ 'protoc' . ' -I ' . ale#Escape(getcwd()) . ' --some-option --lint_out=. ' . '%s'
diff --git a/test/command_callback/test_puglint_command_callback.vader b/test/command_callback/test_puglint_command_callback.vader
index f9b4a856..69c86b25 100644
--- a/test/command_callback/test_puglint_command_callback.vader
+++ b/test/command_callback/test_puglint_command_callback.vader
@@ -1,71 +1,48 @@
Before:
- Save g:ale_pug_puglint_options
- Save g:ale_pug_puglint_executable
- Save g:ale_pug_puglint_use_global
-
- let g:ale_pug_puglint_options = ''
- let g:ale_pug_puglint_executable = 'pug-lint'
- let g:ale_pug_puglint_use_global = 0
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
- runtime ale_linters/pug/puglint.vim
+ call ale#assert#SetUpLinterTest('pug', 'puglint')
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(puglint should detect local executables and package.json):
call ale#test#SetFilename('puglint_project/test.pug')
- AssertEqual
+ AssertLinter
\ ale#path#Simplify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'),
- \ ale_linters#pug#puglint#GetExecutable(bufnr(''))
-
- AssertEqual
\ ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/package.json'))
- \ . ' -r inline %t',
- \ ale_linters#pug#puglint#GetCommand(bufnr(''))
+ \ . ' -r inline %t'
Execute(puglint should use global executables if configured):
let g:ale_pug_puglint_use_global = 1
call ale#test#SetFilename('puglint_project/test.pug')
- AssertEqual 'pug-lint', ale_linters#pug#puglint#GetExecutable(bufnr(''))
-
- AssertEqual
+ AssertLinter 'pug-lint',
\ ale#Escape('pug-lint')
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/package.json'))
- \ . ' -r inline %t',
- \ ale_linters#pug#puglint#GetCommand(bufnr(''))
+ \ . ' -r inline %t'
Execute(puglint should detect .pug-lintrc):
call ale#test#SetFilename('puglint_project/puglint_rc_dir/subdir/test.pug')
- AssertEqual
+ AssertLinter ale#path#Simplify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'),
\ ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/puglint_rc_dir/.pug-lintrc'))
- \ . ' -r inline %t',
- \ ale_linters#pug#puglint#GetCommand(bufnr(''))
+ \ . ' -r inline %t'
Execute(puglint should detect .pug-lintrc.js):
call ale#test#SetFilename('puglint_project/puglint_rc_js_dir/subdir/test.pug')
- AssertEqual
+ AssertLinter ale#path#Simplify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'),
\ ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/puglint_rc_js_dir/.pug-lintrc.js'))
- \ . ' -r inline %t',
- \ ale_linters#pug#puglint#GetCommand(bufnr(''))
+ \ . ' -r inline %t'
Execute(puglint should detect .pug-lintrc.json):
call ale#test#SetFilename('puglint_project/puglint_rc_json_dir/subdir/test.pug')
- AssertEqual
+ AssertLinter ale#path#Simplify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'),
\ ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/node_modules/.bin/pug-lint'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/puglint_project/puglint_rc_json_dir/.pug-lintrc.json'))
- \ . ' -r inline %t',
- \ ale_linters#pug#puglint#GetCommand(bufnr(''))
+ \ . ' -r inline %t'
diff --git a/test/command_callback/test_pycodestyle_command_callback.vader b/test/command_callback/test_pycodestyle_command_callback.vader
index 90b07a24..851eede9 100644
--- a/test/command_callback/test_pycodestyle_command_callback.vader
+++ b/test/command_callback/test_pycodestyle_command_callback.vader
@@ -1,34 +1,26 @@
Before:
- Save g:ale_python_pycodestyle_executable
- Save g:ale_python_pycodestyle_options
- Save g:ale_python_pycodestyle_use_global
-
- runtime ale_linters/python/pycodestyle.vim
+ call ale#assert#SetUpLinterTest('python', 'pycodestyle')
After:
- Restore
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The pycodestyle command callback should return default string):
- AssertEqual ale#Escape('pycodestyle') . ' -',
- \ ale_linters#python#pycodestyle#GetCommand(bufnr(''))
+ AssertLinter 'pycodestyle', ale#Escape('pycodestyle') . ' -'
Execute(The pycodestyle command callback should allow options):
let g:ale_python_pycodestyle_options = '--exclude=test*.py'
- AssertEqual ale#Escape('pycodestyle') . ' --exclude=test*.py -',
- \ ale_linters#python#pycodestyle#GetCommand(bufnr(''))
+ AssertLinter 'pycodestyle',
+ \ ale#Escape('pycodestyle') . ' --exclude=test*.py -'
Execute(The pycodestyle executable should be configurable):
let g:ale_python_pycodestyle_executable = '~/.local/bin/pycodestyle'
- AssertEqual ale#Escape('~/.local/bin/pycodestyle') . ' -',
- \ ale_linters#python#pycodestyle#GetCommand(bufnr(''))
+ AssertLinter '~/.local/bin/pycodestyle',
+ \ ale#Escape('~/.local/bin/pycodestyle') . ' -'
Execute(Setting executable to 'pipenv' appends 'run pycodestyle'):
let g:ale_python_pycodestyle_executable = 'path/to/pipenv'
- AssertEqual
- \ ale#Escape('path/to/pipenv') . ' run pycodestyle -',
- \ ale_linters#python#pycodestyle#GetCommand(bufnr(''))
+ AssertLinter 'path/to/pipenv',
+ \ ale#Escape('path/to/pipenv') . ' run pycodestyle -'
diff --git a/test/command_callback/test_pyflakes_command_callback.vader b/test/command_callback/test_pyflakes_command_callback.vader
index 491432e9..efc925fe 100644
--- a/test/command_callback/test_pyflakes_command_callback.vader
+++ b/test/command_callback/test_pyflakes_command_callback.vader
@@ -1,34 +1,20 @@
Before:
- Save g:ale_python_pyflakes_executable
- Save g:ale_python_pyflakes_use_global
-
- unlet! g:ale_python_pyflakes_executable
- unlet! g:ale_python_pyflakes_use_global
-
+ call ale#assert#SetUpLinterTest('python', 'pyflakes')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
- runtime ale_linters/python/pyflakes.vim
-
After:
- Restore
-
unlet! b:bin_dir
unlet! b:executable
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The pyflakes command callback should return default string):
- AssertEqual ale#Escape('pyflakes') . ' %t',
- \ ale_linters#python#pyflakes#GetCommand(bufnr(''))
+ AssertLinter 'pyflakes', ale#Escape('pyflakes') . ' %t'
Execute(The pyflakes executable should be configurable):
let g:ale_python_pyflakes_executable = '~/.local/bin/pyflakes'
- AssertEqual ale#Escape('~/.local/bin/pyflakes') . ' %t',
- \ ale_linters#python#pyflakes#GetCommand(bufnr(''))
+ AssertLinter '~/.local/bin/pyflakes',
+ \ ale#Escape('~/.local/bin/pyflakes') . ' %t'
Execute(The pyflakes executable should be run from the virtualenv path):
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
@@ -37,20 +23,17 @@ Execute(The pyflakes executable should be run from the virtualenv path):
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pyflakes'
\)
- AssertEqual ale#Escape(b:executable) . ' %t',
- \ ale_linters#python#pyflakes#GetCommand(bufnr(''))
+ AssertLinter b:executable, ale#Escape(b:executable) . ' %t'
Execute(You should be able to override the pyflakes virtualenv lookup):
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_pyflakes_use_global = 1
- AssertEqual ale#Escape('pyflakes') . ' %t',
- \ ale_linters#python#pyflakes#GetCommand(bufnr(''))
+ AssertLinter 'pyflakes', ale#Escape('pyflakes') . ' %t'
Execute(Setting executable to 'pipenv' appends 'run pyflakes'):
let g:ale_python_pyflakes_executable = 'path/to/pipenv'
- AssertEqual
+ AssertLinter 'path/to/pipenv',
\ ale#Escape('path/to/pipenv') . ' run pyflakes %t',
- \ ale_linters#python#pyflakes#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_pylint_command_callback.vader b/test/command_callback/test_pylint_command_callback.vader
index f8cb5800..be2908f9 100644
--- a/test/command_callback/test_pylint_command_callback.vader
+++ b/test/command_callback/test_pylint_command_callback.vader
@@ -1,79 +1,46 @@
Before:
- Save g:ale_python_pylint_executable
- Save g:ale_python_pylint_options
- Save g:ale_python_pylint_use_global
- Save g:ale_python_pylint_change_directory
-
- unlet! g:ale_python_pylint_executable
- unlet! g:ale_python_pylint_options
- unlet! g:ale_python_pylint_use_global
- unlet! g:ale_python_pylint_change_directory
-
- runtime ale_linters/python/pylint.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('python', 'pylint')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
-
let b:command_tail = ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
-
unlet! b:bin_dir
unlet! b:executable
+ unlet! b:command_tail
+
+ call ale#assert#TearDownLinterTest()
Execute(The pylint callbacks should return the correct default values):
- AssertEqual
- \ 'pylint',
- \ ale_linters#python#pylint#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'pylint',
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('pylint') . ' ' . b:command_tail,
- \ ale_linters#python#pylint#GetCommand(bufnr(''))
+ \ . ale#Escape('pylint') . ' ' . b:command_tail
Execute(The option for disabling changing directories should work):
let g:ale_python_pylint_change_directory = 0
- AssertEqual
- \ 'pylint',
- \ ale_linters#python#pylint#GetExecutable(bufnr(''))
- \
- AssertEqual
- \ ale#Escape('pylint') . ' ' . b:command_tail,
- \ ale_linters#python#pylint#GetCommand(bufnr(''))
+ AssertLinter 'pylint', ale#Escape('pylint') . ' ' . b:command_tail
Execute(The pylint executable should be configurable, and escaped properly):
let g:ale_python_pylint_executable = 'executable with spaces'
- AssertEqual
- \ 'executable with spaces',
- \ ale_linters#python#pylint#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'executable with spaces',
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('executable with spaces') . ' ' . b:command_tail,
- \ ale_linters#python#pylint#GetCommand(bufnr(''))
+ \ . ale#Escape('executable with spaces') . ' ' . b:command_tail
Execute(The pylint command callback should let you set options):
let g:ale_python_pylint_options = '--some-option'
- AssertEqual
+ AssertLinter 'pylint',
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('pylint') . ' --some-option' . b:command_tail,
- \ ale_linters#python#pylint#GetCommand(bufnr(''))
+ \ . ale#Escape('pylint') . ' --some-option' . b:command_tail
Execute(The pylint callbacks shouldn't detect virtualenv directories where they don't exist):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
- AssertEqual
- \ 'pylint',
- \ ale_linters#python#pylint#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'pylint',
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('pylint') . ' ' . b:command_tail,
- \ ale_linters#python#pylint#GetCommand(bufnr(''))
+ \ . ale#Escape('pylint') . ' ' . b:command_tail
Execute(The pylint callbacks should detect virtualenv directories):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
@@ -82,32 +49,22 @@ Execute(The pylint callbacks should detect virtualenv directories):
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pylint'
\)
- AssertEqual
- \ b:executable,
- \ ale_linters#python#pylint#GetExecutable(bufnr(''))
-
- AssertEqual
+ AssertLinter b:executable,
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape(b:executable) . ' ' . b:command_tail,
- \ ale_linters#python#pylint#GetCommand(bufnr(''))
+ \ . ale#Escape(b:executable) . ' ' . b:command_tail
Execute(You should able able to use the global pylint instead):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_pylint_use_global = 1
- AssertEqual
- \ 'pylint',
- \ ale_linters#python#pylint#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'pylint',
\ ale#path#BufferCdString(bufnr(''))
- \ . ale#Escape('pylint') . ' ' . b:command_tail,
- \ ale_linters#python#pylint#GetCommand(bufnr(''))
+ \ . ale#Escape('pylint') . ' ' . b:command_tail
Execute(Setting executable to 'pipenv' appends 'run pylint'):
let g:ale_python_pylint_executable = 'path/to/pipenv'
- AssertEqual
+ AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run pylint'
- \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s',
- \ ale_linters#python#pylint#GetCommand(bufnr(''))
+ \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
diff --git a/test/command_callback/test_pyls_command_callback.vader b/test/command_callback/test_pyls_command_callback.vader
index 4bef4742..53bf3000 100644
--- a/test/command_callback/test_pyls_command_callback.vader
+++ b/test/command_callback/test_pyls_command_callback.vader
@@ -1,34 +1,21 @@
Before:
- Save g:ale_python_pyls_executable
- Save g:ale_python_pyls_use_global
-
- unlet! g:ale_python_pyls_executable
- unlet! g:ale_python_pyls_use_global
+ call ale#assert#SetUpLinterTest('python', 'pyls')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
- runtime ale_linters/python/pyls.vim
-
After:
- Restore
-
unlet! b:bin_dir
unlet! b:executable
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The pyls command callback should return default string):
- AssertEqual ale#Escape('pyls'),
- \ ale_linters#python#pyls#GetCommand(bufnr(''))
+ AssertLinter 'pyls', ale#Escape('pyls')
Execute(The pyls executable should be configurable):
let g:ale_python_pyls_executable = '~/.local/bin/pyls'
- AssertEqual ale#Escape('~/.local/bin/pyls'),
- \ ale_linters#python#pyls#GetCommand(bufnr(''))
+ AssertLinter '~/.local/bin/pyls' , ale#Escape('~/.local/bin/pyls')
Execute(The pyls executable should be run from the virtualenv path):
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
@@ -45,12 +32,9 @@ Execute(You should be able to override the pyls virtualenv lookup):
let g:ale_python_pyls_use_global = 1
- AssertEqual ale#Escape('pyls'),
- \ ale_linters#python#pyls#GetCommand(bufnr(''))
+ AssertLinter 'pyls', ale#Escape('pyls')
Execute(Setting executable to 'pipenv' appends 'run pyls'):
let g:ale_python_pyls_executable = 'path/to/pipenv'
- AssertEqual
- \ ale#Escape('path/to/pipenv') . ' run pyls',
- \ ale_linters#python#pyls#GetCommand(bufnr(''))
+ AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run pyls'
diff --git a/test/command_callback/test_pyre_command_callback.vader b/test/command_callback/test_pyre_command_callback.vader
index 395f951f..6ad19b56 100644
--- a/test/command_callback/test_pyre_command_callback.vader
+++ b/test/command_callback/test_pyre_command_callback.vader
@@ -1,34 +1,20 @@
Before:
- Save g:ale_python_pyre_executable
- Save g:ale_python_pyre_use_global
-
- unlet! g:ale_python_pyre_executable
- unlet! g:ale_python_pyre_use_global
-
+ call ale#assert#SetUpLinterTest('python', 'pyre')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
- runtime ale_linters/python/pyre.vim
-
After:
- Restore
-
unlet! b:bin_dir
unlet! b:executable
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The pyre command callback should return default string):
- AssertEqual ale#Escape('pyre') . ' persistent',
- \ ale_linters#python#pyre#GetCommand(bufnr(''))
+ AssertLinter 'pyre', ale#Escape('pyre') . ' persistent'
Execute(The pyre executable should be configurable):
let g:ale_python_pyre_executable = '~/.local/bin/pyre'
- AssertEqual ale#Escape('~/.local/bin/pyre') . ' persistent',
- \ ale_linters#python#pyre#GetCommand(bufnr(''))
+ AssertLinter '~/.local/bin/pyre',
+ \ ale#Escape('~/.local/bin/pyre') . ' persistent'
Execute(The pyre executable should be run from the virtualenv path):
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
@@ -37,20 +23,17 @@ Execute(The pyre executable should be run from the virtualenv path):
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pyre'
\)
- AssertEqual ale#Escape(b:executable) . ' persistent',
- \ ale_linters#python#pyre#GetCommand(bufnr(''))
+ AssertLinter b:executable, ale#Escape(b:executable) . ' persistent'
Execute(You should be able to override the pyre virtualenv lookup):
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_pyre_use_global = 1
- AssertEqual ale#Escape('pyre') . ' persistent',
- \ ale_linters#python#pyre#GetCommand(bufnr(''))
+ AssertLinter 'pyre', ale#Escape('pyre') . ' persistent'
Execute(Setting executable to 'pipenv' appends 'run pyre'):
let g:ale_python_pyre_executable = 'path/to/pipenv'
- AssertEqual
- \ ale#Escape('path/to/pipenv') . ' run pyre persistent',
- \ ale_linters#python#pyre#GetCommand(bufnr(''))
+ AssertLinter 'path/to/pipenv',
+ \ ale#Escape('path/to/pipenv') . ' run pyre persistent'
diff --git a/test/command_callback/test_pyrex_cython_command_callback.vader b/test/command_callback/test_pyrex_cython_command_callback.vader
index 527ed2dd..b9020f11 100644
--- a/test/command_callback/test_pyrex_cython_command_callback.vader
+++ b/test/command_callback/test_pyrex_cython_command_callback.vader
@@ -1,50 +1,30 @@
Before:
- Save g:ale_pyrex_cython_executable
- Save g:ale_pyrex_cython_options
-
- unlet! g:ale_pyrex_cython_executable
- unlet! b:ale_pyrex_cython_executable
- unlet! g:ale_pyrex_cython_options
- unlet! b:ale_pyrex_cython_options
-
- runtime ale_linters/pyrex/cython.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('pyrex', 'cython')
After:
- Restore
- unlet! b:ale_pyrex_cython_options
- unlet! b:ale_pyrex_cython_executable
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(The default cython command should be correct):
- AssertEqual
- \ ale#Escape('cython')
+ AssertLinter 'cython', ale#Escape('cython')
\ . ' --working ' . ale#Escape(g:dir)
\ . ' --include-dir ' . ale#Escape(g:dir)
\ . ' --warning-extra'
- \ . ' --output-file ' . g:ale#util#nul_file . ' %t',
- \ ale_linters#pyrex#cython#GetCommand(bufnr(''))
+ \ . ' --output-file ' . g:ale#util#nul_file . ' %t'
Execute(The cython executable should be configurable):
let b:ale_pyrex_cython_executable = 'cython_foobar'
- AssertEqual
- \ ale#Escape('cython_foobar')
+ AssertLinter 'cython_foobar', ale#Escape('cython_foobar')
\ . ' --working ' . ale#Escape(g:dir)
\ . ' --include-dir ' . ale#Escape(g:dir)
\ . ' --warning-extra'
- \ . ' --output-file ' . g:ale#util#nul_file . ' %t',
- \ ale_linters#pyrex#cython#GetCommand(bufnr(''))
+ \ . ' --output-file ' . g:ale#util#nul_file . ' %t'
Execute(Additional cython options should be configurable):
let b:ale_pyrex_cython_options = '--foobar'
- AssertEqual
- \ ale#Escape('cython')
+ AssertLinter 'cython', ale#Escape('cython')
\ . ' --working ' . ale#Escape(g:dir)
\ . ' --include-dir ' . ale#Escape(g:dir)
\ . ' --foobar'
- \ . ' --output-file ' . g:ale#util#nul_file . ' %t',
- \ ale_linters#pyrex#cython#GetCommand(bufnr(''))
+ \ . ' --output-file ' . g:ale#util#nul_file . ' %t'
diff --git a/test/command_callback/test_qmlfmt_command_callback.vader b/test/command_callback/test_qmlfmt_command_callback.vader
index 263caea7..53502f4d 100644
--- a/test/command_callback/test_qmlfmt_command_callback.vader
+++ b/test/command_callback/test_qmlfmt_command_callback.vader
@@ -1,18 +1,13 @@
Before:
- runtime ale_linters/qml/qmlfmt.vim
+ call ale#assert#SetUpLinterTest('qml', 'qmlfmt')
After:
- let g:ale_qml_qmlfmt_executable = 'qmlfmt'
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The qml qmlfmt command callback should return the correct default string):
- AssertEqual ale#Escape('qmlfmt') . ' -e',
- \ join(split(ale_linters#qml#qmlfmt#GetCommand(1)))
+ AssertLinter 'qmlfmt', ale#Escape('qmlfmt') . ' -e',
Execute(The qmlfmt executable should be configurable):
let g:ale_qml_qmlfmt_executable = '~/.local/bin/qmlfmt'
- AssertEqual '~/.local/bin/qmlfmt', ale_linters#qml#qmlfmt#GetExecutable(1)
- AssertEqual ale#Escape('~/.local/bin/qmlfmt') . ' -e',
- \ join(split(ale_linters#qml#qmlfmt#GetCommand(1)))
+ AssertLinter '~/.local/bin/qmlfmt', ale#Escape('~/.local/bin/qmlfmt') . ' -e'
diff --git a/test/command_callback/test_rails_best_practices_command_callback.vader b/test/command_callback/test_rails_best_practices_command_callback.vader
index b4d2e82d..bc7c8e85 100644
--- a/test/command_callback/test_rails_best_practices_command_callback.vader
+++ b/test/command_callback/test_rails_best_practices_command_callback.vader
@@ -1,10 +1,5 @@
Before:
- Save g:ale_ruby_rails_best_practices_executable
-
- let g:ale_ruby_rails_best_practices_executable = 'rails_best_practices'
-
- runtime ale_linters/ruby/rails_best_practices.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('ruby', 'rails_best_practices')
call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb')
let b:args = '--silent -f json'
@@ -13,45 +8,35 @@ Before:
let b:suffix = has('win32') ? '; type %t' : ''
After:
- Restore
-
unlet! b:args
unlet! b:app_path
unlet! b:suffix
-
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(Executable should default to rails_best_practices):
- AssertEqual
- \ ale#Escape('rails_best_practices')
+ AssertLinter 'rails_best_practices', ale#Escape('rails_best_practices')
\ . ' ' . b:args
\ . ' ' . ale#Escape(b:app_path)
- \ . b:suffix,
- \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr(''))
+ \ . b:suffix
Execute(Should be able to set a custom executable):
let g:ale_ruby_rails_best_practices_executable = 'bin/rails_best_practices'
- AssertEqual
- \ ale#Escape('bin/rails_best_practices')
+ AssertLinter 'bin/rails_best_practices', ale#Escape('bin/rails_best_practices')
\ . ' ' . b:args
\ . ' ' . ale#Escape(b:app_path)
- \ . b:suffix,
- \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr(''))
+ \ . b:suffix
Execute(Setting bundle appends 'exec rails_best_practices'):
let g:ale_ruby_rails_best_practices_executable = 'path to/bundle'
- AssertEqual
- \ ale#Escape('path to/bundle') . ' exec rails_best_practices'
+ AssertLinter 'path to/bundle', ale#Escape('path to/bundle')
+ \ . ' exec rails_best_practices'
\ . ' ' . b:args
\ . ' ' . ale#Escape(b:app_path)
- \ . b:suffix,
- \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr(''))
+ \ . b:suffix
Execute(Command callback should be empty when not in a valid Rails app):
call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/test.rb')
- AssertEqual
- \ '',
- \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr(''))
+ AssertLinter 'rails_best_practices', ''
diff --git a/test/command_callback/test_reason_ols_callbacks.vader b/test/command_callback/test_reason_ols_callbacks.vader
index 5fb39afe..53ef7fab 100644
--- a/test/command_callback/test_reason_ols_callbacks.vader
+++ b/test/command_callback/test_reason_ols_callbacks.vader
@@ -1,54 +1,41 @@
Before:
- Save &filetype
- Save g:ale_reason_ols_executable
- Save g:ale_reason_ols_use_global
+ call ale#assert#SetUpLinterTest('reason', 'ols')
+ Save &filetype
let &filetype = 'reason'
- unlet! g:ale_reason_ols_executable
- unlet! g:ale_reason_ols_use_global
-
- runtime ale_linters/reason/ols.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The language string should be correct):
- AssertEqual 'reason', ale#handlers#ols#GetLanguage(bufnr(''))
+ AssertLSPLanguage 'reason'
Execute(The default executable should be correct):
- AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('ocaml-language-server') . ' --stdio',
- \ ale#handlers#ols#GetCommand(bufnr(''))
+ AssertLinter 'ocaml-language-server',
+ \ ale#Escape('ocaml-language-server') . ' --stdio'
Execute(The project root should be detected correctly):
- AssertEqual '', ale#handlers#ols#GetProjectRoot(bufnr(''))
+ AssertLSPProject ''
call ale#test#SetFilename('ols_paths/file.re')
- AssertEqual
- \ ale#path#Simplify(g:dir . '/ols_paths'),
- \ ale#handlers#ols#GetProjectRoot(bufnr(''))
+ AssertLSPProject ale#path#Simplify(g:dir . '/ols_paths')
Execute(The local executable should be used when available):
call ale#test#SetFilename('ols_paths/file.re')
- AssertEqual
+ AssertLinter
\ ale#path#Simplify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server'),
- \ ale#handlers#ols#GetExecutable(bufnr(''))
+ \ ale#Escape(ale#path#Simplify(g:dir . '/ols_paths/node_modules/.bin/ocaml-language-server')) . ' --stdio'
Execute(The gloabl executable should always be used when use_global is set):
let g:ale_reason_ols_use_global = 1
call ale#test#SetFilename('ols_paths/file.re')
- AssertEqual 'ocaml-language-server', ale#handlers#ols#GetExecutable(bufnr(''))
+ AssertLinter 'ocaml-language-server',
+ \ ale#Escape('ocaml-language-server') . ' --stdio'
Execute(The executable should be configurable):
let g:ale_reason_ols_executable = 'foobar'
- AssertEqual 'foobar', ale#handlers#ols#GetExecutable(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --stdio'
diff --git a/test/command_callback/test_reek_command_callback.vader b/test/command_callback/test_reek_command_callback.vader
index 41e749c1..059e5e36 100644
--- a/test/command_callback/test_reek_command_callback.vader
+++ b/test/command_callback/test_reek_command_callback.vader
@@ -1,34 +1,34 @@
Before:
- runtime ale_linters/ruby/reek.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('ruby', 'reek')
After:
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
- call ale#semver#ResetVersionCache()
+ call ale#assert#TearDownLinterTest()
Execute(The reek callbacks should return the correct default values):
- AssertEqual
+ WithChainResults ['reek 5.0.0']
+ AssertLinter 'reek', [
\ 'reek --version',
- \ ale_linters#ruby#reek#VersionCheck(bufnr(''))
- AssertEqual
\ 'reek -f json --no-progress --no-color --stdin-filename %s',
- \ ale_linters#ruby#reek#GetCommand(bufnr(''), ['reek 5.0.0'])
+ \]
" Try with older versions.
call ale#semver#ResetVersionCache()
- AssertEqual
+
+ WithChainResults ['reek 4.8.2']
+ AssertLinter 'reek', [
+ \ 'reek --version',
\ 'reek -f json --no-progress --no-color',
- \ ale_linters#ruby#reek#GetCommand(bufnr(''), ['reek 4.8.2'])
+ \]
Execute(The reek version check should be cached):
- AssertEqual
+ WithChainResults ['reek 5.0.0']
+ AssertLinter 'reek', [
+ \ 'reek --version',
\ 'reek -f json --no-progress --no-color --stdin-filename %s',
- \ ale_linters#ruby#reek#GetCommand(bufnr(''), ['reek 5.0.0'])
+ \]
- AssertEqual
+ WithChainResults []
+ AssertLinter 'reek', [
\ '',
- \ ale_linters#ruby#reek#VersionCheck(bufnr(''))
- AssertEqual
\ 'reek -f json --no-progress --no-color --stdin-filename %s',
- \ ale_linters#ruby#reek#GetCommand(bufnr(''), [])
+ \]
diff --git a/test/command_callback/test_rubocop_command_callback.vader b/test/command_callback/test_rubocop_command_callback.vader
index f0aa194f..7f42a8c0 100644
--- a/test/command_callback/test_rubocop_command_callback.vader
+++ b/test/command_callback/test_rubocop_command_callback.vader
@@ -1,39 +1,29 @@
Before:
- Save g:ale_ruby_rubocop_executable
+ call ale#assert#SetUpLinterTest('ruby', 'rubocop')
+ call ale#test#SetFilename('dummy.rb')
let g:ale_ruby_rubocop_executable = 'rubocop'
-
- runtime ale_linters/ruby/rubocop.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
- call ale#test#SetFilename('dummy.rb')
+ let g:ale_ruby_rubocop_options = ''
After:
- Restore
-
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(Executable should default to rubocop):
- AssertEqual
- \ ale#Escape('rubocop')
+ AssertLinter 'rubocop', ale#Escape('rubocop')
\ . ' --format json --force-exclusion --stdin '
- \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb')),
- \ ale_linters#ruby#rubocop#GetCommand(bufnr(''))
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb'))
Execute(Should be able to set a custom executable):
let g:ale_ruby_rubocop_executable = 'bin/rubocop'
- AssertEqual
- \ ale#Escape('bin/rubocop')
+ AssertLinter 'bin/rubocop' , ale#Escape('bin/rubocop')
\ . ' --format json --force-exclusion --stdin '
- \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb')),
- \ ale_linters#ruby#rubocop#GetCommand(bufnr(''))
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb'))
Execute(Setting bundle appends 'exec rubocop'):
let g:ale_ruby_rubocop_executable = 'path to/bundle'
- AssertEqual
- \ ale#Escape('path to/bundle') . ' exec rubocop'
+ AssertLinter 'path to/bundle', ale#Escape('path to/bundle')
+ \ . ' exec rubocop'
\ . ' --format json --force-exclusion --stdin '
- \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb')),
- \ ale_linters#ruby#rubocop#GetCommand(bufnr(''))
+ \ . ale#Escape(ale#path#Simplify(g:dir . '/dummy.rb'))
diff --git a/test/command_callback/test_ruby_command_callback.vader b/test/command_callback/test_ruby_command_callback.vader
index 3813d56b..b6bac14f 100644
--- a/test/command_callback/test_ruby_command_callback.vader
+++ b/test/command_callback/test_ruby_command_callback.vader
@@ -1,25 +1,13 @@
Before:
- Save g:ale_ruby_ruby_executable
-
- unlet! g:ale_ruby_ruby_executable
-
- runtime ale_linters/ruby/ruby.vim
+ call ale#assert#SetUpLinterTest('ruby', 'ruby')
After:
- Restore
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual 'ruby', ale_linters#ruby#ruby#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('ruby') . ' -w -c -T1 %t',
- \ ale_linters#ruby#ruby#GetCommand(bufnr(''))
+ AssertLinter 'ruby', ale#Escape('ruby') . ' -w -c -T1 %t'
Execute(The executable should be configurable):
let g:ale_ruby_ruby_executable = 'foobar'
- AssertEqual 'foobar', ale_linters#ruby#ruby#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('foobar') . ' -w -c -T1 %t',
- \ ale_linters#ruby#ruby#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' -w -c -T1 %t'
diff --git a/test/command_callback/test_rust_rls_callbacks.vader b/test/command_callback/test_rust_rls_callbacks.vader
index 16bde98a..a710161d 100644
--- a/test/command_callback/test_rust_rls_callbacks.vader
+++ b/test/command_callback/test_rust_rls_callbacks.vader
@@ -1,45 +1,25 @@
Before:
- Save g:ale_rust_rls_executable
- Save g:ale_rust_rls_toolchain
-
- unlet! g:ale_rust_rls_executable
- unlet! g:ale_rust_rls_toolchain
-
- runtime ale_linters/rust/rls.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('rust', 'rls')
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default executable path should be correct):
- AssertEqual 'rls', ale_linters#rust#rls#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('rls') . ' +' . ale#Escape('nightly'),
- \ ale_linters#rust#rls#GetCommand(bufnr(''))
+ AssertLinter 'rls', ale#Escape('rls') . ' +' . ale#Escape('nightly')
Execute(The toolchain should be configurable):
let g:ale_rust_rls_toolchain = 'stable'
- AssertEqual
- \ ale#Escape('rls') . ' +' . ale#Escape('stable'),
- \ ale_linters#rust#rls#GetCommand(bufnr(''))
+ AssertLinter 'rls', ale#Escape('rls') . ' +' . ale#Escape('stable')
Execute(The toolchain should be ommitted if not given):
let g:ale_rust_rls_toolchain = ''
- AssertEqual
- \ ale#Escape('rls'),
- \ ale_linters#rust#rls#GetCommand(bufnr(''))
+ AssertLinter 'rls', ale#Escape('rls')
Execute(The project root should be detected correctly):
- AssertEqual '', ale_linters#rust#rls#GetProjectRoot(bufnr(''))
+ AssertLSPProject ''
call ale#test#SetFilename('rust-rls-project/test.rs')
- AssertEqual
- \ ale#path#Simplify(g:dir . '/rust-rls-project'),
- \ ale_linters#rust#rls#GetProjectRoot(bufnr(''))
+ AssertLSPProject ale#path#Simplify(g:dir . '/rust-rls-project')
diff --git a/test/command_callback/test_rustc_command_callback.vader b/test/command_callback/test_rustc_command_callback.vader
index fe46c9ad..7ca02760 100644
--- a/test/command_callback/test_rustc_command_callback.vader
+++ b/test/command_callback/test_rustc_command_callback.vader
@@ -1,37 +1,21 @@
Before:
- Save g:ale_rust_rustc_options
-
- unlet! g:ale_rust_rustc_options
-
- runtime ale_linters/rust/rustc.vim
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('rust', 'rustc')
After:
- Restore
-
- unlet! b:ale_rust_rustc_options
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual
- \ 'rustc --error-format=json -Z no-trans -',
- \ ale_linters#rust#rustc#RustcCommand(bufnr(''))
+ AssertLinter 'rustc', 'rustc --error-format=json -Z no-trans -'
Execute(The options should be configurable):
let b:ale_rust_rustc_options = '--foo'
- AssertEqual
- \ 'rustc --error-format=json --foo -',
- \ ale_linters#rust#rustc#RustcCommand(bufnr(''))
+ AssertLinter 'rustc', 'rustc --error-format=json --foo -'
Execute(Some default paths should be included when the project is a Cargo project):
call ale#test#SetFilename('cargo_paths/test.rs')
- AssertEqual
- \ 'rustc --error-format=json -Z no-trans'
+ AssertLinter 'rustc', 'rustc --error-format=json -Z no-trans'
\ . ' -L ' . ale#Escape(ale#path#GetAbsPath(g:dir, 'cargo_paths/target/debug/deps'))
\ . ' -L ' . ale#Escape(ale#path#GetAbsPath(g:dir, 'cargo_paths/target/release/deps'))
- \ . ' -',
- \ ale_linters#rust#rustc#RustcCommand(bufnr(''))
+ \ . ' -'
diff --git a/test/command_callback/test_sasslint_command_callback.vader b/test/command_callback/test_sasslint_command_callback.vader
index 1db7e5fb..4d7cc4c7 100644
--- a/test/command_callback/test_sasslint_command_callback.vader
+++ b/test/command_callback/test_sasslint_command_callback.vader
@@ -1,12 +1,11 @@
Before:
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('sass', 'sasslint')
call ale#test#SetFilename('test.sass')
After:
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(The default sasslint command should be correct):
- AssertEqual
+ AssertLinter 'sass-lint',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
- \ . ale#Escape('sass-lint') . ' -v -q -f compact %t',
- \ ale#handlers#sasslint#GetCommand(bufnr(''))
+ \ . ale#Escape('sass-lint') . ' -v -q -f compact %t'
diff --git a/test/command_callback/test_scalac_command_callback.vader b/test/command_callback/test_scalac_command_callback.vader
index 6bb31b3f..115731b3 100644
--- a/test/command_callback/test_scalac_command_callback.vader
+++ b/test/command_callback/test_scalac_command_callback.vader
@@ -1,17 +1,13 @@
Before:
- runtime ale_linters/scala/scalac.vim
+ call ale#assert#SetUpLinterTest('scala', 'scalac')
After:
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Given scala(An empty Scala file):
Execute(The default executable and command should be correct):
- AssertEqual 'scalac', ale_linters#scala#scalac#GetExecutable(bufnr(''))
- AssertEqual
- \ ale#Escape('scalac') . ' -Ystop-after:parser %t',
- \ ale_linters#scala#scalac#GetCommand(bufnr(''))
+ AssertLinter 'scalac', ale#Escape('scalac') . ' -Ystop-after:parser %t'
Given scala.sbt(An empty SBT file):
Execute(scalac should not be run for sbt files):
- AssertEqual '', ale_linters#scala#scalac#GetExecutable(bufnr(''))
- AssertEqual '', ale_linters#scala#scalac#GetCommand(bufnr(''))
+ AssertLinter '', ''
diff --git a/test/command_callback/test_scalastyle_command_callback.vader b/test/command_callback/test_scalastyle_command_callback.vader
index 953d57b3..3c28f7a3 100644
--- a/test/command_callback/test_scalastyle_command_callback.vader
+++ b/test/command_callback/test_scalastyle_command_callback.vader
@@ -1,36 +1,34 @@
Before:
- Save g:ale_scala_scalastyle_options
- Save g:ale_scalastyle_config_loc
-
- unlet! g:ale_scala_scalastyle_options
- unlet! g:ale_scalastyle_config_loc
-
- runtime ale_linters/scala/scalastyle.vim
+ call ale#assert#SetUpLinterTest('scala', 'scalastyle')
After:
- Restore
-
+ unlet! g:ale_scalastyle_config_loc
call ale#linter#Reset()
Execute(Should return the correct default command):
- AssertEqual
- \ 'scalastyle %t',
- \ ale_linters#scala#scalastyle#GetCommand(bufnr(''))
+ AssertLinter 'scalastyle', 'scalastyle %t'
Execute(Should allow using a custom config file):
+ let b:ale_scala_scalastyle_config = '/dooper/config.xml'
+
+ AssertLinter 'scalastyle', 'scalastyle'
+ \ . ' --config ' . ale#Escape('/dooper/config.xml')
+ \ . ' %t'
+
+Execute(Should support a legacy option for the scalastyle config):
+ unlet! g:ale_scala_scalastyle_config
let g:ale_scalastyle_config_loc = '/dooper/config.xml'
- AssertEqual
- \ 'scalastyle'
- \ . ' --config ' . ale#Escape('/dooper/config.xml')
- \ . ' %t',
- \ ale_linters#scala#scalastyle#GetCommand(bufnr(''))
+ call ale#linter#Reset()
+ runtime ale_linters/scala/scalastyle.vim
+
+ AssertLinter 'scalastyle', 'scalastyle'
+ \ . ' --config ' . ale#Escape('/dooper/config.xml')
+ \ . ' %t'
Execute(Should allow using custom options):
- let g:ale_scala_scalastyle_options = '--warnings false --quiet true'
+ let b:ale_scala_scalastyle_options = '--warnings false --quiet true'
- AssertEqual
- \ 'scalastyle'
+ AssertLinter 'scalastyle', 'scalastyle'
\ . ' --warnings false --quiet true'
- \ . ' %t',
- \ ale_linters#scala#scalastyle#GetCommand(bufnr(''))
+ \ . ' %t'
diff --git a/test/command_callback/test_shellcheck_command_callback.vader b/test/command_callback/test_shellcheck_command_callback.vader
index 68694b67..23684026 100644
--- a/test/command_callback/test_shellcheck_command_callback.vader
+++ b/test/command_callback/test_shellcheck_command_callback.vader
@@ -1,129 +1,95 @@
Before:
- Save g:ale_sh_shellcheck_exclusions
- Save g:ale_sh_shellcheck_executable
- Save g:ale_sh_shellcheck_options
-
- unlet! g:ale_sh_shellcheck_exclusions
- unlet! g:ale_sh_shellcheck_executable
- unlet! g:ale_sh_shellcheck_options
-
- runtime ale_linters/sh/shellcheck.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('sh', 'shellcheck')
call ale#test#SetFilename('test.sh')
let b:prefix = 'cd ' . ale#Escape(ale#path#Simplify(g:dir)) . ' && '
let b:suffix = ' -f gcc -'
After:
- Restore
-
- unlet! b:ale_sh_shellcheck_exclusions
- unlet! b:ale_sh_shellcheck_executable
- unlet! b:ale_sh_shellcheck_options
unlet! b:is_bash
unlet! b:prefix
-
- call ale#test#RestoreDirectory()
-
- call ale#linter#Reset()
+ unlet! b:suffix
+ call ale#assert#TearDownLinterTest()
Execute(The default shellcheck command should be correct):
- AssertEqual
- \ b:prefix . ale#Escape('shellcheck') . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
+ AssertLinter 'shellcheck', b:prefix . ale#Escape('shellcheck') . b:suffix
Execute(The shellcheck command should accept options):
let b:ale_sh_shellcheck_options = '--foobar'
- AssertEqual
- \ b:prefix . ale#Escape('shellcheck') . ' --foobar' . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
+ AssertLinter 'shellcheck',
+ \ b:prefix . ale#Escape('shellcheck') . ' --foobar' . b:suffix
Execute(The shellcheck command should accept options and exclusions):
let b:ale_sh_shellcheck_options = '--foobar'
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
- AssertEqual
- \ b:prefix . ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
+ AssertLinter 'shellcheck',
+ \ b:prefix . ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix
Execute(The shellcheck command should include the dialect):
let b:is_bash = 1
- AssertEqual
- \ b:prefix . ale#Escape('shellcheck') . ' -s bash' . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
+ AssertLinter 'shellcheck',
+ \ b:prefix . ale#Escape('shellcheck') . ' -s bash' . 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'
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
- AssertEqual
- \ b:prefix
- \ . ale#Escape('shellcheck')
+ AssertLinter 'shellcheck', b:prefix . ale#Escape('shellcheck')
\ . ' -s bash --foobar -e foo,bar'
- \ . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
+ \ . b:suffix
-Execute(The VersionCheck function should return the --version command):
- AssertEqual
+Execute(The -x option should be added when the version is new enough):
+ AssertLinter 'shellcheck', [
\ ale#Escape('shellcheck') . ' --version',
- \ ale_linters#sh#shellcheck#VersionCheck(bufnr(''))
-
- let g:ale_sh_shellcheck_executable = 'foobar'
-
- AssertEqual
- \ ale#Escape('foobar') . ' --version',
- \ ale_linters#sh#shellcheck#VersionCheck(bufnr(''))
+ \ b:prefix . ale#Escape('shellcheck') . b:suffix,
+ \]
-Execute(The -x option should be added when the version is new enough):
- AssertEqual
+ WithChainResults [
+ \ 'ShellCheck - shell script analysis tool',
+ \ 'version: 0.4.4',
+ \ 'license: GNU General Public License, version 3',
+ \ 'website: http://www.shellcheck.net',
+ \]
+ AssertLinter 'shellcheck', [
+ \ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [
- \ 'ShellCheck - shell script analysis tool',
- \ 'version: 0.4.4',
- \ 'license: GNU General Public License, version 3',
- \ 'website: http://www.shellcheck.net',
- \ ])
+ \]
" We should cache the version check
- AssertEqual
+ WithChainResults []
+ AssertLinter 'shellcheck', [
+ \ '',
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
-
- AssertEqual '', ale_linters#sh#shellcheck#VersionCheck(bufnr(''))
+ \]
-Execute(The version check shouldn't be run again for new versions):
- call ale_linters#sh#shellcheck#GetCommand(bufnr(''), [
+Execute(The -x option should not be added when the version is too old):
+ WithChainResults [
\ 'ShellCheck - shell script analysis tool',
- \ 'version: 0.4.4',
+ \ 'version: 0.3.9',
\ 'license: GNU General Public License, version 3',
\ 'website: http://www.shellcheck.net',
- \])
-
-Execute(The -x option should not be added when the version is too old):
- AssertEqual
- \ b:prefix . ale#Escape('shellcheck') . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [
- \ 'ShellCheck - shell script analysis tool',
- \ 'version: 0.3.9',
- \ 'license: GNU General Public License, version 3',
- \ 'website: http://www.shellcheck.net',
- \ ])
-
- " We should cache the version check
- AssertEqual
+ \]
+ AssertLinter 'shellcheck', [
+ \ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
- \ ale_linters#sh#shellcheck#GetCommand(bufnr(''), [])
+ \]
Execute(The version check shouldn't be run again for old versions):
- call ale_linters#sh#shellcheck#GetCommand(bufnr(''), [
+ WithChainResults [
\ 'ShellCheck - shell script analysis tool',
\ 'version: 0.3.9',
\ 'license: GNU General Public License, version 3',
\ 'website: http://www.shellcheck.net',
- \])
-
- AssertEqual '', ale_linters#sh#shellcheck#VersionCheck(bufnr(''))
+ \]
+ AssertLinter 'shellcheck', [
+ \ ale#Escape('shellcheck') . ' --version',
+ \ b:prefix . ale#Escape('shellcheck') . b:suffix,
+ \]
+ AssertLinter 'shellcheck', [
+ \ '',
+ \ b:prefix . ale#Escape('shellcheck') . b:suffix,
+ \]
diff --git a/test/command_callback/test_slimlint_command_callback.vader b/test/command_callback/test_slimlint_command_callback.vader
index 38588a1f..3522c2fa 100644
--- a/test/command_callback/test_slimlint_command_callback.vader
+++ b/test/command_callback/test_slimlint_command_callback.vader
@@ -1,39 +1,19 @@
Before:
- runtime ale_linters/slim/slimlint.vim
-
+ call ale#assert#SetUpLinterTest('slim', 'slimlint')
let g:default_command = 'slim-lint %t'
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
After:
- Restore
-
- unlet! g:default_command
- unlet! b:conf
-
- call ale#linter#Reset()
- call ale#test#RestoreDirectory()
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual g:default_command, ale_linters#slim#slimlint#GetCommand(bufnr(''))
+ AssertLinter 'slim-lint', 'slim-lint %t'
Execute(The command should have the .rubocop.yml prepended as an env var if one exists):
call ale#test#SetFilename('../slimlint-test-files/subdir/file.slim')
- let b:conf = ale#path#Simplify(g:dir . '/../slimlint-test-files/.rubocop.yml')
-
- if has('win32')
- " Windows uses 'set var=... && command'
- AssertEqual
- \ 'set SLIM_LINT_RUBOCOP_CONF='
- \ . ale#Escape(b:conf)
- \ . ' && ' . g:default_command,
- \ ale_linters#slim#slimlint#GetCommand(bufnr(''))
- else
- " Unix uses 'var=... command'
- AssertEqual
- \ 'SLIM_LINT_RUBOCOP_CONF='
- \ . ale#Escape(b:conf)
- \ . ' ' . g:default_command,
- \ ale_linters#slim#slimlint#GetCommand(bufnr(''))
- endif
+ AssertLinter 'slim-lint',
+ \ ale#Env(
+ \ 'SLIM_LINT_RUBOCOP_CONF',
+ \ ale#path#Simplify(g:dir . '/../slimlint-test-files/.rubocop.yml')
+ \ )
+ \ . 'slim-lint %t'
diff --git a/test/command_callback/test_standard_command_callback.vader b/test/command_callback/test_standard_command_callback.vader
index 3dee2856..a47e2ec9 100644
--- a/test/command_callback/test_standard_command_callback.vader
+++ b/test/command_callback/test_standard_command_callback.vader
@@ -1,28 +1,10 @@
Before:
- Save g:ale_javascript_standard_executable
- Save g:ale_javascript_standard_use_global
- Save g:ale_javascript_standard_options
-
- unlet! b:executable
- unlet! g:ale_javascript_standard_executable
- unlet! b:ale_javascript_standard_executable
- unlet! g:ale_javascript_standard_use_global
- unlet! g:ale_javascript_standard_options
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('javascript', 'standard')
call ale#test#SetFilename('testfile.js')
-
- runtime ale_linters/javascript/standard.vim
-
-After:
- Restore
-
unlet! b:executable
- call ale#test#SetFilename('test.txt')
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+After:
+ call ale#assert#TearDownLinterTest()
Execute(bin/cmd.js paths should be preferred):
call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js')
@@ -32,15 +14,10 @@ Execute(bin/cmd.js paths should be preferred):
\ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js'
\)
- AssertEqual
- \ b:executable,
- \ ale_linters#javascript#standard#GetExecutable(bufnr(''))
-
- AssertEqual
+ AssertLinter b:executable,
\ (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(b:executable)
- \ . ' --stdin %s',
- \ ale_linters#javascript#standard#GetCommand(bufnr(''))
+ \ . ' --stdin %s'
Execute(.bin directories should be used too):
call ale#test#SetFilename('standard-test-files/with-bin/testfile.js')
@@ -50,38 +27,17 @@ Execute(.bin directories should be used too):
\ . '/standard-test-files/with-bin/node_modules/.bin/standard'
\)
- AssertEqual
- \ b:executable,
- \ ale_linters#javascript#standard#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape(b:executable)
- \ . ' --stdin %s',
- \ ale_linters#javascript#standard#GetCommand(bufnr(''))
+ AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin %s'
Execute(The global executable should be used otherwise):
- AssertEqual
- \ 'standard',
- \ ale_linters#javascript#standard#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape('standard') . ' --stdin %s',
- \ ale_linters#javascript#standard#GetCommand(bufnr(''))
+ AssertLinter 'standard', ale#Escape('standard') . ' --stdin %s'
Execute(The global executable should be configurable):
let b:ale_javascript_standard_executable = 'foobar'
- AssertEqual
- \ 'foobar',
- \ ale_linters#javascript#standard#GetExecutable(bufnr(''))
-
- AssertEqual
- \ ale#Escape('foobar') . ' --stdin %s',
- \ ale_linters#javascript#standard#GetCommand(bufnr(''))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin %s'
Execute(The options should be configurable):
let b:ale_javascript_standard_options = '--wat'
- AssertEqual
- \ ale#Escape('standard') . ' --wat --stdin %s',
- \ ale_linters#javascript#standard#GetCommand(bufnr(''))
+ AssertLinter 'standard', ale#Escape('standard') . ' --wat --stdin %s'
diff --git a/test/command_callback/test_staticcheck_command_callback.vader b/test/command_callback/test_staticcheck_command_callback.vader
index e9628eb6..918c12a0 100644
--- a/test/command_callback/test_staticcheck_command_callback.vader
+++ b/test/command_callback/test_staticcheck_command_callback.vader
@@ -1,41 +1,26 @@
Before:
- Save b:ale_go_staticcheck_options
- Save b:ale_go_staticcheck_lint_package
-
- let b:ale_go_staticcheck_options = ''
- let b:ale_go_staticcheck_lint_package = 0
-
- runtime ale_linters/go/staticcheck.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('go', 'staticcheck')
call ale#test#SetFilename('test.go')
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The staticcheck callback should return the right defaults):
- AssertEqual
+ AssertLinter 'staticcheck',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'staticcheck '
- \ . ale#Escape(expand('%' . ':t')),
- \ ale_linters#go#staticcheck#GetCommand(bufnr(''))
+ \ . ale#Escape(expand('%' . ':t'))
Execute(The staticcheck callback should use configured options):
let b:ale_go_staticcheck_options = '-test'
- AssertEqual
+ AssertLinter 'staticcheck',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . 'staticcheck '
- \ . '-test ' . ale#Escape(expand('%' . ':t')),
- \ ale_linters#go#staticcheck#GetCommand(bufnr(''))
+ \ . '-test ' . ale#Escape(expand('%' . ':t'))
Execute(The staticcheck `lint_package` option should use the correct command):
let b:ale_go_staticcheck_lint_package = 1
- AssertEqual
- \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
- \ . 'staticcheck .',
- \ ale_linters#go#staticcheck#GetCommand(bufnr(''))
+ AssertLinter 'staticcheck',
+ \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && staticcheck .',
diff --git a/test/command_callback/test_swaglint_command_callback.vader b/test/command_callback/test_swaglint_command_callback.vader
index 51a10094..fe8fb722 100644
--- a/test/command_callback/test_swaglint_command_callback.vader
+++ b/test/command_callback/test_swaglint_command_callback.vader
@@ -1,43 +1,29 @@
Before:
- runtime ale_linters/yaml/swaglint.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('yaml', 'swaglint')
After:
- let g:ale_yaml_swaglint_executable = 'swaglint'
- let g:ale_yaml_swaglint_use_global = 0
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The yaml swaglint command callback should return the correct default string):
- AssertEqual 'swaglint',
- \ ale_linters#yaml#swaglint#GetExecutable(bufnr(''))
- AssertEqual 'swaglint -r compact --stdin',
- \ ale_linters#yaml#swaglint#GetCommand(bufnr(''))
+ AssertLinter 'swaglint', 'swaglint -r compact --stdin'
Execute(The yaml swaglint command callback should be configurable):
let g:ale_yaml_swaglint_executable = '~/.local/bin/swaglint'
- AssertEqual '~/.local/bin/swaglint',
- \ ale_linters#yaml#swaglint#GetExecutable(bufnr(''))
- AssertEqual '~/.local/bin/swaglint -r compact --stdin',
- \ ale_linters#yaml#swaglint#GetCommand(bufnr(''))
+
+ AssertLinter '~/.local/bin/swaglint',
+ \ '~/.local/bin/swaglint -r compact --stdin'
Execute(The yaml swaglint command callback should allow a global installation to be used):
let g:ale_yaml_swaglint_executable = '/usr/local/bin/swaglint'
let g:ale_yaml_swaglint_use_global = 1
- AssertEqual '/usr/local/bin/swaglint',
- \ ale_linters#yaml#swaglint#GetExecutable(bufnr(''))
- AssertEqual '/usr/local/bin/swaglint -r compact --stdin',
- \ ale_linters#yaml#swaglint#GetCommand(bufnr(''))
+
+ AssertLinter '/usr/local/bin/swaglint',
+ \ '/usr/local/bin/swaglint -r compact --stdin'
Execute(The yaml swaglint command callback should allow a local installation to be used):
call ale#test#SetFilename('swaglint_paths/docs/swagger.yaml')
- AssertEqual
+ AssertLinter
\ ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint'),
- \ ale_linters#yaml#swaglint#GetExecutable(bufnr(''))
-
- AssertEqual
\ ale#path#Simplify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint')
- \ . ' -r compact --stdin',
- \ ale_linters#yaml#swaglint#GetCommand(bufnr(''))
+ \ . ' -r compact --stdin'
diff --git a/test/command_callback/test_terraform_tflint_command_callback.vader b/test/command_callback/test_terraform_tflint_command_callback.vader
index a4ae56b0..c32d9bcf 100644
--- a/test/command_callback/test_terraform_tflint_command_callback.vader
+++ b/test/command_callback/test_terraform_tflint_command_callback.vader
@@ -1,30 +1,19 @@
Before:
- Save g:ale_terraform_tflint_executable
- Save g:ale_terraform_tflint_options
-
- runtime ale_linters/terraform/tflint.vim
+ call ale#assert#SetUpLinterTest('terraform', 'tflint')
After:
- Restore
+ call ale#assert#TearDownLinterTest()
- call ale#linter#Reset()
+Execute(The default command should be correct):
+ AssertLinter 'tflint', ale#Escape('tflint') . ' -f json %t'
Execute(The default executable should be configurable):
- AssertEqual 'tflint', ale_linters#terraform#tflint#GetExecutable(bufnr(''))
-
- let g:ale_terraform_tflint_executable = 'asdf'
+ let b:ale_terraform_tflint_executable = 'asdf'
- AssertEqual 'asdf', ale_linters#terraform#tflint#GetExecutable(bufnr(''))
+ AssertLinter 'asdf', ale#Escape('asdf') . ' -f json %t'
-Execute(The default command should be good):
- let g:ale_terraform_tflint_executable = 'tflint'
- AssertEqual
- \ ale#Escape('tflint') . ' -f json %t',
- \ ale_linters#terraform#tflint#GetCommand(bufnr(''))
-
-Execute(Overriding things should work):
+Execute(Overriding options should work):
let g:ale_terraform_tflint_executable = 'fnord'
let g:ale_terraform_tflint_options = '--whatever'
- AssertEqual
- \ ale#Escape('fnord') . ' --whatever -f json %t',
- \ ale_linters#terraform#tflint#GetCommand(bufnr(''))
+
+ AssertLinter 'fnord', ale#Escape('fnord') . ' --whatever -f json %t'
diff --git a/test/command_callback/test_textlint_command_callbacks.vader b/test/command_callback/test_textlint_command_callbacks.vader
index 212f34d3..794c7fde 100644
--- a/test/command_callback/test_textlint_command_callbacks.vader
+++ b/test/command_callback/test_textlint_command_callbacks.vader
@@ -1,85 +1,65 @@
" Author: januswel, w0rp
Before:
+ " This is just one language for the linter.
+ call ale#assert#SetUpLinterTest('markdown', 'textlint')
+
+ " The configuration is shared between many languages.
Save g:ale_textlint_executable
Save g:ale_textlint_use_global
Save g:ale_textlint_options
- unlet! g:ale_textlint_executable
+ let g:ale_textlint_executable = 'textlint'
+ let g:ale_textlint_use_global = 0
+ let g:ale_textlint_options = ''
+
unlet! b:ale_textlint_executable
- unlet! g:ale_textlint_use_global
unlet! b:ale_textlint_use_global
- unlet! g:ale_textlint_options
unlet! b:ale_textlint_options
- runtime autoload/ale/handlers/textlint.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
-
After:
- Restore
-
unlet! b:command_tail
unlet! b:ale_textlint_executable
unlet! b:ale_textlint_use_global
unlet! b:ale_textlint_options
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
-Execute(The executable should be configurable):
- AssertEqual 'textlint', ale#handlers#textlint#GetExecutable(bufnr(''))
-
- let b:ale_textlint_executable = 'foobar'
-
- AssertEqual 'foobar', ale#handlers#textlint#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('textlint') . ' -f json --stdin --stdin-filename %s',
- \ ale#handlers#textlint#GetCommand(bufnr(''))
+Execute(The default command should be correct):
+ AssertLinter 'textlint',
+ \ ale#Escape('textlint') . ' -f json --stdin --stdin-filename %s'
+Execute(The executable should be configurable):
let b:ale_textlint_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . ' -f json --stdin --stdin-filename %s',
- \ ale#handlers#textlint#GetCommand(bufnr(''))
- \
+ AssertLinter 'foobar',
+ \ ale#Escape('foobar') . ' -f json --stdin --stdin-filename %s'
Execute(The options should be configurable):
let b:ale_textlint_options = '--something'
- AssertEqual
- \ ale#Escape('textlint') . ' --something -f json --stdin --stdin-filename %s',
- \ ale#handlers#textlint#GetCommand(bufnr(''))
+ AssertLinter 'textlint',
+ \ ale#Escape('textlint') . ' --something -f json --stdin --stdin-filename %s'
Execute(The local executable from .bin should be used if available):
call ale#test#SetFilename('textlint_paths/with_bin_path/foo.txt')
- AssertEqual
+ AssertLinter
\ ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'),
- \ ale#handlers#textlint#GetExecutable(bufnr(''))
-
- AssertEqual
\ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'))
- \ . ' -f json --stdin --stdin-filename %s',
- \ ale#handlers#textlint#GetCommand(bufnr(''))
+ \ . ' -f json --stdin --stdin-filename %s'
Execute(The local executable from textlint/bin should be used if available):
call ale#test#SetFilename('textlint_paths/with_textlint_bin_path/foo.txt')
- AssertEqual
- \ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'),
- \ ale#handlers#textlint#GetExecutable(bufnr(''))
-
if has('win32')
- AssertEqual
+ AssertLinter
+ \ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'),
\ ale#Escape('node.exe') . ' ' . ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'))
- \ . ' -f json --stdin --stdin-filename %s',
- \ ale#handlers#textlint#GetCommand(bufnr(''))
+ \ . ' -f json --stdin --stdin-filename %s'
else
- AssertEqual
+ AssertLinter
+ \ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'),
\ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'))
- \ . ' -f json --stdin --stdin-filename %s',
- \ ale#handlers#textlint#GetCommand(bufnr(''))
+ \ . ' -f json --stdin --stdin-filename %s'
endif
diff --git a/test/command_callback/test_thrift_command_callback.vader b/test/command_callback/test_thrift_command_callback.vader
index 7d4e436c..ea217259 100644
--- a/test/command_callback/test_thrift_command_callback.vader
+++ b/test/command_callback/test_thrift_command_callback.vader
@@ -1,13 +1,6 @@
Before:
- Save g:ale_thrift_thrift_executable
- Save g:ale_thrift_thrift_generators
- Save g:ale_thrift_thrift_includes
- Save g:ale_thrift_thrift_options
-
- unlet! b:ale_thrift_thrift_executable
- unlet! b:ale_thrift_thrift_generators
- unlet! b:ale_thrift_thrift_includes
- unlet! b:ale_thrift_thrift_options
+ call ale#assert#SetUpLinterTest('thrift', 'thrift')
+ let b:suffix = ' -out ' . ale#Escape('TEMP_DIR') . ' %t'
function! GetCommand(buffer) abort
call ale#engine#InitBufferInfo(a:buffer)
@@ -24,62 +17,37 @@ Before:
return join(l:split_command)
endfunction
- runtime ale_linters/thrift/thrift.vim
-
After:
- Restore
-
+ unlet! b:suffix
delfunction GetCommand
- unlet! b:ale_thrift_thrift_executable
- unlet! b:ale_thrift_thrift_generators
- unlet! b:ale_thrift_thrift_includes
- unlet! b:ale_thrift_thrift_options
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
-Execute(The executable should be configurable):
- AssertEqual 'thrift', ale_linters#thrift#thrift#GetExecutable(bufnr(''))
+Execute(The default command should be correct):
+ AssertLinter 'thrift', ale#Escape('thrift') . ' --gen cpp -strict' . b:suffix
+Execute(The executable should be configurable):
let b:ale_thrift_thrift_executable = 'foobar'
- AssertEqual 'foobar', ale_linters#thrift#thrift#GetExecutable(bufnr(''))
-
-Execute(The executable should be used in the command):
- AssertEqual
- \ ale#Escape('thrift') . ' --gen cpp -strict -out TEMP %t',
- \ GetCommand(bufnr('%'))
- let b:ale_thrift_thrift_executable = 'foobar'
- AssertEqual
- \ ale#Escape('foobar') . ' --gen cpp -strict -out TEMP %t',
- \ GetCommand(bufnr('%'))
+ AssertLinter 'foobar', ale#Escape('foobar') . ' --gen cpp -strict' . b:suffix
Execute(The list of generators should be configurable):
let b:ale_thrift_thrift_generators = ['java', 'py:dynamic']
- AssertEqual
- \ ale#Escape('thrift') . ' --gen java --gen py:dynamic -strict -out TEMP %t',
- \ GetCommand(bufnr('%'))
+ AssertLinter 'thrift', ale#Escape('thrift')
+ \ . ' --gen java --gen py:dynamic -strict' . b:suffix
let b:ale_thrift_thrift_generators = []
- AssertEqual
- \ ale#Escape('thrift') . ' --gen cpp -strict -out TEMP %t',
- \ GetCommand(bufnr('%'))
+ AssertLinter 'thrift', ale#Escape('thrift') . ' --gen cpp -strict' . b:suffix
Execute(The list of include paths should be configurable):
let b:ale_thrift_thrift_includes = ['included/path']
- AssertEqual
- \ ale#Escape('thrift')
- \ . ' --gen cpp'
- \ . ' -I included/path'
- \ . ' -strict -out TEMP %t',
- \ GetCommand(bufnr('%'))
+ AssertLinter 'thrift', ale#Escape('thrift')
+ \ . ' --gen cpp -I included/path -strict' . b:suffix
Execute(The string of compiler options should be configurable):
let b:ale_thrift_thrift_options = '-strict --allow-64bit-consts'
- AssertEqual
- \ ale#Escape('thrift')
- \ . ' --gen cpp -strict --allow-64bit-consts'
- \ . ' -out TEMP %t',
- \ GetCommand(bufnr('%'))
+ AssertLinter 'thrift', ale#Escape('thrift')
+ \ . ' --gen cpp -strict --allow-64bit-consts' . b:suffix
diff --git a/test/command_callback/test_tslint_command_callback.vader b/test/command_callback/test_tslint_command_callback.vader
index 0c2f3abf..bd8a12ec 100644
--- a/test/command_callback/test_tslint_command_callback.vader
+++ b/test/command_callback/test_tslint_command_callback.vader
@@ -1,43 +1,19 @@
Before:
- call ale#assert#Init()
-
- Save g:ale_typescript_tslint_executable
- Save g:ale_typescript_tslint_config_path
- Save g:ale_typescript_tslint_rules_dir
- Save g:ale_typescript_tslint_use_global
-
- unlet! g:ale_typescript_tslint_executable
- unlet! g:ale_typescript_tslint_config_path
- unlet! g:ale_typescript_tslint_rules_dir
- unlet! g:ale_typescript_tslint_use_global
-
- runtime ale_linters/typescript/tslint.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#assert#SetUpLinterTest('typescript', 'tslint')
call ale#test#SetFilename('test.ts')
After:
- Restore
-
- unlet! b:ale_typescript_tslint_executable
- unlet! b:ale_typescript_tslint_config_path
- unlet! b:ale_typescript_tslint_rules_dir
- unlet! b:ale_typescript_tslint_use_global
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The default tslint command should be correct):
- AssertLinter
- \ 'tslint',
+ AssertLinter 'tslint',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('tslint') . ' --format json %t'
Execute(The rules directory option should be included if set):
let b:ale_typescript_tslint_rules_dir = '/foo/bar'
- AssertLinter
- \ 'tslint',
+ AssertLinter 'tslint',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('tslint') . ' --format json'
\ . ' -r ' . ale#Escape('/foo/bar')
@@ -46,7 +22,6 @@ Execute(The rules directory option should be included if set):
Execute(The executable should be configurable and escaped):
let b:ale_typescript_tslint_executable = 'foo bar'
- AssertLinter
- \ 'foo bar',
+ AssertLinter 'foo bar',
\ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
\ . ale#Escape('foo bar') . ' --format json %t'
diff --git a/test/command_callback/test_vint_command_callback.vader b/test/command_callback/test_vint_command_callback.vader
index ddf39f31..e0051f26 100644
--- a/test/command_callback/test_vint_command_callback.vader
+++ b/test/command_callback/test_vint_command_callback.vader
@@ -1,39 +1,23 @@
Before:
- Save g:ale_vim_vint_executable
-
- unlet! g:ale_vim_vint_executable
-
- runtime ale_linters/vim/vint.vim
-
+ call ale#assert#SetUpLinterTest('vim', 'vint')
let b:command_tail = (has('nvim') ? ' --enable-neovim' : '')
\ . ' -f "{file_path}:{line_number}:{column_number}: {severity}: {description} (see {reference})" %t'
- call ale#semver#ResetVersionCache()
After:
- Restore
-
- call ale#linter#Reset()
- call ale#semver#ResetVersionCache()
-
unlet! b:bin_dir
unlet! b:executable
+ call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
- AssertEqual 'vint', ale_linters#vim#vint#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'vint', [
\ ale#Escape('vint') .' --version',
- \ ale_linters#vim#vint#VersionCommand(bufnr(''))
- AssertEqual
\ ale#Escape('vint') .' -s --no-color' . b:command_tail,
- \ ale_linters#vim#vint#GetCommand(bufnr(''), [])
+ \]
Execute(The executable should be configurable):
let g:ale_vim_vint_executable = 'foobar'
- AssertEqual 'foobar', ale_linters#vim#vint#GetExecutable(bufnr(''))
- AssertEqual
+ AssertLinter 'foobar', [
\ ale#Escape('foobar') .' --version',
- \ ale_linters#vim#vint#VersionCommand(bufnr(''))
- AssertEqual
\ ale#Escape('foobar') .' -s --no-color' . b:command_tail,
- \ ale_linters#vim#vint#GetCommand(bufnr(''), [])
+ \]
diff --git a/test/command_callback/test_write_good_command_callback.vader b/test/command_callback/test_write_good_command_callback.vader
index 4b5ed7b7..9ffa39bd 100644
--- a/test/command_callback/test_write_good_command_callback.vader
+++ b/test/command_callback/test_write_good_command_callback.vader
@@ -1,6 +1,8 @@
Before:
- call ale#assert#Init()
+ " This is just one example of a language using the linter.
+ call ale#assert#SetUpLinterTest('markdown', 'writegood')
+ " The options are shared between many languages.
Save g:ale_writegood_options
Save g:ale_writegood_executable
Save g:ale_writegood_use_global
@@ -9,18 +11,11 @@ Before:
unlet! g:ale_writegood_executable
unlet! g:ale_writegood_use_global
- runtime ale_linters/markdown/write-good.vim
-
- call ale#test#SetDirectory('/testplugin/test/command_callback')
call ale#test#SetFilename('testfile.txt')
-
call ale#handlers#writegood#ResetOptions()
After:
- Restore
-
- call ale#test#RestoreDirectory()
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The global executable should be used when the local one cannot be found):
AssertLinter
diff --git a/test/command_callback/test_xmllint_command_callback.vader b/test/command_callback/test_xmllint_command_callback.vader
index 12ca15de..5a2377c2 100644
--- a/test/command_callback/test_xmllint_command_callback.vader
+++ b/test/command_callback/test_xmllint_command_callback.vader
@@ -1,25 +1,20 @@
Before:
- runtime ale_linters/xml/xmllint.vim
+ call ale#assert#SetUpLinterTest('xml', 'xmllint')
After:
- let g:ale_xml_xmllint_options = ''
- let g:ale_xml_xmllint_executable = 'xmllint'
-
- call ale#linter#Reset()
+ call ale#assert#TearDownLinterTest()
Execute(The xml xmllint command callback should return the correct default string):
- AssertEqual ale#Escape('xmllint') . ' --noout -',
- \ join(split(ale_linters#xml#xmllint#GetCommand(1)))
+ AssertLinter 'xmllint', ale#Escape('xmllint') . ' --noout -'
Execute(The xml xmllint command callback should let you set options):
let g:ale_xml_xmllint_options = '--xinclude --postvalid'
- AssertEqual ale#Escape('xmllint') . ' --xinclude --postvalid --noout -',
- \ join(split(ale_linters#xml#xmllint#GetCommand(1)))
+ AssertLinter 'xmllint',
+ \ ale#Escape('xmllint') . ' --xinclude --postvalid --noout -'
Execute(The xmllint executable should be configurable):
let g:ale_xml_xmllint_executable = '~/.local/bin/xmllint'
- AssertEqual '~/.local/bin/xmllint', ale_linters#xml#xmllint#GetExecutable(1)
- AssertEqual ale#Escape('~/.local/bin/xmllint') . ' --noout -',
- \ join(split(ale_linters#xml#xmllint#GetCommand(1)))
+ AssertLinter '~/.local/bin/xmllint',
+ \ ale#Escape('~/.local/bin/xmllint') . ' --noout -'
diff --git a/test/fixers/test_tslint_fixer_callback.vader b/test/fixers/test_tslint_fixer_callback.vader
index 5bfafe24..aa9c0322 100644
--- a/test/fixers/test_tslint_fixer_callback.vader
+++ b/test/fixers/test_tslint_fixer_callback.vader
@@ -2,13 +2,16 @@ Before:
Save g:ale_typescript_tslint_executable
Save g:ale_typescript_tslint_config_path
- let g:ale_typescript_tslint_executable = 'xxxinvalid'
- let g:ale_typescript_tslint_config_path = 'tslint.json'
+ unlet! g:ale_typescript_tslint_executable
+ unlet! g:ale_typescript_tslint_config_path
+ unlet! b:ale_typescript_tslint_executable
+ unlet! b:ale_typescript_tslint_config_path
+
+ call ale#handlers#tslint#InitVariables()
- call ale#test#SetDirectory('/testplugin/test/fixers')
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
silent cd ..
silent cd command_callback
- let g:dir = getcwd()
After:
Restore
@@ -16,12 +19,13 @@ After:
call ale#test#RestoreDirectory()
Execute(The tslint callback should return the correct default values):
+ let g:ale_typescript_tslint_config_path = 'tslint.json'
call ale#test#SetFilename('../prettier-test-files/testfile.ts')
AssertEqual
\ {
\ 'read_temporary_file': 1,
- \ 'command': ale#Escape(g:ale_typescript_tslint_executable)
+ \ 'command': ale#Escape('tslint')
\ . ' -c ' . ale#Escape('tslint.json')
\ . ' --fix %t',
\ },
@@ -34,8 +38,8 @@ Execute(The tslint callback should include custom tslint config option):
AssertEqual
\ {
\ 'read_temporary_file': 1,
- \ 'command': ale#Escape(g:ale_typescript_tslint_executable)
- \ . ' -c ' . ale#Escape(g:ale_typescript_tslint_config_path)
+ \ 'command': ale#Escape('tslint')
+ \ . ' -c ' . ale#Escape('.tslintrc')
\ . ' --fix %t',
\ },
\ ale#fixers#tslint#Fix(bufnr(''))
diff --git a/test/test_ale_lint_command.vader b/test/test_ale_lint_command.vader
index 15f1f054..6434e45f 100644
--- a/test/test_ale_lint_command.vader
+++ b/test/test_ale_lint_command.vader
@@ -38,6 +38,7 @@ After:
Restore
unlet! g:expected_loclist
+ unlet! b:i
call ale#engine#Cleanup(bufnr(''))
call ale#linter#Reset()
@@ -54,14 +55,21 @@ Given foobar (Some imaginary filetype):
Execute(ALELint should run the linters):
AssertEqual 'foobar', &filetype
- ALELint
- call ale#engine#WaitForJobs(2000)
+ " 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)
- if !has('nvim')
- " Sleep so the delayed list function can run.
- " This breaks the tests in NeoVim for some reason.
- sleep 1ms
- endif
+ if !has('nvim')
+ " Sleep so the delayed list function can run.
+ " This breaks the tests in NeoVim for some reason.
+ sleep 1ms
+ endif
+
+ if getloclist(0) == g:expected_loclist
+ break
+ endif
+ endfor
" Check the loclist
AssertEqual g:expected_loclist, getloclist(0)
diff --git a/test/test_env_function.vader b/test/test_env_function.vader
new file mode 100644
index 00000000..856a3f57
--- /dev/null
+++ b/test/test_env_function.vader
@@ -0,0 +1,8 @@
+Execute(ale#Env should produce the correct syntax):
+ if has('win32')
+ AssertEqual 'set name=xxx && ', ale#Env('name', 'xxx')
+ AssertEqual 'set name="foo bar" && ', ale#Env('name', 'foo bar')
+ else
+ AssertEqual 'name=''xxx'' ', ale#Env('name', 'xxx')
+ AssertEqual 'name=''foo bar'' ', ale#Env('name', 'foo bar')
+ endif