diff options
Diffstat (limited to 'test/command_callback')
8 files changed, 125 insertions, 74 deletions
diff --git a/test/command_callback/test_rails_best_practices_command_callback.vader b/test/command_callback/test_rails_best_practices_command_callback.vader index 09436be0..7305f4a6 100644 --- a/test/command_callback/test_rails_best_practices_command_callback.vader +++ b/test/command_callback/test_rails_best_practices_command_callback.vader @@ -7,36 +7,51 @@ Before: call ale#test#SetDirectory('/testplugin/test/command_callback') call ale#test#SetFilename('../ruby_fixtures/valid_rails_app/db/test.rb') + let b:args = '--silent -f json' + \ . ' --output-file ' . (has('win32') ? '%t' : '/dev/stdout') + let b:app_path = ale#path#Winify(g:dir . '/../ruby_fixtures/valid_rails_app') + let b:suffix = has('win32') ? '; type %t' : '' + After: Restore + unlet! b:args + unlet! b:app_path + unlet! b:suffix + call ale#test#RestoreDirectory() Execute(Executable should default to rails_best_practices): AssertEqual - \ '''rails_best_practices'' --silent -f json --output-file /dev/stdout ' - \ . ale#Escape(simplify(g:dir . '/../ruby_fixtures/valid_rails_app')), + \ ale#Escape('rails_best_practices') + \ . ' ' . b:args + \ . ' ' . ale#Escape(b:app_path) + \ . b:suffix, \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) Execute(Should be able to set a custom executable): let g:ale_ruby_rails_best_practices_executable = 'bin/rails_best_practices' AssertEqual - \ '''bin/rails_best_practices'' --silent -f json --output-file /dev/stdout ' - \ . ale#Escape(simplify(g:dir . '/../ruby_fixtures/valid_rails_app')), + \ ale#Escape('bin/rails_best_practices') + \ . ' ' . b:args + \ . ' ' . ale#Escape(b:app_path) + \ . b:suffix, \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) Execute(Setting bundle appends 'exec rails_best_practices'): let g:ale_ruby_rails_best_practices_executable = 'path to/bundle' AssertEqual - \ '''path to/bundle'' exec rails_best_practices --silent -f json --output-file /dev/stdout ' - \ . ale#Escape(simplify(g:dir . '/../ruby_fixtures/valid_rails_app')), + \ ale#Escape('path to/bundle') . ' exec rails_best_practices' + \ . ' ' . b:args + \ . ' ' . ale#Escape(b:app_path) + \ . b:suffix, \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) Execute(Command callback should be empty when not in a valid Rails app): call ale#test#SetFilename('../ruby_fixtures/not_a_rails_app/test.rb') AssertEqual - \ '', - \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) + \ '', + \ ale_linters#ruby#rails_best_practices#GetCommand(bufnr('')) diff --git a/test/command_callback/test_rubocop_command_callback.vader b/test/command_callback/test_rubocop_command_callback.vader index a88d453c..fddf7145 100644 --- a/test/command_callback/test_rubocop_command_callback.vader +++ b/test/command_callback/test_rubocop_command_callback.vader @@ -10,24 +10,30 @@ Before: After: Restore + call ale#linter#Reset() call ale#test#RestoreDirectory() Execute(Executable should default to rubocop): AssertEqual - \ '''rubocop'' --format json --force-exclusion --stdin ' - \ . ale#Escape(g:dir . '/dummy.rb'), + \ ale#Escape('rubocop') + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Winify(g:dir . '/dummy.rb')), \ ale_linters#ruby#rubocop#GetCommand(bufnr('')) Execute(Should be able to set a custom executable): let g:ale_ruby_rubocop_executable = 'bin/rubocop' + AssertEqual - \ '''bin/rubocop'' --format json --force-exclusion --stdin ' - \ . ale#Escape(g:dir . '/dummy.rb'), + \ ale#Escape('bin/rubocop') + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Winify(g:dir . '/dummy.rb')), \ ale_linters#ruby#rubocop#GetCommand(bufnr('')) Execute(Setting bundle appends 'exec rubocop'): let g:ale_ruby_rubocop_executable = 'path to/bundle' + AssertEqual - \ '''path to/bundle'' exec rubocop --format json --force-exclusion --stdin ' - \ . ale#Escape(g:dir . '/dummy.rb'), + \ ale#Escape('path to/bundle') . ' exec rubocop' + \ . ' --format json --force-exclusion --stdin ' + \ . ale#Escape(ale#path#Winify(g:dir . '/dummy.rb')), \ ale_linters#ruby#rubocop#GetCommand(bufnr('')) diff --git a/test/command_callback/test_rust_rls_callbacks.vader b/test/command_callback/test_rust_rls_callbacks.vader index 76e69927..b01f8f06 100644 --- a/test/command_callback/test_rust_rls_callbacks.vader +++ b/test/command_callback/test_rust_rls_callbacks.vader @@ -28,5 +28,5 @@ Execute(The project root should be detected correctly): call ale#test#SetFilename('rust-rls-project/test.rs') AssertEqual - \ g:dir . '/rust-rls-project', + \ ale#path#Winify(g:dir . '/rust-rls-project'), \ ale_linters#rust#rls#GetProjectRoot(bufnr('')) diff --git a/test/command_callback/test_scalastyle_command_callback.vader b/test/command_callback/test_scalastyle_command_callback.vader index f051b025..953d57b3 100644 --- a/test/command_callback/test_scalastyle_command_callback.vader +++ b/test/command_callback/test_scalastyle_command_callback.vader @@ -1,10 +1,16 @@ Before: + Save g:ale_scala_scalastyle_options + Save g:ale_scalastyle_config_loc + + unlet! g:ale_scala_scalastyle_options + unlet! g:ale_scalastyle_config_loc + runtime ale_linters/scala/scalastyle.vim After: + Restore + call ale#linter#Reset() - let g:ale_scala_scalastyle_options = '' - let g:ale_scalastyle_conf_loc = '' Execute(Should return the correct default command): AssertEqual @@ -15,13 +21,16 @@ Execute(Should allow using a custom config file): let g:ale_scalastyle_config_loc = '/dooper/config.xml' AssertEqual - \ 'scalastyle --config ''/dooper/config.xml'' %t', + \ 'scalastyle' + \ . ' --config ' . ale#Escape('/dooper/config.xml') + \ . ' %t', \ ale_linters#scala#scalastyle#GetCommand(bufnr('')) Execute(Should allow using custom options): let g:ale_scala_scalastyle_options = '--warnings false --quiet true' AssertEqual - \ 'scalastyle --config ''/dooper/config.xml'' --warnings false --quiet true %t', + \ 'scalastyle' + \ . ' --warnings false --quiet true' + \ . ' %t', \ ale_linters#scala#scalastyle#GetCommand(bufnr('')) - diff --git a/test/command_callback/test_slimlint_command_callback.vader b/test/command_callback/test_slimlint_command_callback.vader index 98fd9a83..d4dad4c4 100644 --- a/test/command_callback/test_slimlint_command_callback.vader +++ b/test/command_callback/test_slimlint_command_callback.vader @@ -9,8 +9,7 @@ After: Restore unlet! g:default_command - - let g:ale_has_override = {} + unlet! b:conf call ale#linter#Reset() call ale#test#RestoreDirectory() @@ -21,15 +20,20 @@ Execute(The default command should be correct): Execute(The command should have the .rubocop.yml prepended as an env var if one exists): call ale#test#SetFilename('../slimlint-test-files/subdir/file.slim') - AssertEqual - \ 'SLIM_LINT_RUBOCOP_CONF=''/testplugin/test/slimlint-test-files/.rubocop.yml'' ' . g:default_command, - \ ale_linters#slim#slimlint#GetCommand(bufnr('')) - -Execute(The command should have the .rubocop.yml prepended as an env var if one exists on win32): - call ale#test#SetFilename('../slimlint-test-files/subdir/file.slim') - - let g:ale_has_override['win32'] = 1 - - AssertEqual - \ 'set SLIM_LINT_RUBOCOP_CONF=''/testplugin/test/slimlint-test-files/.rubocop.yml'' && ' . g:default_command, - \ ale_linters#slim#slimlint#GetCommand(bufnr('')) + let b:conf = ale#path#Winify(g:dir . '/../slimlint-test-files/.rubocop.yml') + + if has('win32') + " Windows uses 'set var=... && command' + AssertEqual + \ 'set SLIM_LINT_RUBOCOP_CONF=' + \ . ale#Escape(b:conf) + \ . ' && ' . g:default_command, + \ ale_linters#slim#slimlint#GetCommand(bufnr('')) + else + " Unix uses 'var=... command' + AssertEqual + \ 'SLIM_LINT_RUBOCOP_CONF=' + \ . ale#Escape(b:conf) + \ . ' ' . g:default_command, + \ ale_linters#slim#slimlint#GetCommand(bufnr('')) + endif diff --git a/test/command_callback/test_standard_command_callback.vader b/test/command_callback/test_standard_command_callback.vader index 193ead83..279109e0 100644 --- a/test/command_callback/test_standard_command_callback.vader +++ b/test/command_callback/test_standard_command_callback.vader @@ -19,8 +19,6 @@ After: unlet! b:executable - let g:ale_has_override = {} - call ale#test#SetFilename('test.txt') call ale#test#RestoreDirectory() @@ -29,45 +27,36 @@ After: Execute(bin/cmd.js paths should be preferred): call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js') - let b:executable = g:dir - \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' + let b:executable = ale#path#Winify( + \ g:dir + \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' + \) AssertEqual \ b:executable, \ ale_linters#javascript#standard#GetExecutable(bufnr('')) AssertEqual - \ ale#Escape(b:executable) . ' --stdin %s', + \ (has('win32') ? 'node.exe ' : '') + \ . ale#Escape(b:executable) + \ . ' --stdin %s', \ ale_linters#javascript#standard#GetCommand(bufnr('')) Execute(.bin directories should be used too): call ale#test#SetFilename('standard-test-files/with-bin/testfile.js') - let b:executable = g:dir - \ . '/standard-test-files/with-bin/node_modules/.bin/standard' - - AssertEqual - \ b:executable, - \ ale_linters#javascript#standard#GetExecutable(bufnr('')) - - AssertEqual - \ ale#Escape(b:executable) . ' --stdin %s', - \ ale_linters#javascript#standard#GetCommand(bufnr('')) - -Execute(.js files should be executed with node on Windows): - let g:ale_has_override['win32'] = 1 - - call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js') - - let b:executable = g:dir - \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' + let b:executable = ale#path#Winify( + \ g:dir + \ . '/standard-test-files/with-bin/node_modules/.bin/standard' + \) AssertEqual \ b:executable, \ ale_linters#javascript#standard#GetExecutable(bufnr('')) AssertEqual - \ ale#Escape('node.exe') . ' ' . ale#Escape(b:executable) . ' --stdin %s', + \ ale#Escape(b:executable) + \ . ' --stdin %s', \ ale_linters#javascript#standard#GetCommand(bufnr('')) Execute(The global executable should be used otherwise): diff --git a/test/command_callback/test_swaglint_command_callback.vader b/test/command_callback/test_swaglint_command_callback.vader index 5d04e923..379aa0cc 100644 --- a/test/command_callback/test_swaglint_command_callback.vader +++ b/test/command_callback/test_swaglint_command_callback.vader @@ -30,7 +30,12 @@ Execute(The yaml swaglint command callback should allow a global installation to Execute(The yaml swaglint command callback should allow a local installation to be used): call ale#test#SetFilename('swaglint_paths/docs/swagger.yaml') - AssertEqual g:dir . '/swaglint_paths/node_modules/.bin/swaglint', + + AssertEqual + \ ale#path#Winify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint'), \ ale_linters#yaml#swaglint#GetExecutable(bufnr('')) - AssertEqual g:dir . '/swaglint_paths/node_modules/.bin/swaglint -r compact --stdin', + + AssertEqual + \ ale#path#Winify(g:dir . '/swaglint_paths/node_modules/.bin/swaglint') + \ . ' -r compact --stdin', \ ale_linters#yaml#swaglint#GetCommand(bufnr('')) diff --git a/test/command_callback/test_thrift_command_callback.vader b/test/command_callback/test_thrift_command_callback.vader index 43487f42..67008919 100644 --- a/test/command_callback/test_thrift_command_callback.vader +++ b/test/command_callback/test_thrift_command_callback.vader @@ -11,9 +11,17 @@ Before: function! GetCommand(buffer) abort call ale#engine#InitBufferInfo(a:buffer) - let l:result = ale_linters#thrift#thrift#GetCommand(a:buffer) + let l:command = ale_linters#thrift#thrift#GetCommand(a:buffer) call ale#engine#Cleanup(a:buffer) - return l:result + + let l:split_command = split(l:command) + let l:index = index(l:split_command, '-out') + + if l:index >= 0 + let l:split_command[l:index + 1] = 'TEMP' + endif + + return join(l:split_command) endfunction runtime ale_linters/thrift/thrift.vim @@ -34,28 +42,43 @@ Execute(The executable should be configurable): AssertEqual 'foobar', ale_linters#thrift#thrift#GetExecutable(bufnr('')) Execute(The executable should be used in the command): - Assert GetCommand(bufnr('%')) =~# "^'thrift'" + AssertEqual + \ ale#Escape('thrift') . ' --gen cpp -strict -out TEMP %t', + \ GetCommand(bufnr('%')) let b:ale_thrift_thrift_executable = 'foobar' - Assert GetCommand(bufnr('%')) =~# "^'foobar'" + AssertEqual + \ ale#Escape('foobar') . ' --gen cpp -strict -out TEMP %t', + \ GetCommand(bufnr('%')) Execute(The list of generators should be configurable): - Assert GetCommand(bufnr('%')) =~# '--gen cpp' - let b:ale_thrift_thrift_generators = ['java', 'py:dynamic'] - Assert GetCommand(bufnr('%')) =~# '--gen java --gen py:dynamic' + + AssertEqual + \ ale#Escape('thrift') . ' --gen java --gen py:dynamic -strict -out TEMP %t', + \ GetCommand(bufnr('%')) let b:ale_thrift_thrift_generators = [] - Assert GetCommand(bufnr('%')) =~# '--gen cpp' -Execute(The list of include paths should be configurable): - Assert GetCommand(bufnr('%')) !~# '-I' + AssertEqual + \ ale#Escape('thrift') . ' --gen cpp -strict -out TEMP %t', + \ GetCommand(bufnr('%')) +Execute(The list of include paths should be configurable): let b:ale_thrift_thrift_includes = ['included/path'] - Assert GetCommand(bufnr('%')) =~# '-I included/path' -Execute(The string of compiler options should be configurable): - Assert GetCommand(bufnr('%')) =~# '-strict' + AssertEqual + \ ale#Escape('thrift') + \ . ' --gen cpp' + \ . ' -I included/path' + \ . ' -strict -out TEMP %t', + \ GetCommand(bufnr('%')) +Execute(The string of compiler options should be configurable): let b:ale_thrift_thrift_options = '-strict --allow-64bit-consts' - Assert GetCommand(bufnr('%')) =~# '-strict --allow-64bit-consts' + + AssertEqual + \ ale#Escape('thrift') + \ . ' --gen cpp -strict --allow-64bit-consts' + \ . ' -out TEMP %t', + \ GetCommand(bufnr('%')) |