diff options
Diffstat (limited to 'test')
22 files changed, 110 insertions, 85 deletions
diff --git a/test/command_callback/test_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader index fdf23866..063f3f2f 100644 --- a/test/command_callback/test_gobuild_command_callback.vader +++ b/test/command_callback/test_gobuild_command_callback.vader @@ -11,14 +11,14 @@ After: Execute(The default commands should be correct): AssertLinter 'go', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . '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#path#BufferCdString(bufnr('')) \ . ale#Env('GO111MODULE', 'on') \ . 'go test -c -o /dev/null ./' @@ -28,7 +28,7 @@ Execute(Extra options should be supported): let g:ale_go_gobuild_options = '--foo-bar' AssertLinter 'go', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . 'go test --foo-bar -c -o /dev/null ./' let g:ale_go_gobuild_options = '' @@ -37,5 +37,5 @@ Execute(The executable should be configurable): let g:ale_go_go_executable = 'foobar' AssertLinter 'foobar', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . 'foobar test -c -o /dev/null ./' diff --git a/test/command_callback/test_gofmt_command_callback.vader b/test/command_callback/test_gofmt_command_callback.vader index 4da1f6c8..88b2e6b0 100644 --- a/test/command_callback/test_gofmt_command_callback.vader +++ b/test/command_callback/test_gofmt_command_callback.vader @@ -1,5 +1,8 @@ Before: Save g:ale_go_go111module + Save b:ale_go_go111module + + let b:ale_go_go111module = '' call ale#assert#SetUpLinterTest('go', 'gofmt') call ale#test#SetFilename('../go_files/testfile2.go') diff --git a/test/command_callback/test_golangci_lint_command_callback.vader b/test/command_callback/test_golangci_lint_command_callback.vader index 7f1e2ac4..37fb1f7d 100644 --- a/test/command_callback/test_golangci_lint_command_callback.vader +++ b/test/command_callback/test_golangci_lint_command_callback.vader @@ -13,7 +13,7 @@ After: Execute(The golangci-lint defaults should be correct): AssertLinter 'golangci-lint', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('golangci-lint') \ . ' run ' . ale#Escape(expand('%' . ':t')) \ . ' --enable-all' @@ -22,7 +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#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('something else') \ . ' run ' . ale#Escape(expand('%' . ':t')) \ . ' --enable-all' @@ -31,7 +31,7 @@ Execute(The golangci-lint callback should use configured options): let b:ale_go_golangci_lint_options = '--foobar' AssertLinter 'golangci-lint', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('golangci-lint') \ . ' run ' . ale#Escape(expand('%' . ':t')) \ . ' --foobar' @@ -40,7 +40,7 @@ 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#path#BufferCdString(bufnr('')) \ . ale#Env('GO111MODULE', 'on') \ . ale#Escape('golangci-lint') \ . ' run ' . ale#Escape(expand('%' . ':t')) @@ -50,5 +50,5 @@ 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#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('golangci-lint') . ' run --enable-all' diff --git a/test/command_callback/test_gometalinter_command_callback.vader b/test/command_callback/test_gometalinter_command_callback.vader index d922efc6..567997d8 100644 --- a/test/command_callback/test_gometalinter_command_callback.vader +++ b/test/command_callback/test_gometalinter_command_callback.vader @@ -13,7 +13,7 @@ After: Execute(The gometalinter defaults should be correct): AssertLinter 'gometalinter', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('gometalinter') \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' .' @@ -22,7 +22,7 @@ Execute(The gometalinter callback should use a configured executable): let b:ale_go_gometalinter_executable = 'something else' AssertLinter 'something else', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('something else') \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' .' @@ -31,7 +31,7 @@ Execute(The gometalinter callback should use configured options): let b:ale_go_gometalinter_options = '--foobar' AssertLinter 'gometalinter', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('gometalinter') \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) \ . ' --foobar' . ' .' @@ -40,7 +40,7 @@ Execute(The gometalinter should use configured environment variables): let b:ale_go_go111module = 'off' AssertLinter 'gometalinter', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Env('GO111MODULE', 'off') \ . ale#Escape('gometalinter') \ . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t'))) @@ -50,5 +50,5 @@ Execute(The gometalinter `lint_package` option should use the correct command): let b:ale_go_gometalinter_lint_package = 1 AssertLinter 'gometalinter', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('gometalinter') . ' .' diff --git a/test/command_callback/test_gosimple_command_callback.vader b/test/command_callback/test_gosimple_command_callback.vader index ee89eed8..b006f783 100644 --- a/test/command_callback/test_gosimple_command_callback.vader +++ b/test/command_callback/test_gosimple_command_callback.vader @@ -11,11 +11,12 @@ After: Execute(The default gosimple command should be correct): AssertLinter 'gosimple', - \ ale#path#CdString(expand('%:p:h')) . ' gosimple .' + \ ale#path#BufferCdString(bufnr('')) + \ . ' 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 .' + \ ale#path#BufferCdString(bufnr('')) + \ . ' ' . 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 1334fcff..204197d9 100644 --- a/test/command_callback/test_gotype_command_callback.vader +++ b/test/command_callback/test_gotype_command_callback.vader @@ -11,7 +11,8 @@ After: Execute(The default gotype command should be correct): AssertLinter 'gotype', - \ ale#path#CdString(expand('%:p:h')) . ' gotype -e .' + \ ale#path#BufferCdString(bufnr('')) + \ . ' gotype -e .' Execute(The gotype callback should ignore test files): call ale#test#SetFilename('bla_test.go') @@ -22,6 +23,6 @@ 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') + \ ale#path#BufferCdString(bufnr('')) + \ . ' ' . 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 59022180..0e1ea092 100644 --- a/test/command_callback/test_govet_command_callback.vader +++ b/test/command_callback/test_govet_command_callback.vader @@ -13,22 +13,22 @@ After: call ale#assert#TearDownLinterTest() Execute(The default command should be correct): - AssertLinter 'go', ale#path#CdString(expand('%:p:h')) . ' go vet .' + AssertLinter 'go', ale#path#BufferCdString(bufnr('')) . ' go vet .' 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 .' + AssertLinter 'go', ale#path#BufferCdString(bufnr('')) . ' 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 .' + AssertLinter 'foobar', ale#path#BufferCdString(bufnr('')) . ' foobar vet .' Execute(Go environment variables should be supported): let b:ale_go_go111module = 'on' AssertLinter 'go', - \ ale#path#CdString(expand('%:p:h')) . ' ' + \ ale#path#BufferCdString(bufnr('')) . ' ' \ . ale#Env('GO111MODULE', 'on') \ . 'go vet .' diff --git a/test/command_callback/test_graphql_gqlint_command_callbacks.vader b/test/command_callback/test_graphql_gqlint_command_callbacks.vader index 0f4e9770..e8ed0e5d 100644 --- a/test/command_callback/test_graphql_gqlint_command_callbacks.vader +++ b/test/command_callback/test_graphql_gqlint_command_callbacks.vader @@ -6,6 +6,6 @@ After: Execute(The linter should run from the directory of the file in the buffer): AssertLinter 'gqlint', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . 'gqlint --reporter=simple' \ . ' %t' diff --git a/test/command_callback/test_javac_command_callback.vader b/test/command_callback/test_javac_command_callback.vader index d2eebf7a..ac898e5f 100644 --- a/test/command_callback/test_javac_command_callback.vader +++ b/test/command_callback/test_javac_command_callback.vader @@ -3,7 +3,7 @@ Before: call ale#test#SetFilename('dummy.java') let g:cp_sep = has('unix') ? ':' : ';' - let g:prefix = ale#path#CdString(expand('%:p:h')) + let g:prefix = ale#path#BufferCdString(bufnr('')) \ . ale#Escape('javac') . ' -Xlint' function! GetCommand(previous_output) abort @@ -51,7 +51,7 @@ Execute(The executable should be configurable): let g:ale_java_javac_executable = 'foobar' AssertLinter 'foobar', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('foobar') . ' -Xlint' \ . ' -d ' . ale#Escape('TEMP_DIR') . ' %t' @@ -197,7 +197,8 @@ Execute(The javac callback should combine discovered sourcepath and manual ones) let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [], {}) AssertEqual - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . 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/'), @@ -210,7 +211,8 @@ Execute(The javac callback should combine discovered sourcepath and manual ones) let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [], {}) AssertEqual - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . 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/'), @@ -223,7 +225,8 @@ Execute(The javac callback should combine discovered sourcepath and manual ones) let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [], {}) AssertEqual - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . 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/') @@ -238,7 +241,8 @@ Execute(The javac callback should combine discovered sourcepath and manual ones) let b:command = ale_linters#java#javac#GetCommand(bufnr(''), [], {}) AssertEqual - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . 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/'), @@ -253,7 +257,8 @@ Execute(The javac callback should detect source directories): call ale#engine#InitBufferInfo(bufnr('')) AssertLinter 'javac', - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('javac') . ' -Xlint' \ . ' -sourcepath ' . ale#Escape( \ ale#path#Simplify(g:dir . '/java_paths/src/main/java/') \ ) @@ -272,7 +277,8 @@ Execute(The javac callback should combine detected source directories and classp \], {}) AssertEqual - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . 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/') @@ -294,7 +300,8 @@ Execute(The javac callback should include src/test/java for test paths): call ale#engine#InitBufferInfo(bufnr('')) AssertLinter 'javac', - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . 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/'), @@ -307,7 +314,8 @@ Execute(The javac callback should include src/main/jaxb when available): call ale#engine#InitBufferInfo(bufnr('')) AssertLinter 'javac', - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . 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/'), @@ -320,7 +328,8 @@ Execute(The javac callback should add -sourcepath even if src/java/main doesn't call ale#engine#InitBufferInfo(bufnr('')) AssertLinter 'javac', - \ ale#path#CdString(expand('%:p:h')) . ale#Escape('javac') . ' -Xlint' + \ ale#path#BufferCdString(bufnr('')) + \ . ale#Escape('javac') . ' -Xlint' \ . ' -sourcepath ' . ale#Escape(join([ \ ale#path#Simplify(g:dir . '/java_paths_no_main/src/test/java/'), \ ], g:cp_sep)) diff --git a/test/command_callback/test_lintr_command_callback.vader b/test/command_callback/test_lintr_command_callback.vader index 187d3875..ac4b419b 100644 --- a/test/command_callback/test_lintr_command_callback.vader +++ b/test/command_callback/test_lintr_command_callback.vader @@ -6,7 +6,7 @@ After: Execute(The default lintr command should be correct): AssertLinter 'Rscript', - \ ale#path#CdString(getcwd()) + \ ale#path#BufferCdString(bufnr('')) \ . 'Rscript --vanilla -e ' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . 'lint(cache = FALSE, commandArgs(TRUE), ' @@ -17,7 +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#CdString(getcwd()) + \ ale#path#BufferCdString(bufnr('')) \ . 'Rscript --vanilla -e ' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . 'lint(cache = FALSE, commandArgs(TRUE), ' @@ -28,7 +28,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#CdString(getcwd()) + \ ale#path#BufferCdString(bufnr('')) \ . 'Rscript --vanilla -e ' \ . ale#Escape('suppressPackageStartupMessages(library(lintr));' \ . 'lint_package(cache = FALSE, ' diff --git a/test/command_callback/test_mypy_command_callback.vader b/test/command_callback/test_mypy_command_callback.vader index afa9f9af..b9b6ae70 100644 --- a/test/command_callback/test_mypy_command_callback.vader +++ b/test/command_callback/test_mypy_command_callback.vader @@ -75,14 +75,14 @@ Execute(Setting executable to 'pipenv' appends 'run mypy'): let g:ale_python_mypy_executable = 'path/to/pipenv' AssertLinter 'path/to/pipenv', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . 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('/testplugin/test/python_fixtures/pipenv/whatever.py') + call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py') AssertLinter 'pipenv', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('pipenv') . ' run mypy --show-column-numbers --shadow-file %s %t %s' diff --git a/test/command_callback/test_pydocstyle_command_callback.vader b/test/command_callback/test_pydocstyle_command_callback.vader index 7e0df9ca..02177f36 100644 --- a/test/command_callback/test_pydocstyle_command_callback.vader +++ b/test/command_callback/test_pydocstyle_command_callback.vader @@ -1,39 +1,40 @@ Before: call ale#assert#SetUpLinterTest('python', 'pydocstyle') + call ale#test#SetFilename('test.py') After: call ale#assert#TearDownLinterTest() Execute(The pydocstyle command callback should return default string): AssertLinter 'pydocstyle', - \ ale#path#BufferCdString(bufnr('')) - \ . ale#Escape('pydocstyle') . ' ' . ale#Escape('dummy.txt') + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) + \ . ale#Escape('pydocstyle') . ' ' . ale#Escape('test.py') 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 ' . ale#Escape('dummy.txt') + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) + \ . ale#Escape('pydocstyle') . ' --verbose ' . ale#Escape('test.py') 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') . ' ' . ale#Escape('dummy.txt') + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) + \ . ale#Escape('~/.local/bin/pydocstyle') . ' ' . ale#Escape('test.py') 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 ' . ale#Escape('dummy.txt') + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) + \ . ale#Escape('path/to/pipenv') . ' run pydocstyle ' . ale#Escape('test.py') Execute(Pipenv is detected when python_pydocstyle_auto_pipenv is set): let g:ale_python_pydocstyle_auto_pipenv = 1 - call ale#test#SetFilename('/testplugin/test/python_fixtures/pipenv/whatever.py') + call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py') AssertLinter 'pipenv', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('pipenv') . ' run pydocstyle ' . ale#Escape('whatever.py') diff --git a/test/command_callback/test_pylama_command_callback.vader b/test/command_callback/test_pylama_command_callback.vader index 417cb5c9..0aea9a93 100644 --- a/test/command_callback/test_pylama_command_callback.vader +++ b/test/command_callback/test_pylama_command_callback.vader @@ -14,7 +14,7 @@ After: Execute(The pylama command callback should return a default): AssertLinter 'pylama', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('pylama') . b:command_tail Execute(The option for disabling changing directories should work): @@ -26,14 +26,14 @@ Execute(The pylama executable should be configurable, and escaped properly): let g:ale_python_pylama_executable = 'executable with spaces' AssertLinter 'executable with spaces', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . 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#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('pylama') . ' --some-option' . b:command_tail Execute(The pylama command callback should switch directories to the detected project root): @@ -73,13 +73,13 @@ Execute(Setting executable to 'pipenv' appends 'run pylama'): let g:ale_python_pylama_executable = 'path/to/pipenv' AssertLinter 'path/to/pipenv', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . 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('/testplugin/test/python_fixtures/pipenv/whatever.py') + call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py') AssertLinter 'pipenv', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('pipenv') . ' run pylama' . b:command_tail diff --git a/test/command_callback/test_pylint_command_callback.vader b/test/command_callback/test_pylint_command_callback.vader index c41c8398..755dd292 100644 --- a/test/command_callback/test_pylint_command_callback.vader +++ b/test/command_callback/test_pylint_command_callback.vader @@ -1,4 +1,8 @@ Before: + Save g:ale_python_auto_pipenv + + let g:ale_python_auto_pipenv = 0 + call ale#assert#SetUpLinterTest('python', 'pylint') let b:bin_dir = has('win32') ? 'Scripts' : 'bin' @@ -13,7 +17,7 @@ After: Execute(The pylint callbacks should return the correct default values): AssertLinter 'pylint', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('pylint') . ' ' . b:command_tail Execute(The option for disabling changing directories should work): @@ -25,14 +29,14 @@ 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#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . 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#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('pylint') . ' --some-option' . b:command_tail Execute(The pylint callbacks shouldn't detect virtualenv directories where they don't exist): @@ -65,15 +69,15 @@ Execute(Setting executable to 'pipenv' appends 'run pylint'): let g:ale_python_pylint_executable = 'path/to/pipenv' AssertLinter 'path/to/pipenv', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . 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('/testplugin/test/python_fixtures/pipenv/whatever.py') + call ale#test#SetFilename('../python_fixtures/pipenv/whatever.py') AssertLinter 'pipenv', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('pipenv') . ' run pylint' \ . ' --output-format text --msg-template="{path}:{line}:{column}: {msg_id} ({symbol}) {msg}" --reports n %s' diff --git a/test/command_callback/test_shellcheck_command_callback.vader b/test/command_callback/test_shellcheck_command_callback.vader index 1d5b056b..9fb5303a 100644 --- a/test/command_callback/test_shellcheck_command_callback.vader +++ b/test/command_callback/test_shellcheck_command_callback.vader @@ -2,7 +2,7 @@ Before: call ale#assert#SetUpLinterTest('sh', 'shellcheck') call ale#test#SetFilename('test.sh') - let b:prefix = ale#path#CdString(ale#path#Simplify(g:dir)) + let b:prefix = ale#path#BufferCdString(bufnr('')) let b:suffix = ' -f gcc -' After: diff --git a/test/command_callback/test_staticcheck_command_callback.vader b/test/command_callback/test_staticcheck_command_callback.vader index ae0d3584..871a5510 100644 --- a/test/command_callback/test_staticcheck_command_callback.vader +++ b/test/command_callback/test_staticcheck_command_callback.vader @@ -11,7 +11,7 @@ After: Execute(The staticcheck callback should return the right defaults): AssertLinter 'staticcheck', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . 'staticcheck ' \ . ale#Escape(expand('%' . ':t')) @@ -19,7 +19,7 @@ Execute(The staticcheck callback should use configured options): let b:ale_go_staticcheck_options = '-test' AssertLinter 'staticcheck', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . 'staticcheck ' \ . '-test ' . ale#Escape(expand('%' . ':t')) @@ -27,13 +27,14 @@ Execute(The staticcheck `lint_package` option should use the correct command): let b:ale_go_staticcheck_lint_package = 1 AssertLinter 'staticcheck', - \ ale#path#CdString(expand('%:p:h')) . 'staticcheck .', + \ ale#path#BufferCdString(bufnr('')) + \ . '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#path#BufferCdString(bufnr('')) \ . ale#Env('GO111MODULE', 'off') \ . 'staticcheck ' \ . ale#Escape(expand('%' . ':t')) @@ -42,6 +43,6 @@ Execute(The staticcheck callback should use the `GO111MODULE` option if set): let b:ale_go_staticcheck_lint_package = 1 AssertLinter 'staticcheck', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Env('GO111MODULE', 'off') \ . 'staticcheck .' diff --git a/test/command_callback/test_tslint_command_callback.vader b/test/command_callback/test_tslint_command_callback.vader index 229ccc96..cc5d2666 100644 --- a/test/command_callback/test_tslint_command_callback.vader +++ b/test/command_callback/test_tslint_command_callback.vader @@ -7,14 +7,14 @@ After: Execute(The default tslint command should be correct): AssertLinter 'tslint', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . 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#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('tslint') . ' --format json' \ . ' -r ' . ale#Escape('/foo/bar') \ . ' %t' @@ -23,5 +23,5 @@ Execute(The executable should be configurable and escaped): let b:ale_typescript_tslint_executable = 'foo bar' AssertLinter 'foo bar', - \ ale#path#CdString(expand('%:p:h')) + \ ale#path#BufferCdString(bufnr('')) \ . ale#Escape('foo bar') . ' --format json %t' diff --git a/test/command_callback/test_vulture_command_callback.vader b/test/command_callback/test_vulture_command_callback.vader index d6c866b9..bacf8f12 100644 --- a/test/command_callback/test_vulture_command_callback.vader +++ b/test/command_callback/test_vulture_command_callback.vader @@ -12,7 +12,7 @@ After: Execute(The vulture command callback should lint file directory by default): AssertLinter 'vulture', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('vulture') . ' .' Execute(The vulture command callback should lint project root, when present): @@ -31,14 +31,14 @@ 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#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . 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#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('vulture') . ' --some-option .' Execute(The vulture command callback should detect virtualenv directories and switch to the project root): @@ -64,5 +64,5 @@ Execute(Setting executable to 'pipenv' appends 'run vulture'): let g:ale_python_vulture_executable = 'path/to/pipenv' AssertLinter 'path/to/pipenv', - \ ale#path#BufferCdString(bufnr('')) + \ ale#path#CdString(expand('#' . bufnr('') . ':p:h')) \ . ale#Escape('path/to/pipenv') . ' run vulture' . ' .' 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_prettier_eslint_fixer.callback.vader b/test/fixers/test_prettier_eslint_fixer.callback.vader index f7bb3c61..be8f04e3 100644 --- a/test/fixers/test_prettier_eslint_fixer.callback.vader +++ b/test/fixers/test_prettier_eslint_fixer.callback.vader @@ -73,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', @@ -83,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', \ } @@ -91,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_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' diff --git a/test/util/test_cd_string_commands.vader b/test/util/test_cd_string_commands.vader index f2102e48..85c5065f 100644 --- a/test/util/test_cd_string_commands.vader +++ b/test/util/test_cd_string_commands.vader @@ -16,5 +16,5 @@ Execute(BufferCdString should output the correct command string): call ale#test#SetFilename('foo.txt') AssertEqual - \ has('unix') ? 'cd ' . ale#Escape(g:dir) . ' && ' : 'cd /d ' . ale#Escape(g:dir) . ' && ', + \ has('unix') ? 'cd %s:h && ' : 'cd /d %s:h && ', \ ale#path#BufferCdString(bufnr('')) |