diff options
Diffstat (limited to 'test/fixers')
-rw-r--r-- | test/fixers/test_black_fixer_callback.vader | 8 | ||||
-rw-r--r-- | test/fixers/test_clangformat_fixer_callback.vader | 3 | ||||
-rw-r--r-- | test/fixers/test_dfmt_fixer_callback.vader | 40 | ||||
-rw-r--r-- | test/fixers/test_gnatpp_fixer_callback.vader | 28 | ||||
-rw-r--r-- | test/fixers/test_gofmt_fixer_callback.vader | 18 | ||||
-rw-r--r-- | test/fixers/test_goimports_fixer_callback.vader | 16 | ||||
-rw-r--r-- | test/fixers/test_gomod_fixer_callback.vader | 19 | ||||
-rw-r--r-- | test/fixers/test_hindent_fixer_callback.vader | 18 | ||||
-rw-r--r-- | test/fixers/test_sqlformat_fixer_callback.vader | 24 |
9 files changed, 172 insertions, 2 deletions
diff --git a/test/fixers/test_black_fixer_callback.vader b/test/fixers/test_black_fixer_callback.vader index 25ad05db..75864479 100644 --- a/test/fixers/test_black_fixer_callback.vader +++ b/test/fixers/test_black_fixer_callback.vader @@ -36,6 +36,14 @@ Execute(The black callback should include options): \ {'command': ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option -' }, \ ale#fixers#black#Fix(bufnr('')) +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('')) + 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 diff --git a/test/fixers/test_clangformat_fixer_callback.vader b/test/fixers/test_clangformat_fixer_callback.vader index a55576bf..ae7db4cf 100644 --- a/test/fixers/test_clangformat_fixer_callback.vader +++ b/test/fixers/test_clangformat_fixer_callback.vader @@ -20,7 +20,7 @@ Execute(The clang-format callback should return the correct default values): AssertEqual \ { \ 'command': ale#Escape(g:ale_c_clangformat_executable) - \ . ' ' + \ . ' --assume-filename=' . ale#Escape(bufname(bufnr(''))) \ }, \ ale#fixers#clangformat#Fix(bufnr('')) @@ -31,6 +31,7 @@ Execute(The clangformat callback should include any additional options): AssertEqual \ { \ 'command': ale#Escape(g:ale_c_clangformat_executable) + \ . ' --assume-filename=' . ale#Escape(bufname(bufnr(''))) \ . ' --some-option', \ }, \ ale#fixers#clangformat#Fix(bufnr('')) diff --git a/test/fixers/test_dfmt_fixer_callback.vader b/test/fixers/test_dfmt_fixer_callback.vader new file mode 100644 index 00000000..5ecb56e6 --- /dev/null +++ b/test/fixers/test_dfmt_fixer_callback.vader @@ -0,0 +1,40 @@ +Before: + Save g:ale_d_dfmt_executable + Save g:ale_d_dfmt_options + + " Use an invalid global executable, so we don't match it. + let g:ale_d_dfmt_executable = 'xxxinvalid' + let g:ale_d_dfmt_options = '' + + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The dfmt callback should return the correct default values): + call ale#test#SetFilename('../d_files/test.d') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' -i' + \ . ' %t', + \ }, + \ ale#fixers#dfmt#Fix(bufnr('')) + +Execute(The dfmt callback should include custom dfmt options): + let g:ale_d_dfmt_options = "--space-after-cast" + call ale#test#SetFilename('../d_files/test.d') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('xxxinvalid') + \ . ' -i' + \ . ' ' . g:ale_d_dfmt_options + \ . ' %t', + \ }, + \ ale#fixers#dfmt#Fix(bufnr('')) diff --git a/test/fixers/test_gnatpp_fixer_callback.vader b/test/fixers/test_gnatpp_fixer_callback.vader new file mode 100644 index 00000000..a2bf898e --- /dev/null +++ b/test/fixers/test_gnatpp_fixer_callback.vader @@ -0,0 +1,28 @@ +Before: + call ale#assert#SetUpFixerTest('ada', 'gnatpp') + +After: + " Reset fixers, variables, etc. + " + " Vader's 'Restore' command will be called here. + call ale#assert#TearDownFixerTest() + +Execute(The default command should be correct): + call ale#test#SetFilename('../ada_files/testfile.adb') + + AssertFixer + \ { + \ 'command': ale#Escape(g:ale_ada_gnatpp_executable) .' %t', + \ 'read_temporary_file': 1, + \ } + +Execute(The version check should be correct): + call ale#test#SetFilename('../ada_files/testfile.adb') + let g:ale_ada_gnatpp_options = '--no-alignment' + + AssertFixer + \ { + \ 'command': ale#Escape(g:ale_ada_gnatpp_executable) + \ . ' --no-alignment %t', + \ 'read_temporary_file': 1, + \ } diff --git a/test/fixers/test_gofmt_fixer_callback.vader b/test/fixers/test_gofmt_fixer_callback.vader index 14e6e063..16659655 100644 --- a/test/fixers/test_gofmt_fixer_callback.vader +++ b/test/fixers/test_gofmt_fixer_callback.vader @@ -1,6 +1,7 @@ Before: Save g:ale_go_gofmt_executable Save g:ale_go_gofmt_options + Save g:ale_go_go111module " Use an invalid global executable, so we don't match it. let g:ale_go_gofmt_executable = 'xxxinvalid' @@ -11,6 +12,8 @@ Before: After: Restore + unlet! b:ale_go_go111module + call ale#test#RestoreDirectory() Execute(The gofmt callback should return the correct default values): @@ -27,6 +30,7 @@ Execute(The gofmt callback should return the correct default values): Execute(The gofmt callback should include custom gofmt options): let g:ale_go_gofmt_options = "-r '(a) -> a'" + call ale#test#SetFilename('../go_files/testfile.go') AssertEqual @@ -38,3 +42,17 @@ Execute(The gofmt callback should include custom gofmt options): \ . ' %t', \ }, \ ale#fixers#gofmt#Fix(bufnr('')) + +Execute(The gofmt callback should support Go environment variables): + let g:ale_go_go111module = 'off' + + call ale#test#SetFilename('../go_files/testfile.go') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Env('GO111MODULE', 'off') + \ . ale#Escape('xxxinvalid') . ' -l -w' + \ . ' %t', + \ }, + \ ale#fixers#gofmt#Fix(bufnr('')) diff --git a/test/fixers/test_goimports_fixer_callback.vader b/test/fixers/test_goimports_fixer_callback.vader index cec06354..3ea022ff 100644 --- a/test/fixers/test_goimports_fixer_callback.vader +++ b/test/fixers/test_goimports_fixer_callback.vader @@ -1,6 +1,7 @@ Before: Save g:ale_go_goimports_executable Save g:ale_go_goimports_options + Save g:ale_go_go111module " Use an invalid global executable, so we don't match it. let g:ale_go_goimports_executable = 'xxxinvalid' @@ -12,6 +13,8 @@ Before: After: Restore + unlet! b:ale_go_go111module + call ale#test#RestoreDirectory() Execute(The goimports callback should return 0 when the executable isn't executable): @@ -39,3 +42,16 @@ Execute(The goimports callback should include extra options): \ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w -srcdir %s --xxx %t' \ }, \ ale#fixers#goimports#Fix(bufnr('')) + +Execute(The goimports callback should support Go environment variables): + let g:ale_go_goimports_executable = has('win32') ? 'cmd' : 'echo' + let g:ale_go_go111module = 'on' + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Env('GO111MODULE', 'on') + \ . ale#Escape(g:ale_go_goimports_executable) + \ . ' -l -w -srcdir %s %t' + \ }, + \ ale#fixers#goimports#Fix(bufnr('')) diff --git a/test/fixers/test_gomod_fixer_callback.vader b/test/fixers/test_gomod_fixer_callback.vader index a378e961..422caf63 100644 --- a/test/fixers/test_gomod_fixer_callback.vader +++ b/test/fixers/test_gomod_fixer_callback.vader @@ -1,18 +1,22 @@ Before: Save g:ale_go_go_executable + Save g:ale_go_go111module " Use an invalid global executable, so we don't match it. let g:ale_go_go_executable = 'xxxinvalid' + let g:ale_go_go111module = '' call ale#test#SetDirectory('/testplugin/test/fixers') After: Restore + unlet! b:ale_go_go111module + call ale#test#RestoreDirectory() Execute(The gomod callback should return the correct default values): call ale#test#SetFilename('../go_files/go.mod') - setl ft=gomod + setl filetype=gomod AssertEqual \ { @@ -22,3 +26,16 @@ Execute(The gomod callback should return the correct default values): \ . ' %t', \ }, \ ale#fixers#gomod#Fix(bufnr('')) + +Execute(The gomod callback should support Go environment variables): + call ale#test#SetFilename('../go_files/go.mod') + setl filetype=gomod + let g:ale_go_go111module = 'on' + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Env('GO111MODULE', 'on') + \ . ale#Escape('xxxinvalid') . ' mod edit -fmt %t' + \ }, + \ ale#fixers#gomod#Fix(bufnr('')) diff --git a/test/fixers/test_hindent_fixer_callback.vader b/test/fixers/test_hindent_fixer_callback.vader new file mode 100644 index 00000000..2e5a8b9f --- /dev/null +++ b/test/fixers/test_hindent_fixer_callback.vader @@ -0,0 +1,18 @@ +Before: + call ale#test#SetDirectory('/testplugin/test/fixers') + +After: + Restore + + call ale#test#RestoreDirectory() + +Execute(The hindent callback should return the correct default values): + call ale#test#SetFilename('../haskell_files/testfile.hs') + + AssertEqual + \ { + \ 'read_temporary_file': 1, + \ 'command': ale#Escape('hindent') + \ . ' %t', + \ }, + \ ale#fixers#hindent#Fix(bufnr('')) diff --git a/test/fixers/test_sqlformat_fixer_callback.vader b/test/fixers/test_sqlformat_fixer_callback.vader new file mode 100644 index 00000000..4bace089 --- /dev/null +++ b/test/fixers/test_sqlformat_fixer_callback.vader @@ -0,0 +1,24 @@ +Before: + Save g:ale_sql_sqlformat_executable + Save g:ale_sql_sqlformat_options + +After: + Restore + +Execute(The sqlformat callback should return the correct default values): + AssertEqual + \ { + \ 'command': ale#Escape('sqlformat') . ' -' + \ }, + \ ale#fixers#sqlformat#Fix(bufnr('')) + +Execute(The sqlformat executable and options should be configurable): + let g:ale_sql_sqlformat_executable = '/path/to/sqlformat' + let g:ale_sql_sqlformat_options = '-a' + + AssertEqual + \ { + \ 'command': ale#Escape('/path/to/sqlformat') + \ . ' -a -' + \ }, + \ ale#fixers#sqlformat#Fix(bufnr('')) |