diff options
author | w0rp <devw0rp@gmail.com> | 2018-02-04 13:55:09 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-02-04 13:55:09 +0000 |
commit | 33b3331b0499e502f01730af60fb0e9b5a30951f (patch) | |
tree | 5d0ee32e8e8fa4b4712ccd54a8bf500a16481701 /test/command_callback/test_gobuild_command_callback.vader | |
parent | 0f822b063cb9553c9e00bc63d0184ba8577e6248 (diff) | |
download | ale-33b3331b0499e502f01730af60fb0e9b5a30951f.zip |
#1206 Add support for setting options for gobuild, and escape paths better
Diffstat (limited to 'test/command_callback/test_gobuild_command_callback.vader')
-rw-r--r-- | test/command_callback/test_gobuild_command_callback.vader | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/command_callback/test_gobuild_command_callback.vader b/test/command_callback/test_gobuild_command_callback.vader new file mode 100644 index 00000000..240f29c6 --- /dev/null +++ b/test/command_callback/test_gobuild_command_callback.vader @@ -0,0 +1,52 @@ +Before: + Save g:ale_go_gobuild_options + + unlet! g:ale_go_gobuild_options + + let g:env_prefix = has('win32') + \ ? 'set GOPATH=' . ale#Escape('/foo/bar') . ' && ' + \ : 'GOPATH=' . ale#Escape('/foo/bar') . ' ' + + runtime ale_linters/go/gobuild.vim + + call ale#test#SetDirectory('/testplugin/test/command_callback') + + call ale_linters#go#gobuild#ResetEnv() + +After: + Restore + + unlet! g:env_prefix + + call ale#linter#Reset() + call ale#test#RestoreDirectory() + +Execute(The default gobuild command should be correct): + AssertEqual + \ ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz']), + \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ . 'go test -c -o /dev/null ./' + +Execute(The command for getting GOPATH should be correct): + AssertEqual ale_linters#go#gobuild#GoEnv(bufnr('')), 'go env GOPATH GOROOT' + + call ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz']) + + " We shouldn't run `go env` many times after we've got it. + AssertEqual ale_linters#go#gobuild#GoEnv(bufnr('')), '' + +Execute(The GOPATH output should be used after it has been read once): + call ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz']) + + AssertEqual + \ ale_linters#go#gobuild#GetCommand(bufnr(''), []), + \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ . 'go test -c -o /dev/null ./' + +Execute(Extra options should be supported): + let g:ale_go_gobuild_options = '--foo-bar' + + AssertEqual + \ ale_linters#go#gobuild#GetCommand(bufnr(''), ['/foo/bar', '/foo/baz']), + \ g:env_prefix . 'cd ' . ale#Escape(expand('%:p:h')) . ' && ' + \ . 'go test --foo-bar -c -o /dev/null ./' |