2018-03-20 10:56:46 +00:00
|
|
|
Before:
|
2018-03-20 20:49:31 +00:00
|
|
|
Save g:ale_c_parse_makefile
|
2018-03-20 10:56:46 +00:00
|
|
|
Save g:ale_c_gcc_options
|
|
|
|
Save g:ale_c_clang_options
|
|
|
|
Save g:ale_cpp_gcc_options
|
|
|
|
Save g:ale_cpp_clang_options
|
|
|
|
|
|
|
|
call ale#test#SetDirectory('/testplugin/test')
|
|
|
|
|
2018-03-20 20:49:31 +00:00
|
|
|
let g:ale_c_parse_makefile=1
|
2018-03-20 10:56:46 +00:00
|
|
|
let g:ale_c_gcc_options = ''
|
|
|
|
let g:ale_c_clang_options = ''
|
|
|
|
let g:ale_cpp_gcc_options = ''
|
|
|
|
let g:ale_cpp_clang_options = ''
|
|
|
|
|
|
|
|
After:
|
|
|
|
Restore
|
|
|
|
|
|
|
|
call ale#test#RestoreDirectory()
|
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
" Run this only once for this series of tests. The cleanup Execute step
|
|
|
|
" will run at the bottom of this file.
|
|
|
|
"
|
|
|
|
" We need to move .git/HEAD away so we don't match it, as we need to test
|
|
|
|
" functions which look for .git/HEAD.
|
|
|
|
Execute(Move .git/HEAD to a temp dir):
|
|
|
|
let g:temp_head_filename = tempname()
|
|
|
|
let g:head_filename = findfile('.git/HEAD', ';')
|
|
|
|
|
|
|
|
if !empty(g:head_filename)
|
|
|
|
call writefile(readfile(g:head_filename, 'b'), g:temp_head_filename, 'b')
|
|
|
|
call delete(g:head_filename)
|
|
|
|
endif
|
|
|
|
|
2018-03-20 20:49:31 +00:00
|
|
|
Execute(The CFlags parser should be able to parse include directives):
|
2018-03-20 10:56:46 +00:00
|
|
|
runtime! ale_linters/c/gcc.vim
|
|
|
|
|
|
|
|
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
|
|
|
|
|
|
|
|
AssertEqual
|
2018-03-20 20:49:31 +00:00
|
|
|
\ ['-I/testplugin/test/test_c_projects/makefile_project/subdir']
|
|
|
|
\ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -c file.c')
|
2018-03-20 10:56:46 +00:00
|
|
|
|
2018-03-20 20:49:31 +00:00
|
|
|
Execute(The CFlags parser should be able to parse macro directives):
|
|
|
|
runtime! ale_linters/c/gcc.vim
|
|
|
|
|
|
|
|
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ ['-I/testplugin/test/test_c_projects/makefile_project/subdir',
|
|
|
|
\ '-DTEST=1']
|
|
|
|
\ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=1 -c file.c')
|
|
|
|
|
|
|
|
Execute(The CFlags parser should be able to parse macro directives with spaces):
|
|
|
|
runtime! ale_linters/c/gcc.vim
|
2018-03-20 10:56:46 +00:00
|
|
|
|
|
|
|
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
|
|
|
|
|
|
|
|
AssertEqual
|
2018-03-20 20:49:31 +00:00
|
|
|
\ ['-I/testplugin/test/test_c_projects/makefile_project/subdir',
|
|
|
|
\ '-DTEST=$(( 2 * 4 ))']
|
|
|
|
\ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=$(( 2 * 4 )) -c file.c')
|
|
|
|
|
|
|
|
Execute(The CFlags parser should be able to parse shell directives with spaces):
|
|
|
|
runtime! ale_linters/c/gcc.vim
|
2018-03-20 10:56:46 +00:00
|
|
|
|
2018-03-20 20:49:31 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ ['-I/testplugin/test/test_c_projects/makefile_project/subdir',
|
|
|
|
\ '-DTEST=`date +%s`']
|
|
|
|
\ , ale#c#ParseCFlags(bufnr(''), 'gcc -Isubdir -DTEST=`date +%s` -c file.c')
|
2018-03-20 10:56:46 +00:00
|
|
|
|
|
|
|
Execute(Move .git/HEAD back):
|
|
|
|
if !empty(g:head_filename)
|
|
|
|
call writefile(readfile(g:temp_head_filename, 'b'), g:head_filename, 'b')
|
|
|
|
call delete(g:temp_head_filename)
|
|
|
|
endif
|
|
|
|
|
|
|
|
unlet! g:temp_head_filename
|
|
|
|
unlet! g:head_filename
|