diff options
Diffstat (limited to 'test/fixers')
-rw-r--r-- | test/fixers/test_clangtidy_fixer_callback.vader | 24 | ||||
-rw-r--r-- | test/fixers/test_dhall_fixer_callback.vader | 11 | ||||
-rw-r--r-- | test/fixers/test_eslint_fixer_callback.vader | 4 | ||||
-rw-r--r-- | test/fixers/test_isort_fixer_callback.vader | 5 | ||||
-rw-r--r-- | test/fixers/test_latexindent_fixer_callback.vader | 8 | ||||
-rw-r--r-- | test/fixers/test_ocamlformat_fixer_callback.vader | 6 | ||||
-rw-r--r-- | test/fixers/test_prettier_eslint_fixer.callback.vader | 9 | ||||
-rw-r--r-- | test/fixers/test_prettier_fixer_callback.vader | 14 | ||||
-rw-r--r-- | test/fixers/test_prettier_standard_callback.vader | 19 | ||||
-rw-r--r-- | test/fixers/test_remark_lint_fixer_callback.vader | 24 | ||||
-rw-r--r-- | test/fixers/test_rubocop_fixer_callback.vader | 12 | ||||
-rw-r--r-- | test/fixers/test_standard_fixer_callback.vader | 4 | ||||
-rw-r--r-- | test/fixers/test_stylelint_fixer_callback.vader | 8 |
13 files changed, 108 insertions, 40 deletions
diff --git a/test/fixers/test_clangtidy_fixer_callback.vader b/test/fixers/test_clangtidy_fixer_callback.vader index 68416b36..ca08e6bc 100644 --- a/test/fixers/test_clangtidy_fixer_callback.vader +++ b/test/fixers/test_clangtidy_fixer_callback.vader @@ -1,8 +1,19 @@ Before: + Save g:ale_c_build_dir Save g:ale_c_clangtidy_executable + Save g:ale_c_clangtidy_checks + Save g:ale_c_clangtidy_extra_options + Save g:ale_cpp_clangtidy_executable + Save g:ale_cpp_clangtidy_checks + Save g:ale_cpp_clangtidy_extra_options " Use an invalid global executable, so we don't match it. let g:ale_c_clangtidy_executable = 'xxxinvalid' + let g:ale_c_clangtidy_checks = [] + let g:ale_c_clangtidy_extra_options = '' + let g:ale_cpp_clangtidy_executable = 'xxxinvalidpp' + let g:ale_cpp_clangtidy_checks = [] + let g:ale_cpp_clangtidy_extra_options = '' let g:ale_c_build_dir = '' call ale#test#SetDirectory('/testplugin/test/fixers') @@ -36,16 +47,3 @@ Execute(The clangtidy callback should include any additional options): \ . ' -fix -fix-errors --some-option %t', \ }, \ ale#fixers#clangtidy#Fix(bufnr('')) - -Execute(The clangtidy callback should support cpp files): - call ale#test#SetFilename('c_paths/dummy.cpp') - let g:ale_cpp_clangtidy_executable = 'invalidpp' - set filetype=cpp " The test fails without this - - AssertEqual - \ { - \ 'read_temporary_file': 1, - \ 'command': ale#Escape(g:ale_cpp_clangtidy_executable) - \ . ' -fix -fix-errors %t', - \ }, - \ ale#fixers#clangtidy#Fix(bufnr('')) diff --git a/test/fixers/test_dhall_fixer_callback.vader b/test/fixers/test_dhall_fixer_callback.vader new file mode 100644 index 00000000..f27880b7 --- /dev/null +++ b/test/fixers/test_dhall_fixer_callback.vader @@ -0,0 +1,11 @@ +Before: + call ale#assert#SetUpFixerTest('dhall', 'dhall') + +After: + call ale#assert#TearDownFixerTest() + +Execute(The default command should be correct): + AssertFixer + \ { 'read_temporary_file': 1, + \ 'command': ale#Escape('dhall') . ' format --inplace %t' + \ } diff --git a/test/fixers/test_eslint_fixer_callback.vader b/test/fixers/test_eslint_fixer_callback.vader index 400267ac..50fc6672 100644 --- a/test/fixers/test_eslint_fixer_callback.vader +++ b/test/fixers/test_eslint_fixer_callback.vader @@ -1,7 +1,11 @@ Before: call ale#assert#SetUpFixerTest('javascript', 'eslint') + Save g:ale_command_wrapper + runtime autoload/ale/handlers/eslint.vim + let g:ale_command_wrapper = '' + After: call ale#assert#TearDownFixerTest() diff --git a/test/fixers/test_isort_fixer_callback.vader b/test/fixers/test_isort_fixer_callback.vader index 50818621..7f389dcf 100644 --- a/test/fixers/test_isort_fixer_callback.vader +++ b/test/fixers/test_isort_fixer_callback.vader @@ -4,6 +4,7 @@ Before: " Use an invalid global executable, so we don't match it. let g:ale_python_isort_executable = 'xxxinvalid' + let g:ale_python_isort_options = '' call ale#test#SetDirectory('/testplugin/test/fixers') silent cd .. @@ -27,7 +28,7 @@ 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#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir/foo')) + \ 'command': ale#path#BufferCdString(bufnr('')) \ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort')) . ' -', \ }, \ ale#fixers#isort#Fix(bufnr('')) @@ -42,7 +43,7 @@ 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#CdString(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/subdir/foo')) + \ 'command': ale#path#BufferCdString(bufnr('')) \ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort')) \ . ' --multi-line=3 --trailing-comma -', \ }, diff --git a/test/fixers/test_latexindent_fixer_callback.vader b/test/fixers/test_latexindent_fixer_callback.vader index d0da94a1..a440ed65 100644 --- a/test/fixers/test_latexindent_fixer_callback.vader +++ b/test/fixers/test_latexindent_fixer_callback.vader @@ -18,10 +18,8 @@ Execute(The latexindent callback should return the correct default values): AssertEqual \ { - \ 'read_temporary_file': 1, \ 'command': ale#Escape('xxxinvalid') - \ . ' -l -w' - \ . ' %t', + \ . ' -l' \ }, \ ale#fixers#latexindent#Fix(bufnr('')) @@ -31,10 +29,8 @@ Execute(The latexindent callback should include custom gofmt options): AssertEqual \ { - \ 'read_temporary_file': 1, \ 'command': ale#Escape('xxxinvalid') - \ . ' -l -w' + \ . ' -l' \ . ' ' . g:ale_tex_latexindent_options - \ . ' %t', \ }, \ ale#fixers#latexindent#Fix(bufnr('')) diff --git a/test/fixers/test_ocamlformat_fixer_callback.vader b/test/fixers/test_ocamlformat_fixer_callback.vader index f0c36ed7..0ccdb070 100644 --- a/test/fixers/test_ocamlformat_fixer_callback.vader +++ b/test/fixers/test_ocamlformat_fixer_callback.vader @@ -19,8 +19,7 @@ Execute(The ocamlformat callback should return the correct default values): AssertEqual \ { \ 'command': ale#Escape('xxxinvalid') - \ . ' --name=' . ale#Escape(bufname(bufnr(''))) - \ . ' -', + \ . ' --name=%s -', \ }, \ ale#fixers#ocamlformat#Fix(bufnr('')) @@ -32,7 +31,6 @@ Execute(The ocamlformat callback should include custom ocamlformat options): \ { \ 'command': ale#Escape('xxxinvalid') \ . ' ' . g:ale_ocaml_ocamlformat_options - \ . ' --name=' . ale#Escape(bufname(bufnr(''))) - \ . ' -', + \ . ' --name=%s -', \ }, \ ale#fixers#ocamlformat#Fix(bufnr('')) diff --git a/test/fixers/test_prettier_eslint_fixer.callback.vader b/test/fixers/test_prettier_eslint_fixer.callback.vader index 90e11672..be8f04e3 100644 --- a/test/fixers/test_prettier_eslint_fixer.callback.vader +++ b/test/fixers/test_prettier_eslint_fixer.callback.vader @@ -1,5 +1,8 @@ Before: call ale#assert#SetUpFixerTest('javascript', 'prettier_eslint') + Save g:ale_command_wrapper + + let g:ale_command_wrapper = '' After: call ale#assert#TearDownFixerTest() @@ -70,7 +73,7 @@ Execute(The new --stdin-filepath option should be used when the version is new e GivenCommandOutput ['4.4.0'] AssertFixer \ { - \ 'command': ale#path#CdString(expand('%:p:h')) + \ 'command': ale#path#BufferCdString(bufnr('')) \ . 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', @@ -80,7 +83,7 @@ Execute(The version number should be cached): GivenCommandOutput ['4.4.0'] AssertFixer \ { - \ 'command': ale#path#CdString(expand('%:p:h')) + \ 'command': ale#path#BufferCdString(bufnr('')) \ . ale#Escape('prettier-eslint') \ . ' --stdin-filepath %s --stdin', \ } @@ -88,7 +91,7 @@ Execute(The version number should be cached): GivenCommandOutput [] AssertFixer \ { - \ 'command': ale#path#CdString(expand('%:p:h')) + \ 'command': ale#path#BufferCdString(bufnr('')) \ . ale#Escape('prettier-eslint') \ . ' --stdin-filepath %s --stdin', \ } diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader index 062ae8cf..fdd97df3 100644 --- a/test/fixers/test_prettier_fixer_callback.vader +++ b/test/fixers/test_prettier_fixer_callback.vader @@ -1,5 +1,8 @@ Before: call ale#assert#SetUpFixerTest('javascript', 'prettier') + Save g:ale_command_wrapper + + let g:ale_command_wrapper = '' silent cd .. silent cd command_callback @@ -294,6 +297,17 @@ Execute(Should set --parser for experimental language, Handlebars): \ . ' --stdin-filepath %s --stdin', \ } +Execute(Changes to directory where .prettierignore is found): + call ale#test#SetFilename('../prettier-test-files/with_prettierignore/src/testfile.js') + + GivenCommandOutput ['1.6.0'] + AssertFixer + \ { + \ 'command': ale#path#CdString(expand('%:p:h:h')) + \ . ale#Escape(g:ale_javascript_prettier_executable) + \ . ' --stdin-filepath %s --stdin', + \ } + Execute(The prettier_d post-processor should permit regular JavaScript content): AssertEqual \ [ diff --git a/test/fixers/test_prettier_standard_callback.vader b/test/fixers/test_prettier_standard_callback.vader new file mode 100644 index 00000000..ab33fe20 --- /dev/null +++ b/test/fixers/test_prettier_standard_callback.vader @@ -0,0 +1,19 @@ +Before: + call ale#assert#SetUpFixerTest('javascript', 'prettier_standard') + + silent cd .. + silent cd command_callback + let g:dir = getcwd() + +After: + call ale#assert#TearDownFixerTest() + +Execute(The prettier callback should return the correct default values): + call ale#test#SetFilename('../prettier-test-files/testfile.js') + + AssertFixer + \ { + \ 'command': ale#Escape(g:ale_javascript_prettier_standard_executable) + \ . ' --stdin' + \ . ' --stdin-filepath=%s ', + \ } diff --git a/test/fixers/test_remark_lint_fixer_callback.vader b/test/fixers/test_remark_lint_fixer_callback.vader new file mode 100644 index 00000000..5e2e342d --- /dev/null +++ b/test/fixers/test_remark_lint_fixer_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:ale_markdown_remark_lint_executable + Save g:ale_markdown_remark_lint_options + +After: + Restore + +Execute(The remark callback should return the correct default values): + AssertEqual + \ { + \ 'command': ale#Escape('remark') + \ }, + \ ale#fixers#remark_lint#Fix(bufnr('')) + +Execute(The remark executable and options should be configurable): + let g:ale_markdown_remark_lint_executable = '/path/to/remark' + let g:ale_markdown_remark_lint_options = '-h' + + AssertEqual + \ { + \ 'command': ale#Escape('/path/to/remark') + \ . ' -h', + \ }, + \ ale#fixers#remark_lint#Fix(bufnr('')) diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader index 305881e0..84579d31 100644 --- a/test/fixers/test_rubocop_fixer_callback.vader +++ b/test/fixers/test_rubocop_fixer_callback.vader @@ -23,8 +23,7 @@ Execute(The rubocop callback should return the correct default values): \ { \ 'process_with': 'ale#fixers#rubocop#PostProcess', \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) - \ . ' --auto-correct --force-exclusion --stdin ' - \ . ale#Escape(expand('#' . bufnr('') . ':p')), + \ . ' --auto-correct --force-exclusion --stdin %s', \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -36,8 +35,7 @@ Execute(The rubocop callback should include configuration files): \ 'process_with': 'ale#fixers#rubocop#PostProcess', \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) - \ . ' --auto-correct --force-exclusion --stdin ' - \ . ale#Escape(expand('#' . bufnr('') . ':p')), + \ . ' --auto-correct --force-exclusion --stdin %s', \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -51,8 +49,7 @@ Execute(The rubocop callback should include custom rubocop options): \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) \ . ' --except Lint/Debugger' - \ . ' --auto-correct --force-exclusion --stdin ' - \ . ale#Escape(expand('#' . bufnr('') . ':p')), + \ . ' --auto-correct --force-exclusion --stdin %s', \ }, \ ale#fixers#rubocop#Fix(bufnr('')) @@ -65,8 +62,7 @@ Execute(The rubocop callback should use auto-correct-all option when set): \ 'process_with': 'ale#fixers#rubocop#PostProcess', \ 'command': ale#Escape(g:ale_ruby_rubocop_executable) \ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/ruby_paths/with_config/.rubocop.yml')) - \ . ' --auto-correct-all --force-exclusion --stdin ' - \ . ale#Escape(expand('#' . bufnr('') . ':p')), + \ . ' --auto-correct-all --force-exclusion --stdin %s' \ }, \ ale#fixers#rubocop#Fix(bufnr('')) diff --git a/test/fixers/test_standard_fixer_callback.vader b/test/fixers/test_standard_fixer_callback.vader index db9f20f6..f5e9c487 100644 --- a/test/fixers/test_standard_fixer_callback.vader +++ b/test/fixers/test_standard_fixer_callback.vader @@ -15,7 +15,7 @@ Execute(The executable path should be correct): \ 'read_temporary_file': 1, \ 'command': (has('win32') ? 'node.exe ' : '') \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js')) - \ . ' --fix %t', + \ . ' --fix --stdin < %s > %t', \ }, \ ale#fixers#standard#Fix(bufnr('')) @@ -26,6 +26,6 @@ Execute(Custom options should be supported): AssertEqual \ { \ 'read_temporary_file': 1, - \ 'command': ale#Escape('standard') . ' --foo-bar --fix %t', + \ 'command': ale#Escape('standard') . ' --foo-bar --fix --stdin < %s > %t', \ }, \ ale#fixers#standard#Fix(bufnr('')) diff --git a/test/fixers/test_stylelint_fixer_callback.vader b/test/fixers/test_stylelint_fixer_callback.vader index f677cdf7..8fbd8a51 100644 --- a/test/fixers/test_stylelint_fixer_callback.vader +++ b/test/fixers/test_stylelint_fixer_callback.vader @@ -1,4 +1,8 @@ Before: + Save g:ale_stylelint_options + + let g:ale_stylelint_options = '' + call ale#assert#SetUpFixerTest('css', 'stylelint') After: @@ -10,7 +14,7 @@ Execute(The stylelint callback should return the correct default values): AssertFixer \ { \ 'read_temporary_file': 1, - \ 'command': ale#path#CdString(expand('%:p:h')) + \ 'command': ale#path#BufferCdString(bufnr('')) \ . (has('win32') ? 'node.exe ' : '') \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) \ . ' %t' @@ -24,7 +28,7 @@ Execute(The stylelint callback should include custom stylelint options): AssertFixer \ { \ 'read_temporary_file': 1, - \ 'command': ale#path#CdString(expand('%:p:h')) + \ 'command': ale#path#BufferCdString(bufnr('')) \ . (has('win32') ? 'node.exe ' : '') \ . ale#Escape(ale#path#Simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js')) \ . ' %t' |