mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-15 16:57:06 +08:00
39
test/command_callback/test_llc_command_callback.vader
Normal file
39
test/command_callback/test_llc_command_callback.vader
Normal file
@@ -0,0 +1,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'
|
||||
56
test/handler/test_llc_handler.vader
Normal file
56
test/handler/test_llc_handler.vader
Normal file
@@ -0,0 +1,56 @@
|
||||
Before:
|
||||
runtime! ale_linters/llvm/llc.vim
|
||||
|
||||
Execute(llc handler should parse errors output for STDIN):
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 10,
|
||||
\ 'col': 7,
|
||||
\ 'text': "error: value doesn't match function result type 'i32'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 10,
|
||||
\ 'col': 13,
|
||||
\ 'text': "error: use of undefined value '@foo'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#llvm#llc#HandleErrors(bufnr(''), [
|
||||
\ "llc: <stdin>:10:7: error: value doesn't match function result type 'i32'",
|
||||
\ 'ret i64 0',
|
||||
\ ' ^',
|
||||
\ '',
|
||||
\ "llc: <stdin>:10:13: error: use of undefined value '@foo'",
|
||||
\ 'call void @foo(i64 %0)',
|
||||
\ ' ^',
|
||||
\ ])
|
||||
|
||||
Execute(llc handler should parse errors output for some file):
|
||||
call ale#test#SetFilename('test.ll')
|
||||
AssertEqual
|
||||
\ [
|
||||
\ {
|
||||
\ 'lnum': 10,
|
||||
\ 'col': 7,
|
||||
\ 'text': "error: value doesn't match function result type 'i32'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ {
|
||||
\ 'lnum': 10,
|
||||
\ 'col': 13,
|
||||
\ 'text': "error: use of undefined value '@foo'",
|
||||
\ 'type': 'E',
|
||||
\ },
|
||||
\ ],
|
||||
\ ale_linters#llvm#llc#HandleErrors(bufnr(''), [
|
||||
\ "llc: /path/to/test.ll:10:7: error: value doesn't match function result type 'i32'",
|
||||
\ 'ret i64 0',
|
||||
\ ' ^',
|
||||
\ '',
|
||||
\ "llc: /path/to/test.ll:10:13: error: use of undefined value '@foo'",
|
||||
\ 'call void @foo(i64 %0)',
|
||||
\ ' ^',
|
||||
\ ])
|
||||
|
||||
Reference in New Issue
Block a user