summaryrefslogtreecommitdiff
path: root/test/command_callback/test_gometalinter_command_callback.vader
blob: 93a541c8f9754583ad2c38d637978a5d46b3ec86 (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
53
54
55
56
57
58
59
60
61
Before:
  Save b:ale_go_gometalinter_executable
  Save b:ale_go_gometalinter_options
  Save b:ale_go_gometalinter_lint_package

  let b:ale_go_gometalinter_executable = 'gometalinter'
  let b:ale_go_gometalinter_options = ''
  let b:ale_go_gometalinter_lint_package = 0

  runtime ale_linters/go/gometalinter.vim

  call ale#test#SetDirectory('/testplugin/test/command_callback')
  call ale#test#SetFilename('test.go')

After:
  Restore

  call ale#test#RestoreDirectory()
  call ale#linter#Reset()

Execute(The gometalinter callback should return the right defaults):
  AssertEqual
  \ 'gometalinter',
  \ ale_linters#go#gometalinter#GetExecutable(bufnr(''))
  AssertEqual
  \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
  \   . ale#Escape('gometalinter')
  \   . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
  \   . ' .',
  \ ale_linters#go#gometalinter#GetCommand(bufnr(''))

Execute(The gometalinter callback should use a configured executable):
  let b:ale_go_gometalinter_executable = 'something else'

  AssertEqual
  \ 'something else',
  \ ale_linters#go#gometalinter#GetExecutable(bufnr(''))
  AssertEqual
  \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
  \   . ale#Escape('something else')
  \   . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
  \   . ' .', 
  \ ale_linters#go#gometalinter#GetCommand(bufnr(''))

Execute(The gometalinter callback should use configured options):
  let b:ale_go_gometalinter_options = '--foobar'

  AssertEqual
  \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
  \   . ale#Escape('gometalinter')
  \   . ' --include=' . ale#Escape(ale#util#EscapePCRE(expand('%' . ':t')))
  \   . ' --foobar' . ' .',
  \ ale_linters#go#gometalinter#GetCommand(bufnr(''))

Execute(The gometalinter `lint_package` option should use the correct command):
  let b:ale_go_gometalinter_lint_package = 1

  AssertEqual
  \ 'cd ' . ale#Escape(expand('%:p:h')) . ' && '
  \   . ale#Escape('gometalinter') . ' .',
  \ ale_linters#go#gometalinter#GetCommand(bufnr(''))