Close #2281 - Separate cwd commands from commands

Working directories are now set seperately from the commands so they
can later be swapped out when running linters over projects is
supported, and also better support filename mapping for running linters
on other machines in future.
This commit is contained in:
w0rp
2021-03-01 20:11:10 +00:00
parent 48fab99a0a
commit 9fe7b1fe6a
117 changed files with 1142 additions and 1111 deletions

View File

@@ -17,14 +17,14 @@ Execute(The executable should be configurable):
let b:ale_c_cppcheck_executable = 'foobar'
AssertLinterCwd ''
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.c')
AssertLinter 'cppcheck',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ale#Escape('cppcheck')
AssertLinterCwd ale#path#Simplify(g:dir . '/cppcheck_paths/one')
AssertLinter 'cppcheck', ale#Escape('cppcheck')
\ . ' -q --language=c'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape('compile_commands.json')
@@ -33,9 +33,8 @@ Execute(cppcheck for C should detect compile_commands.json files):
Execute(cppcheck for C should detect compile_commands.json files in build directories):
call ale#test#SetFilename('cppcheck_paths/with_build_dir/foo.cpp')
AssertLinter 'cppcheck',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/with_build_dir'))
\ . ale#Escape('cppcheck')
AssertLinterCwd ale#path#Simplify(g:dir . '/cppcheck_paths/with_build_dir')
AssertLinter 'cppcheck', ale#Escape('cppcheck')
\ . ' -q --language=c'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape(ale#path#Simplify('build/compile_commands.json'))
@@ -58,9 +57,8 @@ Execute(cppcheck for C should ignore compile_commands.json file if buffer is mod
set buftype=
set modified
AssertLinter 'cppcheck',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ale#Escape('cppcheck')
AssertLinterCwd ale#path#Simplify(g:dir . '/cppcheck_paths/one')
AssertLinter 'cppcheck', ale#Escape('cppcheck')
\ . ' -q --language=c'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --enable=style'

View File

@@ -118,20 +118,23 @@ Execute(--all-features should be used when g:ale_rust_cargo_default_feature_beha
GivenCommandOutput ['cargo 0.22.0 (3423351a5 2017-10-06)']
AssertLinter 'cargo', [ale#Escape('cargo') . ' --version', 'cargo check --frozen --message-format=json -q --all-features']
Execute(When a crate belongs to a workspace we should cd into the crate):
Execute(Cargo should run from the crate directory when set to avoid the workspace):
let g:ale_rust_cargo_avoid_whole_workspace = 1
call ale#test#SetFilename('cargo_workspace_paths/subpath/test.rs')
AssertLinterCwd ale#path#Simplify(g:dir . '/cargo_workspace_paths/subpath')
call ale#semver#ResetVersionCache()
AssertLinter 'cargo', [
\ ale#Escape('cargo') . ' --version',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/cargo_workspace_paths/subpath')) . ' && '
\ . 'cargo check --frozen --message-format=json -q',
\ 'cargo check --frozen --message-format=json -q',
\]
Execute(When a crate belongs to a workspace we chdir into the crate, unless we disabled it):
Execute(Cargo should not run from the crate directory when not set to avoid the workspace):
let g:ale_rust_cargo_avoid_whole_workspace = 0
call ale#test#SetFilename('cargo_workspace_paths/subpath/test.rs')
AssertLinterCwd ''
call ale#semver#ResetVersionCache()
AssertLinter 'cargo', [
\ ale#Escape('cargo') . ' --version',
\ 'cargo check --frozen --message-format=json -q',

View File

@@ -17,14 +17,14 @@ Execute(The executable should be configurable):
let b:ale_cpp_cppcheck_executable = 'foobar'
AssertLinterCwd ''
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')
AssertLinter 'cppcheck',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ale#Escape('cppcheck')
AssertLinterCwd ale#path#Simplify(g:dir . '/cppcheck_paths/one')
AssertLinter 'cppcheck', ale#Escape('cppcheck')
\ . ' -q --language=c++'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape('compile_commands.json')
@@ -33,9 +33,8 @@ Execute(cppcheck for C++ should detect compile_commands.json files):
Execute(cppcheck for C++ should detect compile_commands.json files in build directories):
call ale#test#SetFilename('cppcheck_paths/with_build_dir/foo.cpp')
AssertLinter 'cppcheck',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/with_build_dir'))
\ . ale#Escape('cppcheck')
AssertLinterCwd ale#path#Simplify(g:dir . '/cppcheck_paths/with_build_dir')
AssertLinter 'cppcheck', ale#Escape('cppcheck')
\ . ' -q --language=c++'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --project=' . ale#Escape(ale#path#Simplify('build/compile_commands.json'))
@@ -58,9 +57,8 @@ Execute(cppcheck for C++ should ignore compile_commands.json file if buffer is m
set buftype=
set modified
AssertLinter 'cppcheck',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/cppcheck_paths/one'))
\ . ale#Escape('cppcheck')
AssertLinterCwd ale#path#Simplify(g:dir . '/cppcheck_paths/one')
AssertLinter 'cppcheck', ale#Escape('cppcheck')
\ . ' -q --language=c++'
\ . ' --template=' . ale#Escape('{file}:{line}:{column}: {severity}:{inconclusive:inconclusive:} {message} [{id}]\\n{code}')
\ . ' --enable=style'

View File

@@ -5,43 +5,38 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The csc linter should return the correct default command):
AssertLinter 'csc', ale#path#CdString(g:dir)
\ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
AssertLinterCwd expand('%:p:h')
AssertLinter 'csc', 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
Execute(The options should be be used in the command):
let g:ale_cs_csc_options = ''
AssertLinter 'csc', ale#path#CdString(g:dir)
\ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
AssertLinter 'csc', 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
Execute(The souce path should be be used in the command):
let g:ale_cs_csc_source = '../foo/bar'
AssertLinter 'csc', ale#path#CdString('../foo/bar')
\ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
AssertLinterCwd '../foo/bar'
AssertLinter 'csc', 'csc /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_csc_assembly_path = ['/usr/lib/mono', '../foo/bar']
AssertLinter 'csc', ale#path#CdString(g:dir)
\ . 'csc /unsafe'
AssertLinter 'csc', 'csc /unsafe'
\ . ' /lib:' . ale#Escape('/usr/lib/mono') . ',' . ale#Escape('../foo/bar')
\ . ' /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
let g:ale_cs_csc_assembly_path = []
AssertLinter 'csc', ale#path#CdString(g:dir)
\ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
AssertLinter 'csc', 'csc /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_csc_assemblies = ['foo.dll', 'bar.dll']
AssertLinter 'csc', ale#path#CdString(g:dir)
\ . 'csc /unsafe'
AssertLinter 'csc', 'csc /unsafe'
\ . ' /r:' . ale#Escape('foo.dll') . ',' . ale#Escape('bar.dll')
\ . ' /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
let g:ale_cs_csc_assemblies = []
AssertLinter 'csc', ale#path#CdString(g:dir)
\ . 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')
AssertLinter 'csc', 'csc /unsafe /out:TEMP /t:module /recurse:' . ale#Escape('*.cs')

View File

@@ -5,43 +5,38 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The mcsc linter should return the correct default command):
AssertLinter 'mcs', ale#path#CdString(g:dir)
\ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
AssertLinterCwd expand('%:p:h')
AssertLinter 'mcs', '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'
AssertLinter 'mcs', ale#path#CdString(g:dir)
\ . 'mcs -unsafe -pkg:dotnet -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
AssertLinter 'mcs', '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'
AssertLinter 'mcs', ale#path#CdString('../foo/bar')
\ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
AssertLinterCwd '../foo/bar'
AssertLinter 'mcs', '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']
AssertLinter 'mcs', ale#path#CdString(g:dir)
\ . 'mcs -unsafe'
AssertLinter 'mcs', '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 = []
AssertLinter 'mcs', ale#path#CdString(g:dir)
\ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
AssertLinter 'mcs', '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']
AssertLinter 'mcs', ale#path#CdString(g:dir)
\ . 'mcs -unsafe'
AssertLinter 'mcs', '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 = []
AssertLinter 'mcs', ale#path#CdString(g:dir)
\ . 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')
AssertLinter 'mcs', 'mcs -unsafe -out:TEMP -t:module -recurse:' . ale#Escape('*.cs')

View File

@@ -0,0 +1,16 @@
Before:
call ale#assert#SetUpLinterTest('elixir', 'dialyxir')
call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex')
After:
call ale#assert#TearDownLinterTest()
Execute(Builds dialyxir command with a normal project):
AssertLinterCwd ale#path#Simplify(g:dir . '/elixir_paths/mix_project')
AssertLinter 'mix', 'mix help dialyzer && mix dialyzer'
Execute(Builds dialyxir command with an umbrella project):
call ale#test#SetFilename('elixir_paths/umbrella_project/apps/mix_project/lib/app.ex')
AssertLinterCwd ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project')
AssertLinter 'mix', 'mix help dialyzer && mix dialyzer'

View File

@@ -0,0 +1,16 @@
Before:
call ale#assert#SetUpLinterTest('elixir', 'dogma')
call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex')
After:
call ale#assert#TearDownLinterTest()
Execute(Builds dogma command with a normal project):
AssertLinterCwd ale#path#Simplify(g:dir . '/elixir_paths/mix_project')
AssertLinter 'mix', 'mix help dogma && mix dogma %s --format=flycheck'
Execute(Builds dogma command with an umbrella project):
call ale#test#SetFilename('elixir_paths/umbrella_project/apps/mix_project/lib/app.ex')
AssertLinterCwd ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project')
AssertLinter 'mix', 'mix help dogma && mix dogma %s --format=flycheck'

View File

@@ -1,47 +0,0 @@
Before:
call ale#assert#SetUpLinterTest('elixir', 'credo')
call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex')
After:
unlet! g:ale_elixir_credo_strict
call ale#assert#TearDownLinterTest()
Execute(Builds credo command with normal project):
AssertLinter 'mix',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
\ . 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with umbrella project):
call ale#test#SetFilename('elixir_paths/umbrella_project/apps/mix_project/lib/app.ex')
AssertLinter 'mix',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project'))
\ . 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with --strict mode when set to 1):
let g:ale_elixir_credo_strict = 1
AssertLinter 'mix',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
\ . 'mix help credo && mix credo --strict --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with suggest mode by default):
AssertLinter 'mix',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
\ . 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with suggest mode when set to 0):
let g:ale_elixir_credo_strict = 0
AssertLinter 'mix',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
\ . 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with a custom config file):
let g:ale_elixir_credo_config_file = '/home/user/custom_credo.exs'
AssertLinter 'mix',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
\ . 'mix help credo && mix credo suggest --config-file /home/user/custom_credo.exs --format=flycheck --read-from-stdin %s'

View File

@@ -0,0 +1,43 @@
Before:
call ale#assert#SetUpLinterTest('elixir', 'credo')
call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex')
After:
unlet! g:ale_elixir_credo_strict
call ale#assert#TearDownLinterTest()
Execute(Builds credo command with normal project):
AssertLinterCwd ale#path#Simplify(g:dir . '/elixir_paths/mix_project')
AssertLinter 'mix',
\ 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with umbrella project):
call ale#test#SetFilename('elixir_paths/umbrella_project/apps/mix_project/lib/app.ex')
AssertLinterCwd ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project')
AssertLinter 'mix',
\ 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with --strict mode when set to 1):
let g:ale_elixir_credo_strict = 1
AssertLinter 'mix',
\ 'mix help credo && mix credo --strict --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with suggest mode by default):
AssertLinter 'mix',
\ 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with suggest mode when set to 0):
let g:ale_elixir_credo_strict = 0
AssertLinter 'mix',
\ 'mix help credo && mix credo suggest --format=flycheck --read-from-stdin %s'
Execute(Builds credo command with a custom config file):
let g:ale_elixir_credo_config_file = '/home/user/custom_credo.exs'
AssertLinter 'mix',
\ 'mix help credo && mix credo suggest --config-file /home/user/custom_credo.exs --format=flycheck --read-from-stdin %s'

View File

@@ -1,9 +1,7 @@
Before:
call ale#assert#SetUpLinterTest('elixir', 'mix')
let g:env_prefix = has('win32')
\ ? 'set MIX_BUILD_PATH=' . ale#Escape('TEMP_DIR') . ' && '
\ : 'MIX_BUILD_PATH=' . ale#Escape('TEMP_DIR') . ' '
call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex')
let g:env_prefix = ale#Env('MIX_BUILD_PATH', 'TEMP_DIR')
After:
unlet! g:env_prefix
@@ -11,23 +9,11 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default mix command should be correct):
call ale#test#SetFilename('elixir_paths/mix_project/lib/app.ex')
AssertLinterCwd ale#path#Simplify(g:dir . '/elixir_paths/mix_project')
AssertLinter 'mix', g:env_prefix . 'mix compile %s'
AssertLinter 'mix',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/elixir_paths/mix_project'))
\ . g:env_prefix
\ . 'mix compile %s'
Execute(Build mix commands with an umbrella root):
call ale#test#SetFilename('elixir_paths/umbrella_project/apps/mix_project/lib/app.ex')
Execute(FindMixProjectRoot should detect the project root directory via mix.exs):
silent execute 'file ' . fnameescape(g:dir . '/elixir_paths/mix_project/lib/app.ex')
AssertEqual
\ ale#path#Simplify(g:dir . '/elixir_paths/mix_project'),
\ ale#handlers#elixir#FindMixProjectRoot(bufnr(''))
Execute(FindMixUmbrellaRoot should detect the umbrella root directory via mix.exs):
silent execute 'file ' . fnameescape(g:dir . '/elixir_paths/umbrella_project/apps/app1/lib/app.ex')
AssertEqual
\ ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project'),
\ ale#handlers#elixir#FindMixUmbrellaRoot(bufnr(''))
AssertLinterCwd ale#path#Simplify(g:dir . '/elixir_paths/umbrella_project')
AssertLinter 'mix', g:env_prefix . 'mix compile %s'

View File

@@ -11,18 +11,18 @@ Execute(should get valid executable with default params):
let g:executable = ale#path#Simplify(g:dir . '/../elm-test-files/newapp/node_modules/.bin/elm')
AssertLinterCwd ale#path#Simplify(g:dir . '/../elm-test-files/newapp')
AssertLinter g:executable,
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/../elm-test-files/newapp')) . ' && '
\ . ale#Escape(g:executable) . ' make --report=json --output=/dev/null %t'
\ ale#Escape(g:executable) . ' make --report=json --output=/dev/null %t'
Execute(should get elm-test executable for test code with elm >= 0.19):
call ale#test#SetFilename('../elm-test-files/newapp/tests/TestSuite.elm')
let g:executable = ale#path#Simplify(g:dir . '/../elm-test-files/newapp/node_modules/.bin/elm-test')
AssertLinterCwd ale#path#Simplify(g:dir . '/../elm-test-files/newapp')
AssertLinter g:executable,
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/../elm-test-files/newapp')) . ' && '
\ . ale#Escape(g:executable) . ' make --report=json --output=/dev/null --compiler '
\ ale#Escape(g:executable) . ' make --report=json --output=/dev/null --compiler '
\ . ale#path#Simplify(g:dir . '/../elm-test-files/newapp/node_modules/.bin/elm') . ' %t'
Execute(should fallback to elm executable with elm >= 0.19):
@@ -30,27 +30,27 @@ Execute(should fallback to elm executable with elm >= 0.19):
let g:executable = ale#path#Simplify(g:dir . '/../elm-test-files/newapp-notests/node_modules/.bin/elm')
AssertLinterCwd ale#path#Simplify(g:dir . '/../elm-test-files/newapp-notests')
AssertLinter g:executable,
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/../elm-test-files/newapp-notests')) . ' && '
\ . ale#Escape(g:executable) . ' make --report=json --output=/dev/null %t'
\ ale#Escape(g:executable) . ' make --report=json --output=/dev/null %t'
Execute(should get plain elm executable for test code with elm < 0.19):
call ale#test#SetFilename('../elm-test-files/oldapp/tests/TestSuite.elm')
let g:executable = ale#path#Simplify(g:dir . '/../elm-test-files/oldapp/node_modules/.bin/elm')
AssertLinterCwd ale#path#Simplify(g:dir . '/../elm-test-files/oldapp')
AssertLinter g:executable,
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/../elm-test-files/oldapp')) . ' && '
\ . ale#Escape(g:executable) . ' make --report=json --output=/dev/null %t'
\ ale#Escape(g:executable) . ' make --report=json --output=/dev/null %t'
Execute(should get valid executable with 'use_global' params):
let g:ale_elm_make_use_global = 1
call ale#test#SetFilename('../elm-test-files/newapp/src/Main.elm')
AssertLinterCwd ale#path#Simplify(g:dir . '/../elm-test-files/newapp')
AssertLinter 'elm',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/../elm-test-files/newapp')) . ' && '
\ . ale#Escape('elm') . ' make --report=json --output=/dev/null %t'
\ ale#Escape('elm') . ' make --report=json --output=/dev/null %t'
Execute(should get valid executable with 'use_global' and 'executable' params):
let g:ale_elm_make_executable = 'other-elm'
@@ -58,6 +58,6 @@ Execute(should get valid executable with 'use_global' and 'executable' params):
call ale#test#SetFilename('../elm-test-files/newapp/src/Main.elm')
AssertLinterCwd ale#path#Simplify(g:dir . '/../elm-test-files/newapp')
AssertLinter 'other-elm',
\ 'cd ' . ale#Escape(ale#path#Simplify(g:dir . '/../elm-test-files/newapp')) . ' && '
\ . ale#Escape('other-elm') . ' make --report=json --output=/dev/null %t'
\ ale#Escape('other-elm') . ' make --report=json --output=/dev/null %t'

View File

@@ -0,0 +1,76 @@
Before:
call ale#assert#SetUpLinterTest('javascript', 'eslint')
runtime autoload/ale/handlers/eslint.vim
let b:args = ' -f json --stdin --stdin-filename %s'
After:
unlet! b:args
unlet! b:executable
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
AssertLinterCwd ''
AssertLinter 'eslint', ale#Escape('eslint') . b:args
Execute(create-react-app directories should be detected correctly):
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/react-app')
AssertLinter b:executable,
\ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
\ . ale#Escape(b:executable) . b:args
Execute(use-global should override create-react-app detection):
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
let g:ale_javascript_eslint_use_global = 1
let g:ale_javascript_eslint_executable = 'eslint_d'
let b:executable = 'eslint_d'
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/react-app')
AssertLinter b:executable, ale#Escape(b:executable) . b:args
Execute(other app directories should be detected correctly):
call ale#test#SetFilename('../eslint-test-files/other-app/subdir/testfile.js')
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/node_modules/.bin/eslint')
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files')
AssertLinter b:executable, ale#Escape(b:executable) . b:args
Execute(use-global should override other app directories):
call ale#test#SetFilename('../eslint-test-files/other-app/subdir/testfile.js')
let g:ale_javascript_eslint_use_global = 1
let g:ale_javascript_eslint_executable = 'eslint_d'
let b:executable = 'eslint_d'
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files')
AssertLinter b:executable, ale#Escape(b:executable) . b:args
Execute(eslint_d should be detected correctly):
call ale#test#SetFilename('../eslint-test-files/app-with-eslint-d/testfile.js')
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d')
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d')
AssertLinter b:executable, ale#Escape(b:executable) . b:args
Execute(eslint.js executables should be run with node on Windows):
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/react-app')
AssertLinter b:executable,
\ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
\ . ale#Escape(b:executable) . b:args
Execute(eslint.js should be run from a containing project with eslint):
call ale#test#SetFilename('../eslint-test-files/react-app/subdir-with-package-json/testfile.js')
let b:executable = ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')
AssertLinterCwd ale#path#Simplify(g:dir . '/../eslint-test-files/react-app')
AssertLinter b:executable,
\ (has('win32') ? ale#Escape('node.exe') . ' ' : '')
\ . ale#Escape(b:executable) . b:args

View File

@@ -13,15 +13,13 @@ After:
Execute(The flake8 callbacks should return the correct default values):
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
" The version check should be cached.
GivenCommandOutput []
AssertLinter 'flake8', [
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
" Try with older versions.
@@ -29,13 +27,14 @@ Execute(The flake8 callbacks should return the correct default values):
GivenCommandOutput ['2.9.9']
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default -',
\ ale#Escape('flake8') . ' --format=default -',
\]
Execute(The option for disabling changing directories should work):
let g:ale_python_flake8_change_directory = 'off'
AssertLinterCwd ['', '']
call ale#semver#ResetVersionCache()
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
@@ -43,6 +42,7 @@ Execute(The option for disabling changing directories should work):
let g:ale_python_flake8_change_directory = 0
AssertLinterCwd ['']
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
@@ -50,6 +50,7 @@ Execute(The option for disabling changing directories should work):
" Invalid options should be considered the same as turning the setting off.
let g:ale_python_flake8_change_directory = 'xxx'
AssertLinterCwd ['']
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
@@ -57,10 +58,11 @@ Execute(The option for disabling changing directories should work):
Execute(The option for changing directory to project root should work):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/namespace_package_tox/namespace/foo/bar.py')
AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
call ale#semver#ResetVersionCache()
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#CdString(ale#python#FindProjectRootIni(bufnr('')))
\ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
Execute(The option for changing directory to file dir should work):
@@ -69,15 +71,13 @@ Execute(The option for changing directory to file dir should work):
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
let g:ale_python_flake8_change_directory = 1
AssertLinter 'flake8', [
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\ ale#Escape('flake8') . ' --format=default --stdin-display-name %s -',
\]
Execute(The flake8 command callback should let you set options):
@@ -86,8 +86,7 @@ Execute(The flake8 command callback should let you set options):
GivenCommandOutput ['3.0.4']
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --some-option'
\ ale#Escape('flake8') . ' --some-option'
\ . ' --format=default --stdin-display-name %s -',
\]
@@ -95,17 +94,17 @@ Execute(The flake8 command callback should let you set options):
GivenCommandOutput ['2.9.9']
AssertLinter 'flake8', [
\ ale#Escape('flake8') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('flake8') . ' --some-option --format=default -',
\ 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'
AssertLinterCwd ['%s:h', '%s:h']
call ale#semver#ResetVersionCache()
AssertLinter 'executable with spaces', [
\ ale#Escape('executable with spaces') . ' --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('executable with spaces')
\ ale#Escape('executable with spaces')
\ . ' --format=default'
\ . ' --stdin-display-name %s -',
\]
@@ -119,8 +118,7 @@ Execute(The flake8 callbacks should detect virtualenv directories):
AssertLinter b:executable, [
\ ale#Escape(b:executable) . ' --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape(b:executable)
\ ale#Escape(b:executable)
\ . ' --format=default'
\ . ' --stdin-display-name %s -',
\]
@@ -170,8 +168,7 @@ Execute(Using `python -m flake8` should be supported for running flake8):
GivenCommandOutput ['2.9.9']
AssertLinter 'python', [
\ ale#Escape('python') . ' -m flake8 --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('python')
\ ale#Escape('python')
\ . ' -m flake8 --some-option --format=default -'
\]
@@ -183,8 +180,7 @@ Execute(Using `python -m flake8` should be supported for running flake8):
GivenCommandOutput ['2.9.9']
AssertLinter 'python', [
\ ale#Escape('python') . ' -m flake8 --version',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('python')
\ ale#Escape('python')
\ . ' -m flake8 --some-option --format=default -'
\]
@@ -194,13 +190,12 @@ Execute(Setting executable to 'pipenv' should append 'run flake8'):
" FIXME: pipenv should check the version with flake8.
GivenCommandOutput []
AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run flake8 --format=default -'
\ ale#Escape('path/to/pipenv') . ' run flake8 --format=default -'
Execute(Pipenv is detected when python_flake8_auto_pipenv is set):
let g:ale_python_flake8_auto_pipenv = 1
call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py')
AssertLinterCwd ale#python#FindProjectRootIni(bufnr(''))
AssertLinter 'pipenv',
\ ale#path#CdString(ale#python#FindProjectRootIni(bufnr('')))
\ . ale#Escape('pipenv') . ' run flake8 --format=default --stdin-display-name %s -'
\ ale#Escape('pipenv') . ' run flake8 --format=default --stdin-display-name %s -'

View File

@@ -9,33 +9,25 @@ After:
Restore
call ale#assert#TearDownLinterTest()
Execute(The default commands should be correct):
AssertLinter 'go',
\ ale#path#BufferCdString(bufnr(''))
\ . 'go test -c -o /dev/null ./'
Execute(The default command should be correct):
AssertLinterCwd '%s:h'
AssertLinter 'go', 'go test -c -o /dev/null ./'
Execute(Go environment variables should be supported):
let b:ale_go_go111module = 'on'
AssertLinter 'go',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Env('GO111MODULE', 'on')
\ . 'go test -c -o /dev/null ./'
AssertLinter 'go', ale#Env('GO111MODULE', 'on') . 'go test -c -o /dev/null ./'
unlet! b:ale_go_go111module
Execute(Extra options should be supported):
let g:ale_go_gobuild_options = '--foo-bar'
AssertLinter 'go',
\ ale#path#BufferCdString(bufnr(''))
\ . 'go test --foo-bar -c -o /dev/null ./'
AssertLinter 'go', 'go test --foo-bar -c -o /dev/null ./'
let g:ale_go_gobuild_options = ''
Execute(The executable should be configurable):
let g:ale_go_go_executable = 'foobar'
AssertLinter 'foobar',
\ ale#path#BufferCdString(bufnr(''))
\ . 'foobar test -c -o /dev/null ./'
AssertLinter 'foobar', 'foobar test -c -o /dev/null ./'

View File

@@ -12,9 +12,9 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The golangci-lint defaults should be correct):
AssertLinterCwd '%s:h',
AssertLinter 'golangci-lint',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('golangci-lint')
\ ale#Escape('golangci-lint')
\ . ' run ' . ale#Escape(expand('%' . ':t'))
\ . ' --enable-all'
@@ -22,8 +22,7 @@ Execute(The golangci-lint callback should use a configured executable):
let b:ale_go_golangci_lint_executable = 'something else'
AssertLinter 'something else',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('something else')
\ ale#Escape('something else')
\ . ' run ' . ale#Escape(expand('%' . ':t'))
\ . ' --enable-all'
@@ -31,8 +30,7 @@ Execute(The golangci-lint callback should use configured options):
let b:ale_go_golangci_lint_options = '--foobar'
AssertLinter 'golangci-lint',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('golangci-lint')
\ ale#Escape('golangci-lint')
\ . ' run ' . ale#Escape(expand('%' . ':t'))
\ . ' --foobar'
@@ -40,8 +38,7 @@ Execute(The golangci-lint callback should support environment variables):
let b:ale_go_go111module = 'on'
AssertLinter 'golangci-lint',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Env('GO111MODULE', 'on')
\ ale#Env('GO111MODULE', 'on')
\ . ale#Escape('golangci-lint')
\ . ' run ' . ale#Escape(expand('%' . ':t'))
\ . ' --enable-all'
@@ -50,5 +47,4 @@ Execute(The golangci-lint `lint_package` option should use the correct command):
let b:ale_go_golangci_lint_package = 1
AssertLinter 'golangci-lint',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('golangci-lint') . ' run --enable-all'
\ ale#Escape('golangci-lint') . ' run --enable-all'

View File

@@ -12,9 +12,9 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The gometalinter defaults should be correct):
AssertLinterCwd '%s:h',
AssertLinter 'gometalinter',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('gometalinter')
\ ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' .'
@@ -22,8 +22,7 @@ Execute(The gometalinter callback should use a configured executable):
let b:ale_go_gometalinter_executable = 'something else'
AssertLinter 'something else',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('something else')
\ ale#Escape('something else')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' .'
@@ -31,8 +30,7 @@ Execute(The gometalinter callback should use configured options):
let b:ale_go_gometalinter_options = '--foobar'
AssertLinter 'gometalinter',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('gometalinter')
\ ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' --foobar' . ' .'
@@ -40,8 +38,7 @@ Execute(The gometalinter should use configured environment variables):
let b:ale_go_go111module = 'off'
AssertLinter 'gometalinter',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Env('GO111MODULE', 'off')
\ ale#Env('GO111MODULE', 'off')
\ . ale#Escape('gometalinter')
\ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
\ . ' .'
@@ -49,6 +46,4 @@ Execute(The gometalinter should use configured environment variables):
Execute(The gometalinter `lint_package` option should use the correct command):
let b:ale_go_gometalinter_lint_package = 1
AssertLinter 'gometalinter',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('gometalinter') . ' .'
AssertLinter 'gometalinter', ale#Escape('gometalinter') . ' .'

View File

@@ -10,13 +10,10 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default gosimple command should be correct):
AssertLinter 'gosimple',
\ ale#path#BufferCdString(bufnr(''))
\ . ' gosimple .'
AssertLinterCwd '%s:h'
AssertLinter 'gosimple', 'gosimple .'
Execute(The gosimple command should support Go environment variables):
let b:ale_go_go111module = 'on'
AssertLinter 'gosimple',
\ ale#path#BufferCdString(bufnr(''))
\ . ' ' . ale#Env('GO111MODULE', 'on') . 'gosimple .'
AssertLinter 'gosimple', ale#Env('GO111MODULE', 'on') . 'gosimple .'

View File

@@ -10,19 +10,15 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default gotype command should be correct):
AssertLinter 'gotype',
\ ale#path#BufferCdString(bufnr(''))
\ . ' gotype -e .'
AssertLinterCwd '%s:h'
AssertLinter 'gotype', 'gotype -e .'
Execute(The gotype callback should ignore test files):
call ale#test#SetFilename('bla_test.go')
AssertLinter 'gotype', ''
AssertLinterNotExecuted
Execute(The gotype callback should support Go environment variables):
let b:ale_go_go111module = 'on'
AssertLinter 'gotype',
\ ale#path#BufferCdString(bufnr(''))
\ . ' ' . ale#Env('GO111MODULE', 'on')
\ . 'gotype -e .'
AssertLinter 'gotype', ale#Env('GO111MODULE', 'on') . 'gotype -e .'

View File

@@ -13,22 +13,20 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
AssertLinter 'go', ale#path#BufferCdString(bufnr('')) . ' go vet .'
AssertLinter 'go', 'go vet .'
Execute(Extra options should be supported):
let g:ale_go_govet_options = '--foo-bar'
AssertLinter 'go', ale#path#BufferCdString(bufnr('')) . ' go vet --foo-bar .'
AssertLinterCwd '%s:h'
AssertLinter 'go', 'go vet --foo-bar .'
Execute(The executable should be configurable):
let g:ale_go_go_executable = 'foobar'
AssertLinter 'foobar', ale#path#BufferCdString(bufnr('')) . ' foobar vet .'
AssertLinter 'foobar', 'foobar vet .'
Execute(Go environment variables should be supported):
let b:ale_go_go111module = 'on'
AssertLinter 'go',
\ ale#path#BufferCdString(bufnr('')) . ' '
\ . ale#Env('GO111MODULE', 'on')
\ . 'go vet .'
AssertLinter 'go', ale#Env('GO111MODULE', 'on') . 'go vet .'

View File

@@ -5,7 +5,5 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The linter should run from the directory of the file in the buffer):
AssertLinter 'gqlint',
\ ale#path#BufferCdString(bufnr(''))
\ . 'gqlint --reporter=simple'
\ . ' %t'
AssertLinterCwd '%s:h'
AssertLinter 'gqlint', 'gqlint --reporter=simple %t'

View File

@@ -1,23 +1,13 @@
Before:
Save g:ale_haskell_cabal_ghc_options
unlet! g:ale_haskell_cabal_ghc_options
unlet! b:ale_haskell_cabal_ghc_options
runtime ale_linters/haskell/cabal_ghc.vim
call ale#assert#SetUpLinterTest('haskell', 'cabal_ghc')
After:
Restore
unlet! b:ale_haskell_cabal_ghc_options
call ale#linter#Reset()
call ale#assert#TearDownLinterTest()
Execute(The options should be used in the command):
AssertEqual
\ ale#path#BufferCdString(bufnr('')) . 'cabal exec -- ghc -fno-code -v0 %t',
\ ale_linters#haskell#cabal_ghc#GetCommand(bufnr(''))
AssertLinterCwd '%s:h'
AssertLinter 'cabal', 'cabal exec -- ghc -fno-code -v0 %t'
let b:ale_haskell_cabal_ghc_options = 'foobar'
AssertEqual
\ ale#path#BufferCdString(bufnr('')) . 'cabal exec -- ghc foobar %t',
\ ale_linters#haskell#cabal_ghc#GetCommand(bufnr(''))
AssertLinter 'cabal', 'cabal exec -- ghc foobar %t'

View File

@@ -10,8 +10,9 @@ Execute(The linter should not be executed when there's no stack.yaml file):
Execute(The linter should be executed when there is a stack.yaml file):
call ale#test#SetFilename('stack_ghc_paths/test.hs')
AssertLinter 'stack', ale#path#BufferCdString(bufnr('')) . 'stack ghc -- -fno-code -v0 %t'
AssertLinterCwd '%s:h'
AssertLinter 'stack', 'stack ghc -- -fno-code -v0 %t'
let b:ale_haskell_stack_ghc_options = 'foobar'
AssertLinter 'stack', ale#path#BufferCdString(bufnr('')) . 'stack ghc -- foobar %t'
AssertLinter 'stack', 'stack ghc -- foobar %t'

View File

@@ -3,8 +3,7 @@ Before:
call ale#test#SetFilename('dummy.java')
let g:cp_sep = has('unix') ? ':' : ';'
let g:prefix = ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
let g:prefix = ale#Escape('javac') . ' -Xlint'
function! GetCommand(previous_output) abort
let l:command = ale_linters#java#javac#GetCommand(
@@ -29,6 +28,7 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The javac callback should return the correct default value):
AssertLinterCwd '%s:h'
AssertLinter 'javac', g:prefix . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should use string type g:ale_java_javac_classpath correctly):
@@ -51,8 +51,7 @@ Execute(The executable should be configurable):
let g:ale_java_javac_executable = 'foobar'
AssertLinter 'foobar',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('foobar') . ' -Xlint'
\ ale#Escape('foobar') . ' -Xlint'
\ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t'
Execute(The javac callback should include discovered classpaths):
@@ -197,8 +196,7 @@ Execute(The javac callback should combine discovered sourcepath and manual ones)
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [], {})
AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ 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/build/gen/main/'),
@@ -211,8 +209,7 @@ Execute(The javac callback should combine discovered sourcepath and manual ones)
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [], {})
AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ 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/build/gen/main/'),
@@ -225,8 +222,7 @@ Execute(The javac callback should combine discovered sourcepath and manual ones)
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [], {})
AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ 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/build/gen/main/')
@@ -241,8 +237,7 @@ Execute(The javac callback should combine discovered sourcepath and manual ones)
let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [], {})
AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ 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/build/gen/main/'),
@@ -257,8 +252,7 @@ Execute(The javac callback should detect source directories):
call ale#engine#InitBufferInfo(bufnr(''))
AssertLinter 'javac',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ ale#Escape('javac') . ' -Xlint'
\ . ' -sourcepath ' . ale#Escape(
\ ale#path#Simplify(g:dir . '/java_paths/src/main/java/')
\ )
@@ -277,8 +271,7 @@ Execute(The javac callback should combine detected source directories and classp
\], {})
AssertEqual
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ 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/')
@@ -300,8 +293,7 @@ Execute(The javac callback should include src/test/java for test paths):
call ale#engine#InitBufferInfo(bufnr(''))
AssertLinter 'javac',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ 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/'),
@@ -314,8 +306,7 @@ Execute(The javac callback should include src/main/jaxb when available):
call ale#engine#InitBufferInfo(bufnr(''))
AssertLinter 'javac',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ 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/'),
@@ -328,8 +319,7 @@ Execute(The javac callback should add -sourcepath even if src/java/main doesn't
call ale#engine#InitBufferInfo(bufnr(''))
AssertLinter 'javac',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('javac') . ' -Xlint'
\ ale#Escape('javac') . ' -Xlint'
\ . ' -sourcepath ' . ale#Escape(join([
\ ale#path#Simplify(g:dir . '/java_paths_no_main/src/test/java/'),
\ ], g:cp_sep))

View File

@@ -5,9 +5,9 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default lintr command should be correct):
AssertLinterCwd '%s:h'
AssertLinter 'Rscript',
\ ale#path#BufferCdString(bufnr(''))
\ . 'Rscript --vanilla -e '
\ 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
\ . 'lint(cache = FALSE, commandArgs(TRUE), '
\ . 'with_defaults())')
@@ -17,8 +17,7 @@ Execute(The lintr options should be configurable):
let b:ale_r_lintr_options = 'with_defaults(object_usage_linter = NULL)'
AssertLinter 'Rscript',
\ ale#path#BufferCdString(bufnr(''))
\ . 'Rscript --vanilla -e '
\ 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
\ . 'lint(cache = FALSE, commandArgs(TRUE), '
\ . 'with_defaults(object_usage_linter = NULL))')
@@ -28,8 +27,7 @@ Execute(If the lint_package flag is set, lintr::lint_package should be called):
let b:ale_r_lintr_lint_package = 1
AssertLinter 'Rscript',
\ ale#path#BufferCdString(bufnr(''))
\ . 'Rscript --vanilla -e '
\ 'Rscript --vanilla -e '
\ . ale#Escape('suppressPackageStartupMessages(library(lintr));'
\ . 'lint_package(cache = FALSE, '
\ . 'linters = with_defaults())')

View File

@@ -1,25 +1,22 @@
Before:
call ale#assert#SetUpLinterTest('mercury', 'mmc')
call ale#test#SetFilename('dummy')
After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
AssertLinterCwd '%s:h'
AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('mmc') . ' --errorcheck-only --make --output-compile-error-lines 100 dummy'
\ ale#Escape('mmc') . ' --errorcheck-only --make --output-compile-error-lines 100 %s:t:r'
Execute(The executable should be configurable):
let b:ale_mercury_mmc_executable = 'foo'
AssertLinter 'foo',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('foo') . ' --errorcheck-only --make --output-compile-error-lines 100 dummy'
\ ale#Escape('foo') . ' --errorcheck-only --make --output-compile-error-lines 100 %s:t:r'
Execute(The options should be configurable):
let b:ale_mercury_mmc_options = '--bar'
AssertLinter 'mmc',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('mmc') . ' --errorcheck-only --bar dummy'
\ ale#Escape('mmc') . ' --errorcheck-only --bar %s:t:r'

View File

@@ -11,8 +11,9 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The mypy callbacks should return the correct default values):
AssertLinterCwd g:dir
AssertLinter 'mypy',
\ ale#path#CdString(g:dir) . ale#Escape('mypy')
\ ale#Escape('mypy')
\ . ' --show-column-numbers'
\ . ' --shadow-file %s %t %s'
@@ -20,7 +21,7 @@ Execute(The mypy executable should be configurable, and escaped properly):
let g:ale_python_mypy_executable = 'executable with spaces'
AssertLinter 'executable with spaces',
\ ale#path#CdString(g:dir) . ale#Escape('executable with spaces')
\ ale#Escape('executable with spaces')
\ . ' --show-column-numbers'
\ . ' --shadow-file %s %t %s'
@@ -28,62 +29,62 @@ Execute(The mypy command callback should let you set options):
let g:ale_python_mypy_options = '--some-option'
AssertLinter 'mypy',
\ ale#path#CdString(g:dir) . ale#Escape('mypy')
\ ale#Escape('mypy')
\ . ' --some-option'
\ . ' --show-column-numbers'
\ . ' --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')
call ale#test#SetFilename('python_paths/no_virtualenv/subdir/foo/bar.py')
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir')
AssertLinter 'mypy',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
\ . ale#Escape('mypy')
\ ale#Escape('mypy')
\ . ' --show-column-numbers'
\ . ' --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')
call ale#test#SetFilename('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')
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')
AssertLinter b:executable,
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape(b:executable)
\ ale#Escape(b:executable)
\ . ' --show-column-numbers'
\ . ' --shadow-file %s %t %s'
Execute(The mypy callbacks should cd to directory containing mypy.ini if found):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_mypy_ini_and_pytest_ini/tests/testsubfolder/my_tests.py')
call ale#test#SetFilename('python_paths/with_mypy_ini_and_pytest_ini/tests/testsubfolder/my_tests.py')
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/with_mypy_ini_and_pytest_ini')
AssertLinter 'mypy',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_mypy_ini_and_pytest_ini'))
\ . ale#Escape('mypy')
\ ale#Escape('mypy')
\ . ' --show-column-numbers'
\ . ' --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')
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_mypy_use_global = 1
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')
AssertLinter 'mypy',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape('mypy')
\ ale#Escape('mypy')
\ . ' --show-column-numbers'
\ . ' --shadow-file %s %t %s'
Execute(Setting executable to 'pipenv' appends 'run mypy'):
let g:ale_python_mypy_executable = 'path/to/pipenv'
AssertLinterCwd expand('#' . bufnr('') . ':p:h')
AssertLinter 'path/to/pipenv',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('path/to/pipenv') . ' run mypy'
\ ale#Escape('path/to/pipenv') . ' run mypy'
\ . ' --show-column-numbers --shadow-file %s %t %s'
Execute(Pipenv is detected when python_mypy_auto_pipenv is set):
let g:ale_python_mypy_auto_pipenv = 1
call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py')
let g:ale_python_mypy_auto_pipenv = 1
AssertLinterCwd expand('#' . bufnr('') . ':p:h')
AssertLinter 'pipenv',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('pipenv') . ' run mypy --show-column-numbers --shadow-file %s %t %s'
\ ale#Escape('pipenv') . ' run mypy --show-column-numbers --shadow-file %s %t %s'

View File

@@ -11,8 +11,8 @@ Execute(The local phpcs executable should be used):
let g:executable = ale#path#Simplify(g:dir . '/../phpcs-test-files/project-with-phpcs/vendor/bin/phpcs')
AssertLinter g:executable, ale#path#BufferCdString(bufnr(''))
\ . ale#Escape(g:executable)
AssertLinterCwd '%s:h'
AssertLinter g:executable, ale#Escape(g:executable)
\ . ' -s --report=emacs --stdin-path=%s'
Execute(use_global should override local executable detection):
@@ -20,27 +20,23 @@ Execute(use_global should override local executable detection):
call ale#test#SetFilename('../phpcs-test-files/project-with-phpcs/foo/test.php')
AssertLinter 'phpcs', ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('phpcs')
AssertLinter 'phpcs', ale#Escape('phpcs')
\ . ' -s --report=emacs --stdin-path=%s'
Execute(Projects without local executables should use the global one):
call ale#test#SetFilename('../phpcs-test-files/project-without-phpcs/foo/test.php')
AssertLinter 'phpcs', ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('phpcs')
AssertLinter 'phpcs', ale#Escape('phpcs')
\ . ' -s --report=emacs --stdin-path=%s'
Execute(User provided options should be used):
let g:ale_php_phpcs_options = '--my-user-provided-option my-value'
AssertLinter 'phpcs', ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('phpcs')
AssertLinter 'phpcs', ale#Escape('phpcs')
\ . ' -s --report=emacs --stdin-path=%s --my-user-provided-option my-value'
Execute(The _standard option should be used):
let g:ale_php_phpcs_standard = 'foobar'
AssertLinter 'phpcs', ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('phpcs')
AssertLinter 'phpcs', ale#Escape('phpcs')
\ . ' -s --report=emacs --stdin-path=%s --standard=' . ale#Escape('foobar')

View File

@@ -6,35 +6,28 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The pydocstyle command callback should return default string):
AssertLinter 'pydocstyle',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('pydocstyle') . ' %s:t'
AssertLinterCwd '%s:h'
AssertLinter 'pydocstyle', ale#Escape('pydocstyle') . ' %s:t'
Execute(The pydocstyle command callback should allow options):
let g:ale_python_pydocstyle_options = '--verbose'
AssertLinter 'pydocstyle',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('pydocstyle') . ' --verbose %s:t'
AssertLinter 'pydocstyle', ale#Escape('pydocstyle') . ' --verbose %s:t'
Execute(The pydocstyle executable should be configurable):
let g:ale_python_pydocstyle_executable = '~/.local/bin/pydocstyle'
AssertLinter '~/.local/bin/pydocstyle',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('~/.local/bin/pydocstyle') . ' %s:t'
\ ale#Escape('~/.local/bin/pydocstyle') . ' %s:t'
Execute(Setting executable to 'pipenv' appends 'run pydocstyle'):
let g:ale_python_pydocstyle_executable = 'path/to/pipenv'
AssertLinter 'path/to/pipenv',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('path/to/pipenv') . ' run pydocstyle %s:t'
\ ale#Escape('path/to/pipenv') . ' run pydocstyle %s:t'
Execute(Pipenv is detected when python_pydocstyle_auto_pipenv is set):
let g:ale_python_pydocstyle_auto_pipenv = 1
call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py')
AssertLinter 'pipenv',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('pipenv') . ' run pydocstyle %s:t'
AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pydocstyle %s:t'

View File

@@ -12,74 +12,65 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The pylama command callback should return a default):
AssertLinter 'pylama',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('pylama') . b:command_tail
Execute(The default pylama command should be correct):
AssertLinterCwd ale#path#Simplify(g:dir)
AssertLinter 'pylama', ale#Escape('pylama') . b:command_tail
Execute(The option for disabling changing directories should work):
let g:ale_python_pylama_change_directory = 0
AssertLinterCwd ''
AssertLinter 'pylama', ale#Escape('pylama') . b:command_tail
Execute(The pylama executable should be configurable, and escaped properly):
let g:ale_python_pylama_executable = 'executable with spaces'
AssertLinterCwd ale#path#Simplify(g:dir)
AssertLinter 'executable with spaces',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('executable with spaces') . b:command_tail
\ ale#Escape('executable with spaces') . b:command_tail
Execute(The pylama command callback should let you set options):
let g:ale_python_pylama_options = '--some-option'
AssertLinter 'pylama',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('pylama') . ' --some-option' . b:command_tail
AssertLinterCwd ale#path#Simplify(g:dir)
AssertLinter 'pylama', ale#Escape('pylama') . ' --some-option' . b:command_tail
Execute(The pylama command callback should switch directories to the detected project root):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
AssertLinter 'pylama',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
\ . ale#Escape('pylama') . b:command_tail
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir')
AssertLinter 'pylama', ale#Escape('pylama') . b:command_tail
Execute(The pylama command callback shouldn't detect virtualenv directories where they don't exist):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
call ale#test#SetFilename('python_paths/no_virtualenv/subdir/foo/bar.py')
AssertLinter 'pylama',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
\ . ale#Escape('pylama') . b:command_tail
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir')
AssertLinter 'pylama', ale#Escape('pylama') . b:command_tail
Execute(The pylama command callback should detect virtualenv directories and switch to the project root):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let b:executable = ale#path#Simplify(
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pylama'
\)
AssertLinter b:executable,
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape(b:executable) . b:command_tail
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')
AssertLinter b:executable, ale#Escape(b:executable) . b:command_tail
Execute(You should able able to use the global pylama instead):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_pylama_use_global = 1
AssertLinter 'pylama',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape('pylama') . b:command_tail
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')
AssertLinter 'pylama', ale#Escape('pylama') . b:command_tail
Execute(Setting executable to 'pipenv' appends 'run pylama'):
let g:ale_python_pylama_executable = 'path/to/pipenv'
AssertLinter 'path/to/pipenv',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('path/to/pipenv') . ' run pylama' . b:command_tail
\ ale#Escape('path/to/pipenv') . ' run pylama' . b:command_tail
Execute(Pipenv is detected when python_pylama_auto_pipenv is set):
let g:ale_python_pylama_auto_pipenv = 1
call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py')
AssertLinter 'pipenv',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('pipenv') . ' run pylama' . b:command_tail
AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pylama' . b:command_tail

View File

@@ -18,75 +18,64 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The pylint callbacks should return the correct default values):
AssertLinter 'pylint',
\ ale#path#CdString(expand('%:p:h'))
\ . ale#Escape('pylint') . b:command_tail
AssertLinterCwd expand('%:p:h')
AssertLinter 'pylint', ale#Escape('pylint') . b:command_tail
Execute(Pylint should run with the --from-stdin in new enough versions):
GivenCommandOutput ['pylint 2.4.0']
AssertLinter 'pylint',
\ ale#path#CdString(expand('%:p:h'))
\ . ale#Escape('pylint') . b:command_tail[:-3] . '--from-stdin %s'
AssertLinterCwd expand('%:p:h')
AssertLinter 'pylint', ale#Escape('pylint') . b:command_tail[:-3] . '--from-stdin %s'
Execute(The option for disabling changing directories should work):
let g:ale_python_pylint_change_directory = 0
AssertLinterCwd ''
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'
AssertLinter 'executable with spaces',
\ ale#path#CdString(expand('%:p:h'))
\ . ale#Escape('executable with spaces') . b:command_tail
AssertLinter 'executable with spaces', 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'
AssertLinter 'pylint',
\ ale#path#CdString(expand('%:p:h'))
\ . ale#Escape('pylint') . ' --some-option' . b:command_tail
AssertLinter 'pylint', 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')
call ale#test#SetFilename('python_paths/no_virtualenv/subdir/foo/bar.py')
AssertLinter 'pylint',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
\ . ale#Escape('pylint') . b:command_tail
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir')
AssertLinter 'pylint', 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')
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let b:executable = ale#path#Simplify(
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/pylint'
\)
AssertLinter b:executable,
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape(b:executable) . b:command_tail
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')
AssertLinter b:executable, 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')
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_pylint_use_global = 1
AssertLinter 'pylint',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape('pylint') . b:command_tail
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')
AssertLinter 'pylint', ale#Escape('pylint') . b:command_tail
Execute(Setting executable to 'pipenv' appends 'run pylint'):
let g:ale_python_pylint_executable = 'path/to/pipenv'
let g:ale_python_pylint_use_global = 1
AssertLinter 'path/to/pipenv',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('path/to/pipenv') . ' run pylint'
AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run pylint'
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'
Execute(Pipenv is detected when python_pylint_auto_pipenv is set):
let g:ale_python_pylint_auto_pipenv = 1
call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py')
AssertLinter 'pipenv',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('pipenv') . ' run pylint'
AssertLinterCwd expand('%:p:h')
AssertLinter 'pipenv', ale#Escape('pipenv') . ' run pylint'
\ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s'

View File

@@ -5,9 +5,9 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default command should be correct):
AssertLinter 'ruby', ale#Escape('ruby') . ' -w -c %t'
AssertLinter 'ruby', ale#Escape('ruby') . ' -w -c -T1 %t'
Execute(The executable should be configurable):
let g:ale_ruby_ruby_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar') . ' -w -c %t'
AssertLinter 'foobar', ale#Escape('foobar') . ' -w -c -T1 %t'

View File

@@ -2,67 +2,63 @@ Before:
call ale#assert#SetUpLinterTest('sh', 'shellcheck')
call ale#test#SetFilename('test.sh')
let b:prefix = ale#path#BufferCdString(bufnr(''))
let b:suffix = ' -f gcc -'
After:
unlet! b:is_bash
unlet! b:prefix
unlet! b:suffix
call ale#assert#TearDownLinterTest()
Execute(The default shellcheck command should be correct):
AssertLinter 'shellcheck', b:prefix . ale#Escape('shellcheck') . b:suffix
AssertLinterCwd '%s:h'
AssertLinter 'shellcheck', ale#Escape('shellcheck') . b:suffix
Execute(The option disabling changing directories should work):
let g:ale_sh_shellcheck_change_directory = 0
AssertLinterCwd ''
AssertLinter 'shellcheck', ale#Escape('shellcheck') . b:suffix
Execute(The shellcheck command should accept options):
let b:ale_sh_shellcheck_options = '--foobar'
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' --foobar' . b:suffix
AssertLinter 'shellcheck', 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'
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix
\ ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix
Execute(The shellcheck command should include the dialect):
let b:is_bash = 1
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' -s bash' . b:suffix
AssertLinter 'shellcheck', ale#Escape('shellcheck') . ' -s bash' . b:suffix
Execute(The shellcheck command should use ale_sh_shellcheck_dialect):
let b:ale_sh_shellcheck_dialect = 'ksh93'
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . ' -s ksh93' . b:suffix
AssertLinter 'shellcheck', ale#Escape('shellcheck') . ' -s ksh93' . b:suffix
Execute(The shellcheck command should allow unspecified dialect):
let b:ale_sh_shellcheck_dialect = ''
AssertLinter 'shellcheck',
\ b:prefix . ale#Escape('shellcheck') . b:suffix
AssertLinter 'shellcheck', ale#Escape('shellcheck') . b:suffix
Execute(The shellcheck command should include the dialect before options and exclusions):
let b:is_bash = 1
let b:ale_sh_shellcheck_options = '--foobar'
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
AssertLinter 'shellcheck', b:prefix . ale#Escape('shellcheck')
AssertLinter 'shellcheck', ale#Escape('shellcheck')
\ . ' -s bash --foobar -e foo,bar'
\ . b:suffix
Execute(The -x option should be added when the version is new enough):
AssertLinter 'shellcheck', [
\ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\ ale#Escape('shellcheck') . b:suffix,
\]
GivenCommandOutput [
@@ -73,13 +69,13 @@ Execute(The -x option should be added when the version is new enough):
\]
AssertLinter 'shellcheck', [
\ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
\ ale#Escape('shellcheck') . ' -x' . b:suffix,
\]
" We should cache the version check
GivenCommandOutput []
AssertLinter 'shellcheck', [
\ b:prefix . ale#Escape('shellcheck') . ' -x' . b:suffix,
\ ale#Escape('shellcheck') . ' -x' . b:suffix,
\]
Execute(The -x option should not be added when the version is too old):
@@ -91,7 +87,7 @@ Execute(The -x option should not be added when the version is too old):
\]
AssertLinter 'shellcheck', [
\ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\ ale#Escape('shellcheck') . b:suffix,
\]
Execute(The version check shouldn't be run again for old versions):
@@ -103,8 +99,8 @@ Execute(The version check shouldn't be run again for old versions):
\]
AssertLinter 'shellcheck', [
\ ale#Escape('shellcheck') . ' --version',
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\ ale#Escape('shellcheck') . b:suffix,
\]
AssertLinter 'shellcheck', [
\ b:prefix . ale#Escape('shellcheck') . b:suffix,
\ ale#Escape('shellcheck') . b:suffix,
\]

View File

@@ -10,39 +10,26 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The staticcheck callback should return the right defaults):
AssertLinter 'staticcheck',
\ ale#path#BufferCdString(bufnr(''))
\ . 'staticcheck '
\ . ale#Escape(expand('%' . ':t'))
AssertLinterCwd '%s:h'
AssertLinter 'staticcheck', 'staticcheck %s:t'
Execute(The staticcheck callback should use configured options):
let b:ale_go_staticcheck_options = '-test'
AssertLinter 'staticcheck',
\ ale#path#BufferCdString(bufnr(''))
\ . 'staticcheck '
\ . '-test ' . ale#Escape(expand('%' . ':t'))
AssertLinter 'staticcheck', 'staticcheck -test %s:t'
Execute(The staticcheck `lint_package` option should use the correct command):
let b:ale_go_staticcheck_lint_package = 1
AssertLinter 'staticcheck',
\ ale#path#BufferCdString(bufnr(''))
\ . 'staticcheck .',
AssertLinterCwd '%s:h'
AssertLinter 'staticcheck', 'staticcheck .'
Execute(The staticcheck callback should use the `GO111MODULE` option if set):
let b:ale_go_go111module = 'off'
AssertLinter 'staticcheck',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Env('GO111MODULE', 'off')
\ . 'staticcheck '
\ . ale#Escape(expand('%' . ':t'))
AssertLinter 'staticcheck', ale#Env('GO111MODULE', 'off') . 'staticcheck %s:t'
" Test with lint_package option set
let b:ale_go_staticcheck_lint_package = 1
AssertLinter 'staticcheck',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Env('GO111MODULE', 'off')
\ . 'staticcheck .'
AssertLinter 'staticcheck', ale#Env('GO111MODULE', 'off') . 'staticcheck .'

View File

@@ -6,22 +6,18 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The default tslint command should be correct):
AssertLinter 'tslint',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('tslint') . ' --format json %t'
AssertLinterCwd '%s:h'
AssertLinter 'tslint', 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',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('tslint') . ' --format json'
\ ale#Escape('tslint') . ' --format json'
\ . ' -r ' . ale#Escape('/foo/bar')
\ . ' %t'
Execute(The executable should be configurable and escaped):
let b:ale_typescript_tslint_executable = 'foo bar'
AssertLinter 'foo bar',
\ ale#path#BufferCdString(bufnr(''))
\ . ale#Escape('foo bar') . ' --format json %t'
AssertLinter 'foo bar', ale#Escape('foo bar') . ' --format json %t'

View File

@@ -11,58 +11,48 @@ After:
call ale#assert#TearDownLinterTest()
Execute(The vulture command callback should lint file directory by default):
AssertLinter 'vulture',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('vulture') . ' .'
AssertLinterCwd expand('#' . bufnr('') . ':p:h')
AssertLinter 'vulture', ale#Escape('vulture') . ' .'
Execute(The vulture command callback should lint project root, when present):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/no_virtualenv/subdir/foo/bar.py')
call ale#test#SetFilename('python_paths/no_virtualenv/subdir/foo/bar.py')
AssertLinter 'vulture',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir'))
\ . ale#Escape('vulture') . ' .'
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/no_virtualenv/subdir')
AssertLinter 'vulture', ale#Escape('vulture') . ' .'
Execute(The option for disabling change directory works and only lints file):
let g:ale_python_vulture_change_directory = 0
AssertLinterCwd ''
AssertLinter 'vulture', ale#Escape('vulture') . ' %s'
Execute(The vulture executable should be configurable, and escaped properly):
let g:ale_python_vulture_executable = 'executable with spaces'
AssertLinter 'executable with spaces',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('executable with spaces') . ' .'
AssertLinter 'executable with spaces', ale#Escape('executable with spaces') . ' .'
Execute(The vulture command callback should let you set options):
let g:ale_python_vulture_options = '--some-option'
AssertLinter 'vulture',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('vulture') . ' --some-option .'
AssertLinter 'vulture', ale#Escape('vulture') . ' --some-option .'
Execute(The vulture command callback should detect virtualenv directories and switch to the project root):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let b:executable = ale#path#Simplify(
\ g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/vulture'
\)
AssertLinter b:executable,
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape(b:executable) . ' .'
AssertLinterCwd ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir')
AssertLinter b:executable, ale#Escape(b:executable) . ' .'
Execute(You should able able to use the global vulture instead):
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
call ale#test#SetFilename('python_paths/with_virtualenv/subdir/foo/bar.py')
let g:ale_python_vulture_use_global = 1
AssertLinter 'vulture',
\ ale#path#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir'))
\ . ale#Escape('vulture') . ' .'
AssertLinter 'vulture', ale#Escape('vulture') . ' .'
Execute(Setting executable to 'pipenv' appends 'run vulture'):
let g:ale_python_vulture_executable = 'path/to/pipenv'
AssertLinter 'path/to/pipenv',
\ ale#path#CdString(expand('#' . bufnr('') . ':p:h'))
\ . ale#Escape('path/to/pipenv') . ' run vulture' . ' .'
AssertLinter 'path/to/pipenv', ale#Escape('path/to/pipenv') . ' run vulture' . ' .'