2017-05-31 19:01:40 +00:00
|
|
|
Before:
|
2018-07-23 21:03:28 +00:00
|
|
|
" Make sure the c.vim file is loaded first.
|
|
|
|
call ale#c#FindProjectRoot(bufnr(''))
|
|
|
|
|
2017-05-31 19:01:40 +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
|
2018-07-23 21:03:28 +00:00
|
|
|
Save g:__ale_c_project_filenames
|
|
|
|
|
|
|
|
let g:original_project_filenames = g:__ale_c_project_filenames
|
|
|
|
|
|
|
|
" Remove the .git/HEAD dir for C import paths for these tests.
|
|
|
|
" The tests run inside of a git repo.
|
|
|
|
let g:__ale_c_project_filenames = filter(
|
|
|
|
\ copy(g:__ale_c_project_filenames),
|
|
|
|
\ 'v:val isnot# ''.git/HEAD'''
|
|
|
|
\)
|
2017-05-31 19:01:40 +00:00
|
|
|
|
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
|
|
|
|
|
2018-07-23 21:03:28 +00:00
|
|
|
unlet! g:original_project_filenames
|
|
|
|
|
2017-07-09 21:43:25 +00:00
|
|
|
call ale#test#RestoreDirectory()
|
2017-05-31 19:01:40 +00:00
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
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
|
|
|
\ . ' -'
|
2018-03-27 18:24:22 +00:00
|
|
|
\ , ale_linters#cpp#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/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
|
|
|
\ . ' -'
|
2018-03-27 18:24:22 +00:00
|
|
|
\ , ale_linters#cpp#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/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
|
|
|
\ . ' -'
|
2018-03-27 18:24:22 +00:00
|
|
|
\ , ale_linters#cpp#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/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
|
|
|
\ . ' -'
|
2018-03-27 18:24:22 +00:00
|
|
|
\ , ale_linters#cpp#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/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
|
|
|
\ . ' -'
|
2018-03-27 18:24:22 +00:00
|
|
|
\ , ale_linters#cpp#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/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
|
|
|
\ . ' -'
|
2018-03-27 18:24:22 +00:00
|
|
|
\ , ale_linters#cpp#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/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
|
|
|
\ . ' -'
|
2018-03-27 18:24:22 +00:00
|
|
|
\ , ale_linters#cpp#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/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
|
|
|
\ . ' -'
|
2018-03-27 18:24:22 +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):
|
2018-07-23 21:21:13 +00:00
|
|
|
" Don't run this test on Windows. I can't be bothered fixing it.
|
|
|
|
if !has('win32')
|
|
|
|
runtime! ale_linters/cpp/clang.vim
|
|
|
|
|
|
|
|
" Restore the .git/HEAD check for just this test.
|
|
|
|
let g:__ale_c_project_filenames = g:original_project_filenames
|
|
|
|
|
|
|
|
call ale#test#SetFilename('test_c_projects/git_and_nested_makefiles/src/file.cpp')
|
|
|
|
|
|
|
|
AssertEqual
|
|
|
|
\ ale#Escape('clang++')
|
|
|
|
\ . ' -S -x c++ -fsyntax-only '
|
|
|
|
\ . '-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')) . ' '
|
|
|
|
\ . ' -'
|
|
|
|
\ , ale_linters#cpp#clang#GetCommand(bufnr(''), [])
|
|
|
|
endif
|
2017-06-25 20:33:15 +00:00
|
|
|
|
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(''))
|