summaryrefslogtreecommitdiff
path: root/test/command_callback/test_cpp_clangcheck_command_callbacks.vader
blob: f708c52d5758dfc8f01f5f6b9e06d68582c769a1 (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
62
63
Before:
  Save g:ale_cpp_clangcheck_executable
  Save g:ale_cpp_clangcheck_options

  unlet! g:ale_cpp_clangcheck_executable
  unlet! b:ale_cpp_clangcheck_executable
  unlet! g:ale_cpp_clangcheck_options
  unlet! b:ale_cpp_clangcheck_options

  runtime ale_linters/cpp/clangcheck.vim

After:
  Restore
  unlet! b:command_tail
  unlet! b:ale_cpp_clangcheck_executable
  unlet! b:ale_cpp_clangcheck_options
  unlet! b:ale_c_build_dir
  call ale#linter#Reset()

Execute(The executable should be configurable):
  AssertEqual 'clang-check', ale_linters#cpp#clangcheck#GetExecutable(bufnr(''))

  let b:ale_cpp_clangcheck_executable = 'foobar'

  AssertEqual 'foobar', ale_linters#cpp#clangcheck#GetExecutable(bufnr(''))

Execute(The executable should be used in the command):
  AssertEqual
  \ ale#Escape('clang-check')
  \   . ' -analyze %s'
  \   . ' -extra-arg -Xclang -extra-arg -analyzer-output=text',
  \ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))

  let b:ale_cpp_clangcheck_executable = 'foobar'

  " The extra arguments in the command are used to prevent .plist files from
  " being generated.
  AssertEqual
  \ ale#Escape('foobar')
  \   . ' -analyze %s'
  \   . ' -extra-arg -Xclang -extra-arg -analyzer-output=text',
  \ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))

Execute(The options should be configurable):
  let b:ale_cpp_clangcheck_options = '--something'

  AssertEqual
  \ ale#Escape('clang-check')
  \   . ' -analyze %s'
  \   . ' -extra-arg -Xclang -extra-arg -analyzer-output=text'
  \   . ' --something',
  \ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))

Execute(The build directory should be used when set):
  let b:ale_cpp_clangcheck_options = '--something'
  let b:ale_c_build_dir = '/foo/bar'

  AssertEqual
  \ ale#Escape('clang-check')
  \   . ' -analyze %s '
  \   . '--something -p '
  \   . ale#Escape('/foo/bar'),
  \ ale_linters#cpp#clangcheck#GetCommand(bufnr(''))