mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-28 12:32:27 +08:00
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:
@@ -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'
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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')
|
||||
|
||||
16
test/command_callback/test_dialyxir_command_callback.vader
Normal file
16
test/command_callback/test_dialyxir_command_callback.vader
Normal 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'
|
||||
16
test/command_callback/test_dogma_command_callback.vader
Normal file
16
test/command_callback/test_dogma_command_callback.vader
Normal 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'
|
||||
@@ -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'
|
||||
@@ -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'
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
76
test/command_callback/test_eslint_command_callback.vader
Normal file
76
test/command_callback/test_eslint_command_callback.vader
Normal 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
|
||||
@@ -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 -'
|
||||
|
||||
@@ -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 ./'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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') . ' .'
|
||||
|
||||
@@ -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 .'
|
||||
|
||||
@@ -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 .'
|
||||
|
||||
@@ -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 .'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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())')
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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,
|
||||
\]
|
||||
|
||||
@@ -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 .'
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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' . ' .'
|
||||
|
||||
@@ -28,8 +28,8 @@ Execute(The autoimport callback should return the correct default values):
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autoimport')) . ' -',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autoimport')) . ' -',
|
||||
\ },
|
||||
\ ale#fixers#autoimport#Fix(bufnr(''))
|
||||
|
||||
@@ -43,8 +43,8 @@ Execute(The autoimport callback should respect custom options):
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autoimport'))
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autoimport'))
|
||||
\ . ' --multi-line=3 --trailing-comma -',
|
||||
\ },
|
||||
\ ale#fixers#autoimport#Fix(bufnr(''))
|
||||
|
||||
@@ -1,30 +1,23 @@
|
||||
Before:
|
||||
Save g:ale_python_black_executable
|
||||
Save g:ale_python_black_options
|
||||
call ale#assert#SetUpFixerTest('python', 'black')
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_python_black_executable = 'xxxinvalid'
|
||||
let g:ale_python_black_options = ''
|
||||
let g:ale_python_black_auto_pipenv = 0
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
silent cd ..
|
||||
silent cd command_callback
|
||||
let g:dir = getcwd()
|
||||
|
||||
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
|
||||
|
||||
After:
|
||||
Restore
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
unlet! g:dir
|
||||
unlet! b:bin_dir
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The black callback should return the correct default values):
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {'command': ale#path#BufferCdString(bufnr('')) . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' -'},
|
||||
\ {
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' -'},
|
||||
\ ale#fixers#black#Fix(bufnr(''))
|
||||
|
||||
Execute(The black callback should include options):
|
||||
@@ -40,6 +33,7 @@ Execute(The black callback should include --pyi for .pyi files):
|
||||
let g:ale_python_black_change_directory = 0
|
||||
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.pyi')
|
||||
|
||||
AssertEqual
|
||||
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --pyi -' },
|
||||
\ ale#fixers#black#Fix(bufnr(''))
|
||||
@@ -48,7 +42,7 @@ Execute(Pipenv is detected when python_black_auto_pipenv is set):
|
||||
let g:ale_python_black_auto_pipenv = 1
|
||||
let g:ale_python_black_change_directory = 0
|
||||
|
||||
call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
|
||||
call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py')
|
||||
|
||||
AssertEqual
|
||||
\ {'command': ale#Escape('pipenv') . ' run black -'},
|
||||
|
||||
@@ -6,7 +6,7 @@ Before:
|
||||
let g:ale_dhall_executable = 'odd-dhall'
|
||||
let g:ale_dhall_options = '--ascii'
|
||||
|
||||
call ale#assert#SetUpFixerTest('dhall-format', 'dhall-format')
|
||||
call ale#assert#SetUpFixerTest('dhall', 'dhall-format')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
@@ -7,7 +7,7 @@ Before:
|
||||
let g:ale_dhall_options = '--ascii'
|
||||
let g:ale_dhall_freeze_options = '--all'
|
||||
|
||||
call ale#assert#SetUpFixerTest('dhall-freeze', 'dhall-freeze')
|
||||
call ale#assert#SetUpFixerTest('dhall', 'dhall-freeze')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
@@ -6,7 +6,7 @@ Before:
|
||||
let g:ale_dhall_executable = 'odd-dhall'
|
||||
let g:ale_dhall_options = '--ascii'
|
||||
|
||||
call ale#assert#SetUpFixerTest('dhall-lint', 'dhall-lint')
|
||||
call ale#assert#SetUpFixerTest('dhall', 'dhall-lint')
|
||||
|
||||
After:
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
@@ -17,9 +17,8 @@ Execute(The executable path should be correct):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'),
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js'))
|
||||
\ . ' --fix %t',
|
||||
@@ -36,6 +35,7 @@ Execute(The ESLint fixer should use a config file option if set for old versions
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('eslint') . ' -c /foo.cfg --fix %t',
|
||||
\ }
|
||||
|
||||
@@ -44,6 +44,7 @@ Execute(The ESLint fixer should use a config file option if set for old versions
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('eslint') . ' --bar -c /foo.cfg --fix %t',
|
||||
\ }
|
||||
|
||||
@@ -52,6 +53,7 @@ Execute(The ESLint fixer should use a config file option if set for old versions
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('eslint') . ' --config /foo.cfg --fix %t',
|
||||
\ }
|
||||
|
||||
@@ -60,6 +62,7 @@ Execute(The ESLint fixer should use a config file option if set for old versions
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('eslint') . ' --bar --config /foo.cfg --fix %t',
|
||||
\ }
|
||||
|
||||
@@ -72,6 +75,7 @@ Execute(The ESLint fixer should use a -c file option if set for eslint_d):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('/bin/eslint_d')
|
||||
\ . ' -c /foo.cfg'
|
||||
\ . ' --stdin-filename %s --stdin --fix-to-stdout'
|
||||
@@ -82,6 +86,7 @@ Execute(The ESLint fixer should use a -c file option if set for eslint_d):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('/bin/eslint_d')
|
||||
\ . ' --bar -c /foo.cfg'
|
||||
\ . ' --stdin-filename %s --stdin --fix-to-stdout'
|
||||
@@ -92,6 +97,7 @@ Execute(The ESLint fixer should use a -c file option if set for eslint_d):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('/bin/eslint_d')
|
||||
\ . ' --config /foo.cfg'
|
||||
\ . ' --stdin-filename %s --stdin --fix-to-stdout'
|
||||
@@ -102,6 +108,7 @@ Execute(The ESLint fixer should use a -c file option if set for eslint_d):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('/bin/eslint_d')
|
||||
\ . ' --bar --config /foo.cfg'
|
||||
\ . ' --stdin-filename %s --stdin --fix-to-stdout'
|
||||
@@ -115,6 +122,7 @@ Execute(The ESLint fixer should use a config file option if set for new versions
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('eslint')
|
||||
\ . ' -c /foo.cfg'
|
||||
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
|
||||
@@ -125,6 +133,7 @@ Execute(The ESLint fixer should use a config file option if set for new versions
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('eslint')
|
||||
\ . ' --bar -c /foo.cfg'
|
||||
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
|
||||
@@ -135,6 +144,7 @@ Execute(The ESLint fixer should use a config file option if set for new versions
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('eslint')
|
||||
\ . ' --config /foo.cfg'
|
||||
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
|
||||
@@ -145,6 +155,7 @@ Execute(The ESLint fixer should use a config file option if set for new versions
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
|
||||
\ 'cwd': '',
|
||||
\ 'command': ale#Escape('eslint')
|
||||
\ . ' --bar --config /foo.cfg'
|
||||
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
|
||||
@@ -156,9 +167,8 @@ Execute(The lower priority configuration file in a nested directory should be pr
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'),
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/subdir-with-config/.eslintrc'))
|
||||
\ . ' --fix %t',
|
||||
@@ -172,9 +182,8 @@ Execute(--config in options should override configuration file detection for old
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'),
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' --config /foo.cfg'
|
||||
\ . ' --fix %t',
|
||||
@@ -185,9 +194,8 @@ Execute(--config in options should override configuration file detection for old
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'),
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c /foo.cfg'
|
||||
\ . ' --fix %t',
|
||||
@@ -199,9 +207,8 @@ Execute(package.json should be used as a last resort):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'),
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js'))
|
||||
\ . ' --fix %t',
|
||||
@@ -212,9 +219,8 @@ Execute(package.json should be used as a last resort):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files'))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/node_modules/.bin/eslint'))
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files'),
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/node_modules/.bin/eslint'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/package.json'))
|
||||
\ . ' --fix %t',
|
||||
\ }
|
||||
@@ -229,9 +235,8 @@ Execute(The version check should be correct):
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' --version',
|
||||
\ {
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'),
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
|
||||
@@ -240,9 +245,8 @@ Execute(The version check should be correct):
|
||||
|
||||
AssertFixer [
|
||||
\ {
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'),
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
|
||||
@@ -255,9 +259,8 @@ Execute(--fix-dry-run should be used for 4.9.0 and up):
|
||||
GivenCommandOutput ['4.9.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/react-app'),
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
|
||||
@@ -269,9 +272,8 @@ Execute(--fix-to-stdout should be used for eslint_d):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d'))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'))
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d'),
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/package.json'))
|
||||
\ . ' --fix %t',
|
||||
\ }
|
||||
@@ -281,9 +283,8 @@ Execute(--fix-to-stdout should be used for eslint_d):
|
||||
GivenCommandOutput ['v3.19.0 (eslint_d v4.2.0)']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d'))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'))
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d'),
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'))
|
||||
\ . ' --stdin-filename %s --stdin --fix-to-stdout',
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
|
||||
\ }
|
||||
@@ -292,9 +293,8 @@ Execute(--fix-to-stdout should be used for eslint_d):
|
||||
GivenCommandOutput ['4.9.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command':
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d'))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'))
|
||||
\ 'cwd': ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d'),
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'))
|
||||
\ . ' --stdin-filename %s --stdin --fix-to-stdout',
|
||||
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
|
||||
\ }
|
||||
|
||||
@@ -1,26 +1,17 @@
|
||||
Before:
|
||||
Save g:ale_python_isort_executable
|
||||
Save g:ale_python_isort_options
|
||||
call ale#assert#SetUpFixerTest('python', 'isort')
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_python_isort_executable = 'xxxinvalid'
|
||||
let g:ale_python_isort_options = ''
|
||||
let g:ale_python_isort_auto_pipenv = 0
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
silent cd ..
|
||||
silent cd command_callback
|
||||
let g:dir = getcwd()
|
||||
|
||||
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
|
||||
|
||||
After:
|
||||
Restore
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
unlet! g:dir
|
||||
unlet! b:bin_dir
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The isort callback should return the correct default values):
|
||||
AssertEqual
|
||||
\ 0,
|
||||
@@ -29,8 +20,8 @@ Execute(The isort callback should return the correct default values):
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort')) . ' -',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort')) . ' -',
|
||||
\ },
|
||||
\ ale#fixers#isort#Fix(bufnr(''))
|
||||
|
||||
@@ -44,8 +35,8 @@ Execute(The isort callback should respect custom options):
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort'))
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort'))
|
||||
\ . ' --multi-line=3 --trailing-comma -',
|
||||
\ },
|
||||
\ ale#fixers#isort#Fix(bufnr(''))
|
||||
@@ -53,8 +44,11 @@ Execute(The isort callback should respect custom options):
|
||||
Execute(Pipenv is detected when python_isort_auto_pipenv is set):
|
||||
let g:ale_python_isort_auto_pipenv = 1
|
||||
|
||||
call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py')
|
||||
call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py')
|
||||
|
||||
AssertEqual
|
||||
\ {'command': ale#path#BufferCdString(bufnr('')) . ale#Escape('pipenv') . ' run isort -'},
|
||||
\ {
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape('pipenv') . ' run isort -'
|
||||
\ },
|
||||
\ ale#fixers#isort#Fix(bufnr(''))
|
||||
|
||||
@@ -73,8 +73,8 @@ Execute(The new --stdin-filepath option should be used when the version is new e
|
||||
GivenCommandOutput ['4.4.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape('prettier-eslint')
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape('prettier-eslint')
|
||||
\ . ' --eslint-config-path ' . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/.eslintrc.js'))
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -83,15 +83,15 @@ Execute(The version number should be cached):
|
||||
GivenCommandOutput ['4.4.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape('prettier-eslint')
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape('prettier-eslint')
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
|
||||
GivenCommandOutput []
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape('prettier-eslint')
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape('prettier-eslint')
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
|
||||
@@ -62,8 +62,8 @@ Execute(--stdin-filepath should be used when prettier is new enough):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --no-semi'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -74,16 +74,16 @@ Execute(The version number should be cached):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
|
||||
GivenCommandOutput []
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
|
||||
@@ -95,8 +95,8 @@ Execute(Should set --parser to `babylon` by default, < 1.16.0):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser babylon'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -109,8 +109,8 @@ Execute(Should set --parser to `babel` by default, >= 1.16.0):
|
||||
GivenCommandOutput ['1.16.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser babel'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -123,8 +123,8 @@ Execute(Should set --parser based on filetype, TypeScript):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser typescript'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -137,8 +137,8 @@ Execute(Should set --parser based on filetype, CSS):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser css'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -151,8 +151,8 @@ Execute(Should set --parser based on filetype, LESS):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser less'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -165,8 +165,8 @@ Execute(Should set --parser based on filetype, SCSS):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser scss'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -179,8 +179,8 @@ Execute(Should set --parser based on filetype, JSON):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser json'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -193,8 +193,8 @@ Execute(Should set --parser based on filetype, JSON5):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser json5'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -207,8 +207,8 @@ Execute(Should set --parser based on filetype, GraphQL):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser graphql'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -221,8 +221,8 @@ Execute(Should set --parser based on filetype, Markdown):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser markdown'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -235,8 +235,8 @@ Execute(Should set --parser based on filetype, Vue):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser vue'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -249,8 +249,8 @@ Execute(Should set --parser based on filetype, YAML):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser yaml'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -263,8 +263,8 @@ Execute(Should set --parser based on filetype, HTML):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser html'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -277,8 +277,8 @@ Execute(Should set --parser based on filetype, Ruby):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser ruby'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -291,8 +291,8 @@ Execute(Should set --parser based on first filetype of multiple filetypes):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser css'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -305,8 +305,8 @@ Execute(Should set --parser for experimental language, Handlebars):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --parser glimmer'
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
@@ -317,8 +317,8 @@ Execute(Changes to directory where .prettierignore is found):
|
||||
GivenCommandOutput ['1.6.0']
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'command': ale#path#CdString(expand('%:p:h:h'))
|
||||
\ . ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ 'cwd': expand('%:p:h:h'),
|
||||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' --stdin-filepath %s --stdin',
|
||||
\ }
|
||||
|
||||
|
||||
@@ -14,8 +14,8 @@ Execute(The stylelint callback should return the correct default values):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js'))
|
||||
\ . ' %t'
|
||||
\ . ' --fix',
|
||||
@@ -28,8 +28,8 @@ Execute(The stylelint callback should include custom stylelint options):
|
||||
AssertFixer
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . (has('win32') ? 'node.exe ' : '')
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js'))
|
||||
\ . ' %t'
|
||||
\ . ' --cache'
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
Before:
|
||||
Save g:ale_python_yamlfix_executable
|
||||
Save g:ale_python_yamlfix_options
|
||||
call ale#assert#SetUpFixerTest('yaml', 'yamlfix')
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_python_yamlfix_executable = 'xxxinvalid'
|
||||
let g:ale_python_yamlfix_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
silent cd ..
|
||||
silent cd command_callback
|
||||
let g:dir = getcwd()
|
||||
@@ -14,11 +8,8 @@ Before:
|
||||
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:bin_dir
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#assert#TearDownFixerTest()
|
||||
|
||||
Execute(The yamlfix callback should return the correct default values):
|
||||
AssertEqual
|
||||
@@ -28,23 +19,19 @@ Execute(The yamlfix callback should return the correct default values):
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.yaml')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yamlfix')) . ' -',
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yamlfix')) . ' -',
|
||||
\ },
|
||||
\ ale#fixers#yamlfix#Fix(bufnr(''))
|
||||
|
||||
Execute(The yamlfix callback should respect custom options):
|
||||
let g:ale_yaml_yamlfix_options = '--multi-line=3 --trailing-comma'
|
||||
|
||||
AssertEqual
|
||||
\ 0,
|
||||
\ ale#fixers#yamlfix#Fix(bufnr(''))
|
||||
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.yaml')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yamlfix'))
|
||||
\ 'cwd': '%s:h',
|
||||
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yamlfix'))
|
||||
\ . ' --multi-line=3 --trailing-comma -',
|
||||
\ },
|
||||
\ ale#fixers#yamlfix#Fix(bufnr(''))
|
||||
|
||||
@@ -5,25 +5,23 @@ Before:
|
||||
Save $PATH
|
||||
let $PATH = ale#path#Simplify(g:dir . '/ant-test-files/bin')
|
||||
|
||||
let g:valid_project = 'ant-test-files/ant-project'
|
||||
let g:invalid_project = 'ant-test-files/non-ant-project'
|
||||
let g:command_tail = ' classpath' . ' -S' . ' -q'
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! g:command_tail
|
||||
unlet! g:valid_project
|
||||
unlet! g:invalid_project
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(Should return `cd '[dir]' && 'ant' classpath -S -q`):
|
||||
call ale#test#SetFilename(valid_project . '/Main.java')
|
||||
call ale#test#SetFilename('ant-test-files/ant-project/Main.java')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/ant-test-files/ant-project'))
|
||||
\ . ale#Escape('ant')
|
||||
\ . g:command_tail,
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir . '/ant-test-files/ant-project'),
|
||||
\ ale#Escape('ant') . ' classpath' . ' -S' . ' -q',
|
||||
\ ],
|
||||
\ ale#ant#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
Execute(Should return empty string if ant cannot be executed):
|
||||
call ale#test#SetFilename('ant-test-files/not-an-ant-project/Main.java')
|
||||
|
||||
AssertEqual ['', ''], ale#ant#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
@@ -26,24 +26,30 @@ Execute(The make command should be correct):
|
||||
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'))
|
||||
\ . 'make -n --always-make',
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
|
||||
\ 'make -n --always-make',
|
||||
\ ],
|
||||
\ ale#c#GetMakeCommand(bufnr(''))
|
||||
|
||||
" You should be able to disable --always-make for a buffer.
|
||||
let b:ale_c_always_make = 0
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'))
|
||||
\ . 'make -n',
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir. '/test_c_projects/makefile_project'),
|
||||
\ 'make -n',
|
||||
\ ],
|
||||
\ ale#c#GetMakeCommand(bufnr(''))
|
||||
|
||||
Execute(Should recognize GNUmakefile as a makefile):
|
||||
call ale#test#SetFilename('test_c_projects/gnumakefile_project/file.c')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir. '/test_c_projects/gnumakefile_project'))
|
||||
\ . 'make -n --always-make',
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir. '/test_c_projects/gnumakefile_project'),
|
||||
\ 'make -n --always-make',
|
||||
\ ],
|
||||
\ ale#c#GetMakeCommand(bufnr(''))
|
||||
|
||||
Execute(The CFlags parser should be able to parse include directives):
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
Before:
|
||||
let g:ale_javascript_eslint_executable = 'eslint_d'
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test')
|
||||
|
||||
runtime ale_linters/javascript/eslint.vim
|
||||
|
||||
After:
|
||||
let g:ale_javascript_eslint_executable = 'eslint'
|
||||
let g:ale_javascript_eslint_use_global = 0
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
call ale#linter#Reset()
|
||||
|
||||
Execute(create-react-app directories should be detected correctly):
|
||||
call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'),
|
||||
\ ale#handlers#eslint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(use-global should override create-react-app detection):
|
||||
let g:ale_javascript_eslint_use_global = 1
|
||||
|
||||
call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
|
||||
|
||||
AssertEqual
|
||||
\ 'eslint_d',
|
||||
\ ale#handlers#eslint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(other app directories should be detected correctly):
|
||||
call ale#test#SetFilename('eslint-test-files/other-app/subdir/testfile.js')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/eslint-test-files/node_modules/.bin/eslint'),
|
||||
\ ale#handlers#eslint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(use-global should override other app directories):
|
||||
let g:ale_javascript_eslint_use_global = 1
|
||||
|
||||
call ale#test#SetFilename('eslint-test-files/other-app/subdir/testfile.js')
|
||||
|
||||
AssertEqual
|
||||
\ 'eslint_d',
|
||||
\ ale#handlers#eslint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(eslint_d should be detected correctly):
|
||||
call ale#test#SetFilename('eslint-test-files/app-with-eslint-d/testfile.js')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Simplify(g:dir . '/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'),
|
||||
\ ale#handlers#eslint#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(eslint.js executables should be run with node on Windows):
|
||||
call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
|
||||
|
||||
" We have to execute the file with node.
|
||||
if has('win32')
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app'))
|
||||
\ . ale#Escape('node.exe') . ' '
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -f json --stdin --stdin-filename %s',
|
||||
\ ale#handlers#eslint#GetCommand(bufnr(''))
|
||||
else
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app'))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -f json --stdin --stdin-filename %s',
|
||||
\ ale#handlers#eslint#GetCommand(bufnr(''))
|
||||
endif
|
||||
|
||||
Execute(eslint.js should be run from containing project with eslint):
|
||||
call ale#test#SetFilename('eslint-test-files/react-app/subdir-with-package-json/testfile.js')
|
||||
|
||||
" We have to execute the file with node.
|
||||
if has('win32')
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app'))
|
||||
\ . ale#Escape('node.exe') . ' '
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -f json --stdin --stdin-filename %s',
|
||||
\ ale#handlers#eslint#GetCommand(bufnr(''))
|
||||
else
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/eslint-test-files/react-app'))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -f json --stdin --stdin-filename %s',
|
||||
\ ale#handlers#eslint#GetCommand(bufnr(''))
|
||||
endif
|
||||
|
||||
Execute(eslint.js executables can be run outside project dir):
|
||||
" Set filename above eslint-test-files (which contains node_modules)
|
||||
call ale#test#SetFilename('testfile.js')
|
||||
|
||||
" cd "..." not present, since project root not found (from node_modules)
|
||||
AssertEqual
|
||||
\ ale#Escape(ale#handlers#eslint#GetExecutable(bufnr('')))
|
||||
\ . ' -f json --stdin --stdin-filename %s',
|
||||
\ ale#handlers#eslint#GetCommand(bufnr(''))
|
||||
@@ -25,12 +25,12 @@ After:
|
||||
Execute(FormatCommand should do nothing to basic command strings):
|
||||
AssertEqual
|
||||
\ ['', 'awesome-linter do something', 0],
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'awesome-linter do something', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'awesome-linter do something', 0, v:null, v:null, [])
|
||||
|
||||
Execute(FormatCommand should handle %%, and ignore other percents):
|
||||
AssertEqual
|
||||
\ ['', '% %%d %%f %x %', 0],
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', '%% %%%d %%%f %x %', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', '%% %%%d %%%f %x %', 0, v:null, v:null, [])
|
||||
|
||||
Execute(FormatCommand should convert %s to the current filename):
|
||||
AssertEqual
|
||||
@@ -39,10 +39,10 @@ Execute(FormatCommand should convert %s to the current filename):
|
||||
\ 'foo ' . ale#Escape(expand('%:p')) . ' bar ' . ale#Escape(expand('%:p')),
|
||||
\ 0,
|
||||
\ ],
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'foo %s bar %s', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'foo %s bar %s', 0, v:null, v:null, [])
|
||||
|
||||
Execute(FormatCommand should convert %t to a new temporary filename):
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo %t bar %t', 0, v:null, [])
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo %t bar %t', 0, v:null, v:null, [])
|
||||
|
||||
call CheckTempFile(g:result[0])
|
||||
|
||||
@@ -56,21 +56,21 @@ Execute(FormatCommand should convert %t to a new temporary filename):
|
||||
AssertEqual g:match[1], g:match[2]
|
||||
|
||||
Execute(FormatCommand should not convert %t to a new temporary filename when the input is given as v:false):
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo %t bar %t', 0, v:false, [])
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo %t bar %t', 0, v:false, v:null, [])
|
||||
|
||||
AssertEqual ['', 'foo %t bar %t', 0], g:result
|
||||
|
||||
Execute(FormatCommand should signal that files are created when temporary files are needed):
|
||||
AssertEqual
|
||||
\ 1,
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'foo %t', 0, v:null, [])[2]
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'foo %t', 0, v:null, v:null, [])[2]
|
||||
|
||||
AssertEqual
|
||||
\ 0,
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'foo %s', 0, v:null, [])[2]
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'foo %s', 0, v:null, v:null, [])[2]
|
||||
|
||||
Execute(FormatCommand should let you combine %s and %t):
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo %t bar %s', 0, v:null, [])
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo %t bar %s', 0, v:null, v:null, [])
|
||||
|
||||
call CheckTempFile(g:result[0])
|
||||
|
||||
@@ -87,30 +87,30 @@ Execute(FormatCommand should replace %e with the escaped executable):
|
||||
if has('win32')
|
||||
AssertEqual
|
||||
\ ['', 'foo foo', 0],
|
||||
\ ale#command#FormatCommand(bufnr('%'), 'foo', '%e %e', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), 'foo', '%e %e', 0, v:null, v:null, [])
|
||||
AssertEqual
|
||||
\ ['', '"foo bar"', 0],
|
||||
\ ale#command#FormatCommand(bufnr('%'), 'foo bar', '%e', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), 'foo bar', '%e', 0, v:null, v:null, [])
|
||||
AssertEqual
|
||||
\ ['', '%e %e', 0],
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', '%e %e', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', '%e %e', 0, v:null, v:null, [])
|
||||
else
|
||||
AssertEqual
|
||||
\ ['', '''foo'' ''foo''', 0],
|
||||
\ ale#command#FormatCommand(bufnr('%'), 'foo', '%e %e', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), 'foo', '%e %e', 0, v:null, v:null, [])
|
||||
AssertEqual
|
||||
\ ['', '''foo bar''', 0],
|
||||
\ ale#command#FormatCommand(bufnr('%'), 'foo bar', '%e', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), 'foo bar', '%e', 0, v:null, v:null, [])
|
||||
AssertEqual
|
||||
\ ['', '%e %e', 0],
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', '%e %e', 0, v:null, [])
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', '%e %e', 0, v:null, v:null, [])
|
||||
endif
|
||||
|
||||
Execute(EscapeCommandPart should escape all percent signs):
|
||||
AssertEqual '%%s %%t %%%% %%s %%t %%%%', ale#engine#EscapeCommandPart('%s %t %% %s %t %%')
|
||||
|
||||
Execute(EscapeCommandPart should pipe in temporary files appropriately):
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo bar', 1, v:null, [])
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo bar', 1, v:null, v:null, [])
|
||||
|
||||
call CheckTempFile(g:result[0])
|
||||
|
||||
@@ -118,7 +118,7 @@ Execute(EscapeCommandPart should pipe in temporary files appropriately):
|
||||
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
|
||||
AssertEqual ale#Escape(g:result[0]), g:match[1]
|
||||
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo bar %t', 1, v:null, [])
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', 'foo bar %t', 1, v:null, v:null, [])
|
||||
|
||||
call CheckTempFile(g:result[0])
|
||||
|
||||
@@ -133,10 +133,10 @@ Execute(FormatCommand should apply filename modifiers to the current file):
|
||||
\ . ' ' . ale#Escape(expand('%:p:h:t'))
|
||||
\ . ' ' . ale#Escape('txt')
|
||||
\ . ' ' . ale#Escape(expand('%:p:r')),
|
||||
\ ale#command#FormatCommand(bufnr(''), '', '%s:h %s:t %s:h:t %s:e %s:r', 0, v:null, [])[1]
|
||||
\ ale#command#FormatCommand(bufnr(''), '', '%s:h %s:t %s:h:t %s:e %s:r', 0, v:null, v:null, [])[1]
|
||||
|
||||
Execute(FormatCommand should apply filename modifiers to the temporary file):
|
||||
let g:result = ale#command#FormatCommand(bufnr(''), '', '%t:h %t:t %t:h:t %t:e %t:r', 0, v:null, [])
|
||||
let g:result = ale#command#FormatCommand(bufnr(''), '', '%t:h %t:t %t:h:t %t:e %t:r', 0, v:null, v:null, [])
|
||||
|
||||
AssertEqual
|
||||
\ ale#Escape(fnamemodify(g:result[0], ':h'))
|
||||
@@ -147,28 +147,40 @@ Execute(FormatCommand should apply filename modifiers to the temporary file):
|
||||
\ g:result[1]
|
||||
|
||||
Execute(FormatCommand should apply filename mappings the current file):
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', '%s', 0, v:null, [
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', '%s', 0, v:null, v:null, [
|
||||
\ [expand('%:p:h'), '/foo/bar'],
|
||||
\])
|
||||
|
||||
Assert g:result[1] =~# '/foo/bar'
|
||||
|
||||
Execute(FormatCommand should apply filename mappings to temporary files):
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', '%t', 0, v:null, [
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', '%t', 0, v:null, v:null, [
|
||||
\ [fnamemodify(tempname(), ':h:h'), '/foo/bar']
|
||||
\])
|
||||
|
||||
Assert g:result[1] =~# '/foo/bar'
|
||||
|
||||
Execute(FormatCommand should apply filename modifiers to mapped filenames):
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', '%s:h', 0, v:null, [
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', '%s:h', 0, v:null, v:null, [
|
||||
\ [expand('%:p:h'), '/foo/bar'],
|
||||
\])
|
||||
|
||||
AssertEqual ale#Escape('/foo/bar'), g:result[1]
|
||||
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', '%t:h:h:h', 0, v:null, [
|
||||
let g:result = ale#command#FormatCommand(bufnr('%'), '', '%t:h:h:h', 0, v:null, v:null, [
|
||||
\ [fnamemodify(tempname(), ':h:h'), '/foo/bar']
|
||||
\])
|
||||
|
||||
AssertEqual ale#Escape('/foo/bar'), g:result[1]
|
||||
|
||||
Execute(FormatCommand should apply regular cwd paths):
|
||||
AssertEqual
|
||||
\ 'cd ' . (has('unix') ? '' : '/d ') . ale#Escape('/foo /bar') . ' && abc',
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'abc', 0, v:null, '/foo /bar', [])[1]
|
||||
\
|
||||
Execute(FormatCommand should apply cwd subsitution and formatting):
|
||||
call ale#test#SetFilename('foo.txt')
|
||||
|
||||
AssertEqual
|
||||
\ 'cd ' . (has('unix') ? '' : '/d ') . ale#Escape(getcwd()) . ' && abc',
|
||||
\ ale#command#FormatCommand(bufnr('%'), '', 'abc', 0, v:null, '%s:h', [])[1]
|
||||
|
||||
@@ -25,9 +25,11 @@ Execute(Should return 'gradlew' command if project includes gradle wapper):
|
||||
call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/gradle-test-files/wrapped-project'))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/gradle-test-files/wrapped-project/gradlew'))
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir . '/gradle-test-files/wrapped-project'),
|
||||
\ ale#Escape(ale#path#Simplify(g:dir . '/gradle-test-files/wrapped-project/gradlew'))
|
||||
\ . g:command_tail,
|
||||
\ ],
|
||||
\ ale#gradle#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
Execute(Should return 'gradle' command if project does not include gradle wapper):
|
||||
@@ -36,14 +38,15 @@ Execute(Should return 'gradle' command if project does not include gradle wapper
|
||||
\ . ale#path#Simplify(g:dir . '/gradle-test-files')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/gradle-test-files/unwrapped-project'))
|
||||
\ . ale#Escape('gradle')
|
||||
\ . g:command_tail,
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir . '/gradle-test-files/unwrapped-project'),
|
||||
\ ale#Escape('gradle') . g:command_tail
|
||||
\ ],
|
||||
\ ale#gradle#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
Execute(Should return empty string if gradle cannot be executed):
|
||||
call ale#test#SetFilename('gradle-test-files/non-gradle-project/src/main/kotlin/dummy.kt')
|
||||
|
||||
AssertEqual
|
||||
\ '',
|
||||
\ ['', ''],
|
||||
\ ale#gradle#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
@@ -89,6 +89,34 @@ Execute (PreProcess should allow command to be a callback):
|
||||
\ 'command': function('type'),
|
||||
\})
|
||||
|
||||
Execute (PreProcess should throw when cwd is not a string):
|
||||
AssertThrows call ale#linter#PreProcess('testft', {
|
||||
\ 'name': 'foo',
|
||||
\ 'callback': 'SomeFunction',
|
||||
\ 'executable': 'echo',
|
||||
\ 'cwd': [],
|
||||
\ 'command': 'echo',
|
||||
\})
|
||||
AssertEqual '`cwd` must be a String or Function if defined', g:vader_exception
|
||||
|
||||
Execute (PreProcess should allow cwd to be a callback):
|
||||
call ale#linter#PreProcess('testft', {
|
||||
\ 'name': 'foo',
|
||||
\ 'callback': 'SomeFunction',
|
||||
\ 'executable': 'echo',
|
||||
\ 'cwd': function('type'),
|
||||
\ 'command': 'echo',
|
||||
\})
|
||||
|
||||
Execute (PreProcess should allow cwd to be a string):
|
||||
call ale#linter#PreProcess('testft', {
|
||||
\ 'name': 'foo',
|
||||
\ 'callback': 'SomeFunction',
|
||||
\ 'executable': 'echo',
|
||||
\ 'cwd': '/foo/bar',
|
||||
\ 'command': 'echo',
|
||||
\})
|
||||
|
||||
Execute (PreProcess should when the output stream isn't a valid string):
|
||||
AssertThrows call ale#linter#PreProcess('testft', {
|
||||
\ 'name': 'foo',
|
||||
@@ -305,7 +333,7 @@ Execute(PreProcess should complain about invalid language values):
|
||||
\}
|
||||
|
||||
AssertThrows call ale#linter#PreProcess('testft', g:linter)
|
||||
AssertEqual '`language` must be a String or Funcref if defined', g:vader_exception
|
||||
AssertEqual '`language` must be a String or Function if defined', g:vader_exception
|
||||
|
||||
Execute(PreProcess should use the filetype as the language string by default):
|
||||
let g:linter = {
|
||||
|
||||
@@ -25,9 +25,11 @@ Execute(Should use 'mvnw' in classpath command if available):
|
||||
call ale#test#SetFilename('maven-test-files/maven-java-project/module1/src/main/java/dummy1.java')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1'))
|
||||
\ . ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1/' . g:expected_wrapper)
|
||||
\ . ' dependency:build-classpath',
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1'),
|
||||
\ ale#Escape(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module1/' . g:expected_wrapper))
|
||||
\ . ' dependency:build-classpath',
|
||||
\ ],
|
||||
\ ale#maven#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
Execute(Should use 'mvn' in classpath command if it is executable and 'mvnw' is unavailable):
|
||||
@@ -36,13 +38,16 @@ Execute(Should use 'mvn' in classpath command if it is executable and 'mvnw' is
|
||||
\ . ale#path#Simplify(g:dir . '/maven-test-files')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#CdString(ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module2'))
|
||||
\ . 'mvn dependency:build-classpath',
|
||||
\ [
|
||||
\ ale#path#Simplify(g:dir . '/maven-test-files/maven-java-project/module2'),
|
||||
\ ale#Escape('mvn')
|
||||
\ . ' dependency:build-classpath',
|
||||
\ ],
|
||||
\ ale#maven#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
Execute(Should return empty string if maven cannot be executed):
|
||||
call ale#test#SetFilename('maven-test-files/non-maven-project/src/main/java/dummy.java')
|
||||
|
||||
AssertEqual
|
||||
\ '',
|
||||
\ ['', ''],
|
||||
\ ale#maven#BuildClasspathCommand(bufnr(''))
|
||||
|
||||
@@ -10,11 +10,11 @@ Execute(CdString should output the correct command string):
|
||||
" We will check that escaping is done correctly for each platform.
|
||||
AssertEqual
|
||||
\ has('unix') ? 'cd ''/foo bar/baz'' && ' : 'cd /d "/foo bar/baz" && ',
|
||||
\ ale#path#CdString('/foo bar/baz')
|
||||
\ ale#command#CdString('/foo bar/baz')
|
||||
|
||||
Execute(BufferCdString should output the correct command string):
|
||||
Execute(CdString handle substitution and formatting):
|
||||
call ale#test#SetFilename('foo.txt')
|
||||
|
||||
AssertEqual
|
||||
\ has('unix') ? 'cd %s:h && ' : 'cd /d %s:h && ',
|
||||
\ ale#path#BufferCdString(bufnr(''))
|
||||
\ ale#command#CdString('%s:h')
|
||||
|
||||
Reference in New Issue
Block a user