summaryrefslogtreecommitdiff
path: root/test/command_callback/test_gobuild_command_callback.vader
blob: 240f29c63be1cf0bce2bdbe5cec3e9c7aeb01033 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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 ./'