summaryrefslogtreecommitdiff
path: root/test/command_callback/test_llc_command_callback.vader
blob: 296b277ad1f0eacc01d2299ab4f02827e44bfbc5 (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
Before:
  Save g:ale_llvm_llc_executable

  unlet! g:ale_llvm_llc_executable
  unlet! b:ale_llvm_llc_executable

  runtime ale_linters/llvm/llc.vim

  function! AssertHasPrefix(str, prefix) abort
    let msg = printf("'%s' is expected to be prefixed with '%s'", a:str, a:prefix)
    AssertEqual stridx(a:str, a:prefix), 0, msg
  endfunction

After:
  unlet! g:ale_llvm_llc_executable
  unlet! b:ale_llvm_llc_executable
  delfunction AssertHasPrefix
  Restore

Execute(llc command is customizable):
  let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
  call AssertHasPrefix(cmd, ale#Escape('llc'))

  let g:ale_llvm_llc_executable = 'llc-5.0'
  let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
  call AssertHasPrefix(cmd, ale#Escape('llc-5.0'))

  let b:ale_llvm_llc_executable = 'llc-4.0'
  let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
  call AssertHasPrefix(cmd, ale#Escape('llc-4.0'))

Execute(GetCommand() escapes the returned path):
  let b:ale_llvm_llc_executable = '/path/space contained/llc'
  let cmd = ale_linters#llvm#llc#GetCommand(bufnr(''))
  call AssertHasPrefix(cmd, ale#Escape('/path/space contained/llc'))

Execute(GetExecutable() does not escape the returned path):
  let b:ale_llvm_llc_executable = '/path/space contained/llc'
  AssertEqual ale_linters#llvm#llc#GetExecutable(bufnr('')), '/path/space contained/llc'