2017-05-31 19:01:40 +00:00
|
|
|
Before:
|
|
|
|
Save g:ale_c_gcc_options
|
|
|
|
Save g:ale_c_clang_options
|
|
|
|
Save g:ale_cpp_gcc_options
|
|
|
|
Save g:ale_cpp_clang_options
|
|
|
|
|
2017-07-09 21:43:25 +00:00
|
|
|
call ale#test#SetDirectory('/testplugin/test')
|
2017-05-31 19:01:40 +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
|
|
|
|
|
2017-07-09 21:43:25 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
2017-05-31 19:01:40 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
" 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
|
|
|
|
|
2017-05-31 19:01:40 +00:00
|
|
|
Execute(The C GCC handler should include 'include' directories for projects with a Makefile):
|
|
|
|
runtime! ale_linters/c/gcc.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 21:41:15 +00:00
|
|
|
\ ale#Escape('gcc')
|
|
|
|
\ . ' -S -x c -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
2018-03-20 20:49:31 +00:00
|
|
|
\ , ale_linters#c#gcc#GetCommand(bufnr(''), [])
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
Execute(The C GCC handler should include 'include' directories for projects with a configure file):
|
|
|
|
runtime! ale_linters/c/gcc.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.c')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 21:41:15 +00:00
|
|
|
\ ale#Escape('gcc')
|
|
|
|
\ . ' -S -x c -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
2018-03-20 20:49:31 +00:00
|
|
|
\ , ale_linters#c#gcc#GetCommand(bufnr(''), [])
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
Execute(The C GCC handler should include root directories for projects with .h files in them):
|
|
|
|
runtime! ale_linters/c/gcc.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 21:41:15 +00:00
|
|
|
\ ale#Escape('gcc')
|
|
|
|
\ . ' -S -x c -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
2018-03-20 20:49:31 +00:00
|
|
|
\ , ale_linters#c#gcc#GetCommand(bufnr(''), [])
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
Execute(The C GCC handler should include root directories for projects with .hpp files in them):
|
|
|
|
runtime! ale_linters/c/gcc.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.c')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 21:41:15 +00:00
|
|
|
\ ale#Escape('gcc')
|
|
|
|
\ . ' -S -x c -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
2018-03-20 20:49:31 +00:00
|
|
|
\ , ale_linters#c#gcc#GetCommand(bufnr(''), [])
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
Execute(The C Clang handler should include 'include' directories for projects with a Makefile):
|
|
|
|
runtime! ale_linters/c/clang.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang')
|
|
|
|
\ . ' -S -x c -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
2018-03-20 20:49:31 +00:00
|
|
|
\ , ale_linters#c#clang#GetCommand(bufnr(''), [])
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
Execute(The C Clang handler should include 'include' directories for projects with a configure file):
|
|
|
|
runtime! ale_linters/c/clang.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang')
|
|
|
|
\ . ' -S -x c -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
2018-03-20 20:49:31 +00:00
|
|
|
\ , ale_linters#c#clang#GetCommand(bufnr(''), [])
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
Execute(The C Clang handler should include root directories for projects with .h files in them):
|
|
|
|
runtime! ale_linters/c/clang.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.c')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang')
|
|
|
|
\ . ' -S -x c -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
2018-03-20 20:49:31 +00:00
|
|
|
\ , ale_linters#c#clang#GetCommand(bufnr(''), [])
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
Execute(The C Clang handler should include root directories for projects with .hpp files in them):
|
|
|
|
runtime! ale_linters/c/clang.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.c')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang')
|
|
|
|
\ . ' -S -x c -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
2018-03-20 20:49:31 +00:00
|
|
|
\ , ale_linters#c#clang#GetCommand(bufnr(''), [])
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
Execute(The C++ GCC handler should include 'include' directories for projects with a Makefile):
|
|
|
|
runtime! ale_linters/cpp/gcc.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.cpp')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 21:41:15 +00:00
|
|
|
\ ale#Escape('gcc')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The C++ GCC handler should include 'include' directories for projects with a configure file):
|
|
|
|
runtime! ale_linters/cpp/gcc.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.cpp')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 21:41:15 +00:00
|
|
|
\ ale#Escape('gcc')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The C++ GCC handler should include root directories for projects with .h files in them):
|
|
|
|
runtime! ale_linters/cpp/gcc.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.cpp')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 21:41:15 +00:00
|
|
|
\ ale#Escape('gcc')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The C++ GCC handler should include root directories for projects with .hpp files in them):
|
|
|
|
runtime! ale_linters/cpp/gcc.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.cpp')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 21:41:15 +00:00
|
|
|
\ ale#Escape('gcc')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The C++ Clang handler should include 'include' directories for projects with a Makefile):
|
|
|
|
runtime! ale_linters/cpp/clang.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.cpp')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang++')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/makefile_project/include')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The C++ Clang handler should include 'include' directories for projects with a configure file):
|
|
|
|
runtime! ale_linters/cpp/clang.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/configure_project/subdir/file.cpp')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang++')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/configure_project/include')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The C++ Clang handler should include root directories for projects with .h files in them):
|
|
|
|
runtime! ale_linters/cpp/clang.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/h_file_project/subdir/file.cpp')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang++')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/h_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The C++ Clang handler should include root directories for projects with .hpp files in them):
|
|
|
|
runtime! ale_linters/cpp/clang.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/hpp_file_project/subdir/file.cpp')
|
2017-05-31 19:01:40 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang++')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
|
2017-05-31 19:01:40 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
|
2017-06-24 11:38:16 +00:00
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
Execute(The C++ Clang handler shoud use the include directory based on the .git location):
|
|
|
|
runtime! ale_linters/cpp/clang.vim
|
|
|
|
|
|
|
|
if !isdirectory(g:dir . '/test_c_projects/git_and_nested_makefiles/.git')
|
|
|
|
call mkdir(g:dir . '/test_c_projects/git_and_nested_makefiles/.git')
|
|
|
|
endif
|
|
|
|
|
|
|
|
if !filereadable(g:dir . '/test_c_projects/git_and_nested_makefiles/.git/HEAD')
|
|
|
|
call writefile([], g:dir . '/test_c_projects/git_and_nested_makefiles/.git/HEAD')
|
|
|
|
endif
|
|
|
|
|
|
|
|
call ale#test#SetFilename('test_c_projects/git_and_nested_makefiles/src/file.cpp')
|
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 20:37:10 +00:00
|
|
|
\ ale#Escape('clang++')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-iquote ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/git_and_nested_makefiles/src')) . ' '
|
|
|
|
\ . ' -I' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/git_and_nested_makefiles/include')) . ' '
|
2017-06-25 20:33:15 +00:00
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
|
|
|
|
|
2017-06-24 11:38:16 +00:00
|
|
|
Execute(The C++ ClangTidy handler should include json folders for projects with suitable build directory in them):
|
|
|
|
runtime! ale_linters/cpp/clangtidy.vim
|
|
|
|
|
2017-06-25 20:33:15 +00:00
|
|
|
call ale#test#SetFilename('test_c_projects/json_project/subdir/file.cpp')
|
2017-06-24 11:38:16 +00:00
|
|
|
|
|
|
|
AssertEqual
|
2017-07-16 23:07:18 +00:00
|
|
|
\ ale#Escape('clang-tidy')
|
2017-10-23 22:09:40 +00:00
|
|
|
\ . ' -checks=' . ale#Escape('*') . ' %s '
|
2017-12-19 18:23:09 +00:00
|
|
|
\ . '-p ' . ale#Escape(ale#path#Simplify(g:dir . '/test_c_projects/json_project/build'))
|
2017-06-24 11:38:16 +00:00
|
|
|
\ , ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
|
2017-06-25 20:33:15 +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
|