diff options
author | roel0 <roel.postelmans@altran.com> | 2018-03-20 11:56:46 +0100 |
---|---|---|
committer | roel0 <roel.postelmans@altran.com> | 2018-03-20 11:56:46 +0100 |
commit | 3fb7efa2c6d249ccc5b69036dbeda690c7459515 (patch) | |
tree | 33393c06810204d57e558ed7cec68cb0902032ba /test | |
parent | c47b5fd4b8f9b7c08774e631dae60ca51c23e7c9 (diff) | |
download | ale-3fb7efa2c6d249ccc5b69036dbeda690c7459515.zip |
Added some unit tests and fixed some linting errors for automatic makefile parsing in C #1167
Diffstat (limited to 'test')
-rw-r--r-- | test/test_c_parse_makefile.vader | 72 | ||||
-rw-r--r-- | test/test_c_projects/makefile_project/Makefile | 3 | ||||
-rw-r--r-- | test/test_c_projects/makefile_project/subdir/file.c | 0 |
3 files changed, 75 insertions, 0 deletions
diff --git a/test/test_c_parse_makefile.vader b/test/test_c_parse_makefile.vader new file mode 100644 index 00000000..fac04bbe --- /dev/null +++ b/test/test_c_parse_makefile.vader @@ -0,0 +1,72 @@ +Before: + Save g:ale_c_gcc_options + Save g:ale_c_gcc_parse_makefile + Save g:ale_c_clang_options + Save g:ale_c_clang_parse_makefile + Save g:ale_cpp_gcc_options + Save g:ale_cpp_clang_options + + call ale#test#SetDirectory('/testplugin/test') + + let g:ale_c_gcc_parse_makefile=1 + let g:ale_c_clang_parse_makefile=1 + 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 + +Execute(The C GCC handler should include directories specified in the include path for projects with a Makefile): + runtime! ale_linters/c/gcc.vim + + call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') + + AssertEqual + \ ale#Escape('gcc') + \ . ' -S -x c -fsyntax-only ' + \ . '-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/subdir/'))[1:-3] . ' ' + \ . ' -' + \ , ale_linters#c#gcc#GetCommand(bufnr('')) + +Execute(The C++ Clang handler should include directories specified in the include path for projects with a Makefile): + runtime! ale_linters/c/clang.vim + + call ale#test#SetFilename('test_c_projects/makefile_project/subdir/file.c') + + AssertEqual + \ ale#Escape('clang') + \ . ' -S -x c -fsyntax-only ' + \ . '-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/subdir'))[1:-2] . ' ' + \ . ' -' + \ , ale_linters#c#clang#GetCommand(bufnr('')) + + +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 diff --git a/test/test_c_projects/makefile_project/Makefile b/test/test_c_projects/makefile_project/Makefile index e69de29b..8b49a94d 100644 --- a/test/test_c_projects/makefile_project/Makefile +++ b/test/test_c_projects/makefile_project/Makefile @@ -0,0 +1,3 @@ +file.o : subdir/file.c + cc -c subdir/file.c -Isubdir + diff --git a/test/test_c_projects/makefile_project/subdir/file.c b/test/test_c_projects/makefile_project/subdir/file.c new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/test/test_c_projects/makefile_project/subdir/file.c |