summaryrefslogtreecommitdiff
path: root/test/command_callback
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-08-19 00:47:39 +0100
committerw0rp <devw0rp@gmail.com>2020-08-19 00:47:39 +0100
commit794224aafa6968dd635a96b66ddf218dfdea38d8 (patch)
tree45e6ab407d7414287251742d8c1222c1e7cac1cc /test/command_callback
parent92cada99134dd38d441b7a5a55ddbe7d58882c96 (diff)
downloadale-794224aafa6968dd635a96b66ddf218dfdea38d8.zip
#3056 Add tests for parsed C/C++ -std flag handling
Diffstat (limited to 'test/command_callback')
-rw-r--r--test/command_callback/test_c_clang_command_callbacks.vader17
-rw-r--r--test/command_callback/test_c_gcc_command_callbacks.vader21
-rw-r--r--test/command_callback/test_cpp_clang_command_callbacks.vader18
-rw-r--r--test/command_callback/test_cpp_gcc_command_callbacks.vader18
4 files changed, 72 insertions, 2 deletions
diff --git a/test/command_callback/test_c_clang_command_callbacks.vader b/test/command_callback/test_c_clang_command_callbacks.vader
index b8c02e4d..01be18e0 100644
--- a/test/command_callback/test_c_clang_command_callbacks.vader
+++ b/test/command_callback/test_c_clang_command_callbacks.vader
@@ -2,14 +2,25 @@ Before:
Save g:ale_c_parse_makefile
let g:ale_c_parse_makefile = 0
+ let g:get_cflags_return_value = ''
+
+ runtime autoload/ale/c.vim
+
+ function! ale#c#GetCFlags(buffer, output) abort
+ return g:get_cflags_return_value
+ endfunction
+
call ale#assert#SetUpLinterTest('c', 'clang')
let b:command_tail = ' -S -x c -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
\ . ' -std=c11 -Wall -'
After:
+ unlet! g:get_cflags_return_value
unlet! b:command_tail
+ runtime autoload/ale/c.vim
+
call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
@@ -18,3 +29,9 @@ Execute(The executable should be configurable):
let b:ale_c_clang_executable = 'foobar'
AssertLinter 'foobar', [ale#Escape('foobar') . b:command_tail]
+
+Execute(The -std flag should be replaced by parsed C flags):
+ let b:command_tail = substitute(b:command_tail, 'c11', 'c99 ', '')
+ let g:get_cflags_return_value = '-std=c99'
+
+ AssertLinter 'clang', ale#Escape('clang') . b:command_tail
diff --git a/test/command_callback/test_c_gcc_command_callbacks.vader b/test/command_callback/test_c_gcc_command_callbacks.vader
index 2dbb8b7c..ee5d9030 100644
--- a/test/command_callback/test_c_gcc_command_callbacks.vader
+++ b/test/command_callback/test_c_gcc_command_callbacks.vader
@@ -1,5 +1,13 @@
Before:
Save g:ale_c_parse_makefile
+ let g:get_cflags_return_value = ''
+
+ runtime autoload/ale/c.vim
+
+ function! ale#c#GetCFlags(buffer, output) abort
+ return g:get_cflags_return_value
+ endfunction
+
let g:ale_c_parse_makefile = 0
call ale#assert#SetUpLinterTest('c', 'gcc')
@@ -10,13 +18,22 @@ Before:
\ . ' -std=c11 -Wall -'
After:
- call ale#assert#TearDownLinterTest()
-
+ unlet! g:get_cflags_return_value
unlet! b:command_tail
+ runtime autoload/ale/c.vim
+
+ call ale#assert#TearDownLinterTest()
+
Execute(The executable should be configurable):
AssertLinter 'gcc', [ale#Escape('gcc') . b:command_tail]
let b:ale_c_gcc_executable = 'foobar'
AssertLinter 'foobar', [ale#Escape('foobar') . b:command_tail]
+
+Execute(The -std flag should be replaced by parsed C flags):
+ let b:command_tail = substitute(b:command_tail, 'c11', 'c99 ', '')
+ let g:get_cflags_return_value = '-std=c99'
+
+ AssertLinter 'gcc', ale#Escape('gcc') . b:command_tail
diff --git a/test/command_callback/test_cpp_clang_command_callbacks.vader b/test/command_callback/test_cpp_clang_command_callbacks.vader
index e96fd8e7..7d5fe989 100644
--- a/test/command_callback/test_cpp_clang_command_callbacks.vader
+++ b/test/command_callback/test_cpp_clang_command_callbacks.vader
@@ -2,13 +2,25 @@ Before:
Save g:ale_c_parse_makefile
let g:ale_c_parse_makefile = 0
+ let g:get_cflags_return_value = ''
+
+ runtime autoload/ale/c.vim
+
+ function! ale#c#GetCFlags(buffer, output) abort
+ return g:get_cflags_return_value
+ endfunction
+
call ale#assert#SetUpLinterTest('cpp', 'clang')
let b:command_tail = ' -S -x c++ -fsyntax-only -iquote'
\ . ' ' . ale#Escape(getcwd())
\ . ' -std=c++14 -Wall -'
After:
+ unlet! g:get_cflags_return_value
unlet! b:command_tail
+
+ runtime autoload/ale/c.vim
+
call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
@@ -17,3 +29,9 @@ Execute(The executable should be configurable):
let b:ale_cpp_clang_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
+
+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 'clang++', ale#Escape('clang++') . b:command_tail
diff --git a/test/command_callback/test_cpp_gcc_command_callbacks.vader b/test/command_callback/test_cpp_gcc_command_callbacks.vader
index cfa4ecc0..9a64e6a4 100644
--- a/test/command_callback/test_cpp_gcc_command_callbacks.vader
+++ b/test/command_callback/test_cpp_gcc_command_callbacks.vader
@@ -2,6 +2,14 @@ Before:
Save g:ale_c_parse_makefile
let g:ale_c_parse_makefile = 0
+ let g:get_cflags_return_value = ''
+
+ runtime autoload/ale/c.vim
+
+ function! ale#c#GetCFlags(buffer, output) abort
+ return g:get_cflags_return_value
+ endfunction
+
call ale#assert#SetUpLinterTest('cpp', 'gcc')
let b:command_tail = ' -S -x c++'
\ . ' -o ' . (has('win32') ? 'nul': '/dev/null')
@@ -9,7 +17,11 @@ Before:
\ . ' -std=c++14 -Wall -'
After:
+ unlet! g:get_cflags_return_value
unlet! b:command_tail
+
+ runtime autoload/ale/c.vim
+
call ale#assert#TearDownLinterTest()
Execute(The executable should be configurable):
@@ -18,3 +30,9 @@ Execute(The executable should be configurable):
let b:ale_cpp_gcc_executable = 'foobar'
AssertLinter 'foobar', ale#Escape('foobar') . b:command_tail
+
+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