diff options
Diffstat (limited to 'test/command_callback')
19 files changed, 251 insertions, 12 deletions
diff --git a/test/command_callback/ink_paths/story/main.ink b/test/command_callback/ink_paths/story/main.ink new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/ink_paths/story/main.ink diff --git a/test/command_callback/python_paths/with_virtualenv/subdir/foo/bar.pyi b/test/command_callback/python_paths/with_virtualenv/subdir/foo/bar.pyi new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/command_callback/python_paths/with_virtualenv/subdir/foo/bar.pyi diff --git a/test/command_callback/test_bingo_command_callback.vader b/test/command_callback/test_bingo_command_callback.vader index f4cb3231..5544effa 100644 --- a/test/command_callback/test_bingo_command_callback.vader +++ b/test/command_callback/test_bingo_command_callback.vader @@ -1,4 +1,6 @@ Before: + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'bingo') After: @@ -9,6 +11,7 @@ After: endif unlet! b:ale_completion_enabled + unlet! b:ale_go_go111module call ale#assert#TearDownLinterTest() @@ -34,6 +37,14 @@ Execute(should set bingo options): AssertLinter 'bingo', \ ale#Escape('bingo') . ' --mode stdio --trace' +Execute(should support Go environment variables): + call ale#test#SetFilename('go_paths/go1/prj1/file.go') + let b:ale_go_go111module = 'on' + + AssertLinter 'bingo', + \ ale#Env('GO111MODULE', 'on') . ale#Escape('bingo') . ' --mode stdio' + + Execute(Should return directory for 'go.mod' if found in parent directory): call ale#test#SetFilename('../go_files/test.go') @@ -44,3 +55,20 @@ Execute(Should return nearest directory with '.git' if found in parent directory call mkdir(g:dir . '/.git') AssertLSPProject g:dir + +Execute(Should ignore 'go.mod' and return '.git' dir if modules off): + call ale#test#SetFilename('../go_files/test.go') + + let b:ale_go_go111module = 'off' + let b:parent_dir = ale#path#Simplify(g:dir . '/..') + let b:git_dir = b:parent_dir . '/.git' + + if !isdirectory(b:git_dir) + call mkdir(b:git_dir) + endif + + AssertLSPProject b:parent_dir + + call delete(b:git_dir, 'd') + unlet! b:parent_dir + unlet! b:git_dir diff --git a/test/command_callback/test_elm_lsp_command_callbacks.vader b/test/command_callback/test_elm_ls_command_callbacks.vader index d06ef134..3e1d5fbf 100644 --- a/test/command_callback/test_elm_lsp_command_callbacks.vader +++ b/test/command_callback/test_elm_ls_command_callbacks.vader @@ -1,5 +1,5 @@ Before: - call ale#assert#SetUpLinterTest('elm', 'elm_lsp') + call ale#assert#SetUpLinterTest('elm', 'elm_ls') After: call ale#assert#TearDownLinterTest() @@ -7,7 +7,7 @@ After: Execute(The default executable path should be correct): call ale#test#SetFilename('../elm-test-files/newapp/src/Main.elm') - AssertLinter 'elm-lsp', ale#Escape('elm-lsp') . ' --stdio' + AssertLinter 'elm-language-server', ale#Escape('elm-language-server') . ' --stdio' Execute(The project root should be detected correctly): AssertLSPProject '' @@ -19,11 +19,11 @@ Execute(The project root should be detected correctly): Execute(Should let users configure a global executable and override local paths): call ale#test#SetFilename('../elm-test-files/newapp/src/Main.elm') - let g:ale_elm_lsp_executable = '/path/to/custom/elm-lsp' - let g:ale_elm_lsp_use_global = 1 + let g:ale_elm_ls_executable = '/path/to/custom/elm-language-server' + let g:ale_elm_ls_use_global = 1 - AssertLinter '/path/to/custom/elm-lsp', - \ ale#Escape('/path/to/custom/elm-lsp') . ' --stdio' + AssertLinter '/path/to/custom/elm-language-server', + \ ale#Escape('/path/to/custom/elm-language-server') . ' --stdio' Execute(The language should be correct): AssertLSPLanguage 'elm' diff --git a/test/command_callback/test_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader index 79015b75..fdf23866 100644 --- a/test/command_callback/test_gobuild_command_callback.vader +++ b/test/command_callback/test_gobuild_command_callback.vader @@ -14,6 +14,16 @@ Execute(The default commands should be correct): \ ale#path#CdString(expand('%:p:h')) \ . 'go test -c -o /dev/null ./' +Execute(Go environment variables should be supported): + let b:ale_go_go111module = 'on' + + AssertLinter 'go', + \ ale#path#CdString(expand('%:p:h')) + \ . 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' diff --git a/test/command_callback/test_gofmt_command_callback.vader b/test/command_callback/test_gofmt_command_callback.vader new file mode 100644 index 00000000..4da1f6c8 --- /dev/null +++ b/test/command_callback/test_gofmt_command_callback.vader @@ -0,0 +1,23 @@ +Before: + Save g:ale_go_go111module + + call ale#assert#SetUpLinterTest('go', 'gofmt') + call ale#test#SetFilename('../go_files/testfile2.go') + +After: + Restore + + unlet! b:ale_go_go111module + + call ale#assert#TearDownLinterTest() + +Execute(The default gofmt command should be correct): + AssertLinter 'gofmt', + \ ale#Escape('gofmt') . ' -e %t' + +Execute(The gofmt command should support Go environment variables): + let b:ale_go_go111module = 'on' + + AssertLinter 'gofmt', + \ ale#Env('GO111MODULE', 'on') + \ . ale#Escape('gofmt') . ' -e %t' diff --git a/test/command_callback/test_golangci_lint_command_callback.vader b/test/command_callback/test_golangci_lint_command_callback.vader index 345f58b1..7f1e2ac4 100644 --- a/test/command_callback/test_golangci_lint_command_callback.vader +++ b/test/command_callback/test_golangci_lint_command_callback.vader @@ -1,8 +1,14 @@ Before: + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'golangci_lint') call ale#test#SetFilename('test.go') After: + Restore + + unlet! b:ale_go_go111module + call ale#assert#TearDownLinterTest() Execute(The golangci-lint defaults should be correct): @@ -30,6 +36,16 @@ Execute(The golangci-lint callback should use configured options): \ . ' run ' . ale#Escape(expand('%' . ':t')) \ . ' --foobar' +Execute(The golangci-lint callback should support environment variables): + let b:ale_go_go111module = 'on' + + AssertLinter 'golangci-lint', + \ ale#path#CdString(expand('%:p:h')) + \ . ale#Env('GO111MODULE', 'on') + \ . ale#Escape('golangci-lint') + \ . ' run ' . ale#Escape(expand('%' . ':t')) + \ . ' --enable-all' + Execute(The golangci-lint `lint_package` option should use the correct command): let b:ale_go_golangci_lint_package = 1 diff --git a/test/command_callback/test_golangserver_command_callback.vader b/test/command_callback/test_golangserver_command_callback.vader index 90fdc26f..325adf63 100644 --- a/test/command_callback/test_golangserver_command_callback.vader +++ b/test/command_callback/test_golangserver_command_callback.vader @@ -1,6 +1,7 @@ Before: Save $GOPATH Save g:ale_completion_enabled + Save g:ale_go_go111module let g:ale_completion_enabled = 0 let g:sep = has('win32') ? ';' : ':' @@ -14,6 +15,7 @@ After: Restore unlet! b:ale_completion_enabled + unlet! b:ale_go_go111module unlet! g:sep call ale#assert#TearDownLinterTest() @@ -52,6 +54,12 @@ Execute(should ignore go-langserver -gocodecompletion option): AssertLinter 'go-langserver', ale#Escape('go-langserver') . ' -trace' +Execute(should support Go environment variables): + let b:ale_go_go111module = 'on' + + AssertLinter 'go-langserver', + \ ale#Env('GO111MODULE', 'on') . ale#Escape('go-langserver') + Execute(should set go-langserver for go app1): call ale#test#SetFilename('go_paths/go1/prj1/file.go') diff --git a/test/command_callback/test_golint_command_callbacks.vader b/test/command_callback/test_golint_command_callbacks.vader index 7c300309..64916707 100644 --- a/test/command_callback/test_golint_command_callbacks.vader +++ b/test/command_callback/test_golint_command_callbacks.vader @@ -1,7 +1,13 @@ Before: + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'golint') After: + Restore + + unlet! b:ale_go_go111module + call ale#assert#TearDownLinterTest() Execute(The default golint command should be correct): @@ -16,3 +22,9 @@ Execute(The golint options should be configurable): let b:ale_go_golint_options = '--foo' AssertLinter 'golint', ale#Escape('golint') . ' --foo %t' + +Execute(The golint command should support Go environment variables): + let b:ale_go_go111module = 'on' + + AssertLinter 'golint', + \ ale#Env('GO111MODULE', 'on') . ale#Escape('golint') . ' %t' diff --git a/test/command_callback/test_gometalinter_command_callback.vader b/test/command_callback/test_gometalinter_command_callback.vader index 88e86801..d922efc6 100644 --- a/test/command_callback/test_gometalinter_command_callback.vader +++ b/test/command_callback/test_gometalinter_command_callback.vader @@ -1,8 +1,14 @@ Before: + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'gometalinter') call ale#test#SetFilename('test.go') After: + Restore + + unlet! b:ale_go_go111module + call ale#assert#TearDownLinterTest() Execute(The gometalinter defaults should be correct): @@ -30,6 +36,16 @@ Execute(The gometalinter callback should use configured options): \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' --foobar' . ' .' +Execute(The gometalinter should use configured environment variables): + let b:ale_go_go111module = 'off' + + AssertLinter 'gometalinter', + \ ale#path#CdString(expand('%:p:h')) + \ . ale#Env('GO111MODULE', 'off') + \ . ale#Escape('gometalinter') + \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) + \ . ' .' + Execute(The gometalinter `lint_package` option should use the correct command): let b:ale_go_gometalinter_lint_package = 1 diff --git a/test/command_callback/test_gopls_command_callback.vader b/test/command_callback/test_gopls_command_callback.vader index 0e079a73..92b20b18 100644 --- a/test/command_callback/test_gopls_command_callback.vader +++ b/test/command_callback/test_gopls_command_callback.vader @@ -1,13 +1,15 @@ Before: + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'gopls') After: - Restore - if isdirectory(g:dir . '/.git') call delete(g:dir . '/.git', 'd') endif + unlet! b:ale_go_go111module + unlet! b:ale_go_go111module unlet! b:ale_completion_enabled call ale#assert#TearDownLinterTest() @@ -34,6 +36,12 @@ Execute(should set gopls options): AssertLinter 'gopls', \ ale#Escape('gopls') . ' --mode stdio --trace' +Execute(should support go environment variables): + let b:ale_go_go111module = 'off' + + AssertLinter 'gopls', + \ ale#Env('GO111MODULE', 'off') . ale#Escape('gopls') . ' --mode stdio' + Execute(Should return directory for 'go.mod' if found in parent directory): call ale#test#SetFilename('../go_files/test.go') @@ -44,3 +52,20 @@ Execute(Should return nearest directory with '.git' if found in parent directory call mkdir(g:dir . '/.git') AssertLSPProject g:dir + +Execute(Should ignore 'go.mod' and return '.git' dir if modules off): + call ale#test#SetFilename('../go_files/test.go') + + let b:ale_go_go111module = 'off' + let b:parent_dir = ale#path#Simplify(g:dir . '/..') + let b:git_dir = b:parent_dir . '/.git' + + if !isdirectory(b:git_dir) + call mkdir(b:git_dir) + endif + + AssertLSPProject b:parent_dir + + call delete(b:git_dir, 'd') + unlet! b:parent_dir + unlet! b:git_dir diff --git a/test/command_callback/test_gosimple_command_callback.vader b/test/command_callback/test_gosimple_command_callback.vader index 59013df0..ee89eed8 100644 --- a/test/command_callback/test_gosimple_command_callback.vader +++ b/test/command_callback/test_gosimple_command_callback.vader @@ -1,10 +1,21 @@ Before: + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'gosimple') call ale#test#SetFilename('../go_files/testfile2.go') After: + unlet! b:ale_go_go111module + call ale#assert#TearDownLinterTest() Execute(The default gosimple command should be correct): AssertLinter 'gosimple', \ ale#path#CdString(expand('%:p:h')) . ' gosimple .' + +Execute(The gosimple command should support Go environment variables): + let b:ale_go_go111module = 'on' + + AssertLinter 'gosimple', + \ ale#path#CdString(expand('%:p:h')) . ' ' + \ . ale#Env('GO111MODULE', 'on') . 'gosimple .' diff --git a/test/command_callback/test_gotype_command_callback.vader b/test/command_callback/test_gotype_command_callback.vader index 113f4823..1334fcff 100644 --- a/test/command_callback/test_gotype_command_callback.vader +++ b/test/command_callback/test_gotype_command_callback.vader @@ -1,8 +1,12 @@ Before: + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'gotype') call ale#test#SetFilename('../go_files/testfile2.go') After: + unlet! b:ale_go_go111module + call ale#assert#TearDownLinterTest() Execute(The default gotype command should be correct): @@ -13,3 +17,11 @@ Execute(The gotype callback should ignore test files): call ale#test#SetFilename('bla_test.go') AssertLinter 'gotype', '' + +Execute(The gotype callback should support Go environment variables): + let b:ale_go_go111module = 'on' + + AssertLinter 'gotype', + \ ale#path#CdString(expand('%:p:h')) . ' ' + \ . ale#Env('GO111MODULE', 'on') + \ . 'gotype -e .' diff --git a/test/command_callback/test_govet_command_callback.vader b/test/command_callback/test_govet_command_callback.vader index a55c0812..59022180 100644 --- a/test/command_callback/test_govet_command_callback.vader +++ b/test/command_callback/test_govet_command_callback.vader @@ -1,10 +1,15 @@ Before: Save g:ale_go_go_executable Save g:ale_go_govet_options + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'govet') After: Restore + + unlet! b:ale_go_go111module + call ale#assert#TearDownLinterTest() Execute(The default command should be correct): @@ -12,8 +17,18 @@ Execute(The default command should be correct): Execute(Extra options should be supported): let g:ale_go_govet_options = '--foo-bar' + AssertLinter 'go', ale#path#CdString(expand('%:p:h')) . ' go vet --foo-bar .' Execute(The executable should be configurable): let g:ale_go_go_executable = 'foobar' + AssertLinter 'foobar', ale#path#CdString(expand('%:p:h')) . ' foobar vet .' + +Execute(Go environment variables should be supported): + let b:ale_go_go111module = 'on' + + AssertLinter 'go', + \ ale#path#CdString(expand('%:p:h')) . ' ' + \ . ale#Env('GO111MODULE', 'on') + \ . 'go vet .' diff --git a/test/command_callback/test_ink_ls_command_callbacks.vader b/test/command_callback/test_ink_ls_command_callbacks.vader new file mode 100644 index 00000000..5074506c --- /dev/null +++ b/test/command_callback/test_ink_ls_command_callbacks.vader @@ -0,0 +1,22 @@ +Before: + call ale#assert#SetUpLinterTest('ink', 'ls') + set ft=ink + +After: + call ale#assert#TearDownLinterTest() + +Execute(should set correct defaults): + AssertLinter 'ink-language-server', ale#Escape('ink-language-server') . ' --stdio' + +Execute(should set correct LSP values): + call ale#test#SetFilename('ink_paths/story/main.ink') + + AssertLSPLanguage 'ink' + AssertLSPOptions {} + AssertLSPConfig {} + AssertLSPProject ale#path#Simplify(g:dir . '/ink_paths/story') + +Execute(should accept configuration settings): + AssertLSPConfig {} + let b:ale_ink_ls_initialization_options = {'ink': {'runThroughMono': v:true}} + AssertLSPOptions {'ink': {'runThroughMono': v:true}} diff --git a/test/command_callback/test_languagetool_command_callback.vader b/test/command_callback/test_languagetool_command_callback.vader index a79662b9..ff6b2064 100644 --- a/test/command_callback/test_languagetool_command_callback.vader +++ b/test/command_callback/test_languagetool_command_callback.vader @@ -12,4 +12,11 @@ Execute(Should be able to set a custom executable): let g:ale_languagetool_executable = 'foobar' AssertLinter 'foobar' , ale#Escape('foobar') - \ . ' --autoDetect %s' + \ . ' --autoDetect %s' + +Execute(Should be able to include custom languagetool options): + let g:ale_languagetool_options = '--language en' + + " is now 'foobar' based on above global + AssertLinter 'foobar', ale#Escape('foobar') + \ . ' --language en %s' diff --git a/test/command_callback/test_markdown_mdl_command_callback.vader b/test/command_callback/test_markdown_mdl_command_callback.vader index e029bf9b..1ce4db1a 100644 --- a/test/command_callback/test_markdown_mdl_command_callback.vader +++ b/test/command_callback/test_markdown_mdl_command_callback.vader @@ -5,15 +5,15 @@ After: call ale#assert#TearDownLinterTest() Execute(The default command should be correct): - AssertLinter 'mdl', ale#Escape('mdl') + AssertLinter 'mdl', ale#Escape('mdl') . ' -j' Execute(The executable and options should be configurable): let g:ale_markdown_mdl_executable = 'foo bar' let g:ale_markdown_mdl_options = '--wat' - AssertLinter 'foo bar', ale#Escape('foo bar') . ' --wat' + AssertLinter 'foo bar', ale#Escape('foo bar') . ' -j --wat' Execute(Setting bundle appends 'exec mdl'): let g:ale_markdown_mdl_executable = 'path to/bundle' - AssertLinter 'path to/bundle', ale#Escape('path to/bundle') . ' exec mdl' + AssertLinter 'path to/bundle', ale#Escape('path to/bundle') . ' exec mdl -j' diff --git a/test/command_callback/test_solc_command_callback.vader b/test/command_callback/test_solc_command_callback.vader new file mode 100644 index 00000000..23521f6a --- /dev/null +++ b/test/command_callback/test_solc_command_callback.vader @@ -0,0 +1,13 @@ +Before: + call ale#assert#SetUpLinterTest('solidity', 'solc') + +After: + call ale#assert#TearDownLinterTest() + +Execute(The default command should be correct): + AssertLinter 'solc', 'solc %s' + +Execute(The options should be configurable): + let g:ale_solidity_solc_options = '--foobar' + + AssertLinter 'solc', 'solc --foobar %s' diff --git a/test/command_callback/test_staticcheck_command_callback.vader b/test/command_callback/test_staticcheck_command_callback.vader index 7f17b146..ae0d3584 100644 --- a/test/command_callback/test_staticcheck_command_callback.vader +++ b/test/command_callback/test_staticcheck_command_callback.vader @@ -1,8 +1,12 @@ Before: + Save g:ale_go_go111module + call ale#assert#SetUpLinterTest('go', 'staticcheck') call ale#test#SetFilename('test.go') After: + unlet! b:ale_go_go111module + call ale#assert#TearDownLinterTest() Execute(The staticcheck callback should return the right defaults): @@ -24,3 +28,20 @@ Execute(The staticcheck `lint_package` option should use the correct command): AssertLinter 'staticcheck', \ ale#path#CdString(expand('%:p:h')) . 'staticcheck .', + +Execute(The staticcheck callback should use the `GO111MODULE` option if set): + let b:ale_go_go111module = 'off' + + AssertLinter 'staticcheck', + \ ale#path#CdString(expand('%:p:h')) + \ . ale#Env('GO111MODULE', 'off') + \ . 'staticcheck ' + \ . ale#Escape(expand('%' . ':t')) + + " Test with lint_package option set + let b:ale_go_staticcheck_lint_package = 1 + + AssertLinter 'staticcheck', + \ ale#path#CdString(expand('%:p:h')) + \ . ale#Env('GO111MODULE', 'off') + \ . 'staticcheck .' |