2017-07-16 21:41:15 +00:00
|
|
|
Before:
|
2018-07-29 18:24:19 +00:00
|
|
|
Save g:ale_c_parse_makefile
|
2020-08-20 00:46:29 +00:00
|
|
|
Save g:ale_history_enabled
|
|
|
|
|
2018-07-29 18:24:19 +00:00
|
|
|
let g:ale_c_parse_makefile = 0
|
2020-08-20 00:46:29 +00:00
|
|
|
let g:ale_history_enabled = 0
|
2018-07-29 18:24:19 +00:00
|
|
|
|
2020-08-18 23:47:39 +00:00
|
|
|
let g:get_cflags_return_value = ''
|
2020-08-20 00:46:29 +00:00
|
|
|
let g:executable_map = {}
|
2020-08-18 23:47:39 +00:00
|
|
|
|
|
|
|
runtime autoload/ale/c.vim
|
2020-08-20 00:46:29 +00:00
|
|
|
runtime autoload/ale/engine.vim
|
|
|
|
|
|
|
|
function! ale#engine#IsExecutable(buffer, executable) abort
|
|
|
|
return has_key(g:executable_map, a:executable)
|
|
|
|
endfunction
|
2020-08-18 23:47:39 +00:00
|
|
|
|
|
|
|
function! ale#c#GetCFlags(buffer, output) abort
|
|
|
|
return g:get_cflags_return_value
|
|
|
|
endfunction
|
|
|
|
|
2020-08-20 00:46:29 +00:00
|
|
|
call ale#assert#SetUpLinterTest('cpp', 'cc')
|
|
|
|
|
2019-05-20 12:00:32 +00:00
|
|
|
let b:command_tail = ' -S -x c++'
|
|
|
|
\ . ' -o ' . (has('win32') ? 'nul': '/dev/null')
|
2020-08-28 18:50:36 +00:00
|
|
|
\ . ' -iquote %s:h'
|
2017-07-16 21:41:15 +00:00
|
|
|
\ . ' -std=c++14 -Wall -'
|
|
|
|
|
|
|
|
After:
|
2020-08-18 23:47:39 +00:00
|
|
|
unlet! g:get_cflags_return_value
|
2020-08-20 00:46:29 +00:00
|
|
|
unlet! g:executable_map
|
2017-07-16 21:41:15 +00:00
|
|
|
unlet! b:command_tail
|
2020-08-18 23:47:39 +00:00
|
|
|
|
|
|
|
runtime autoload/ale/c.vim
|
2020-08-20 00:46:29 +00:00
|
|
|
runtime autoload/ale/engine.vim
|
2020-08-18 23:47:39 +00:00
|
|
|
|
2018-07-15 17:24:53 +00:00
|
|
|
call ale#assert#TearDownLinterTest()
|
2017-07-16 21:41:15 +00:00
|
|
|
|
2020-08-20 00:46:29 +00:00
|
|
|
Execute(clang++ should be used instead of gcc, if available):
|
|
|
|
let g:executable_map = {'clang++': 1}
|
|
|
|
|
|
|
|
AssertLinter 'clang++', [ale#Escape('clang++') . b:command_tail]
|
|
|
|
|
2017-07-16 21:41:15 +00:00
|
|
|
Execute(The executable should be configurable):
|
2020-08-20 00:46:29 +00:00
|
|
|
AssertLinter 'gcc', [ale#Escape('gcc') . b:command_tail]
|
2017-07-16 21:41:15 +00:00
|
|
|
|
2020-08-20 00:46:29 +00:00
|
|
|
let b:ale_cpp_cc_executable = 'foobar'
|
2017-07-16 21:41:15 +00:00
|
|
|
|
2020-08-20 00:46:29 +00:00
|
|
|
AssertLinter 'foobar', [ale#Escape('foobar') . b:command_tail]
|
2020-08-18 23:47:39 +00:00
|
|
|
|
|
|
|
Execute(The -std flag should be replaced by parsed C flags):
|
|
|
|
let b:command_tail = substitute(b:command_tail, 'c++14', 'c++11 ', '')
|
|
|
|
let g:get_cflags_return_value = '-std=c++11'
|
|
|
|
|
|
|
|
AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
|
2022-09-25 00:02:43 +00:00
|
|
|
|
|
|
|
Execute(The header files should use -x c++-header):
|
|
|
|
let b:command_tail = substitute(b:command_tail, '-x c++', '-x c++-header', '')
|
|
|
|
|
|
|
|
call ale#test#SetFilename('../test-files/c/hpp_file_project/test.hpp')
|
|
|
|
|
|
|
|
AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
|
|
|
|
|
|
|
|
Execute(The header file extensions should be configurable):
|
|
|
|
let b:command_tail = substitute(b:command_tail, '-x c++', '-x c++-header', '')
|
|
|
|
|
|
|
|
call ale#assert#SetUpLinterTest('cpp', 'cc')
|
|
|
|
let b:ale_cpp_cc_header_exts = ['json']
|
|
|
|
call ale#test#SetFilename('../test-files/c/json_project/build/compile_commands.json')
|
|
|
|
|
|
|
|
AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
|