diff options
Diffstat (limited to 'test/command_callback')
3 files changed, 98 insertions, 47 deletions
diff --git a/test/command_callback/test_c_cppcheck_command_callbacks.vader b/test/command_callback/test_c_cppcheck_command_callbacks.vader new file mode 100644 index 00000000..daf61fbd --- /dev/null +++ b/test/command_callback/test_c_cppcheck_command_callbacks.vader @@ -0,0 +1,49 @@ +Before: + Save g:ale_c_cppcheck_executable + Save g:ale_c_cppcheck_options + + unlet! g:ale_c_cppcheck_executable + unlet! b:ale_c_cppcheck_executable + unlet! g:ale_c_cppcheck_options + unlet! b:ale_c_cppcheck_options + + runtime ale_linters/c/cppcheck.vim + + let b:command_tail = ' -q --language=c --enable=style %t' + + call ale#test#SetDirectory('/testplugin/test/command_callback') + +After: + Restore + unlet! b:command_tail + unlet! b:ale_c_cppcheck_executable + unlet! b:ale_c_cppcheck_options + call ale#linter#Reset() + call ale#test#RestoreDirectory() + +Execute(The executable should be configurable): + AssertEqual 'cppcheck', ale_linters#c#cppcheck#GetExecutable(bufnr('')) + + let b:ale_c_cppcheck_executable = 'foobar' + + AssertEqual 'foobar', ale_linters#c#cppcheck#GetExecutable(bufnr('')) + +Execute(The executable should be used in the command): + AssertEqual + \ ale#Escape('cppcheck') . b:command_tail, + \ ale_linters#c#cppcheck#GetCommand(bufnr('')) + + let b:ale_c_cppcheck_executable = 'foobar' + + AssertEqual + \ ale#Escape('foobar') . b:command_tail, + \ ale_linters#c#cppcheck#GetCommand(bufnr('')) + +Execute(cppcheck for C++ should detect compile_commands.json files): + call ale#test#SetFilename('cppcheck_paths/one/foo.cpp') + + AssertEqual + \ 'cd ' . ale#Escape(g:dir . '/cppcheck_paths/one') . ' && ' + \ . ale#Escape('cppcheck') + \ . ' -q --language=c --project=compile_commands.json --enable=style %t', + \ ale_linters#c#cppcheck#GetCommand(bufnr('')) diff --git a/test/command_callback/test_cpp_cppcheck_command_callbacks.vader b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader new file mode 100644 index 00000000..18391184 --- /dev/null +++ b/test/command_callback/test_cpp_cppcheck_command_callbacks.vader @@ -0,0 +1,49 @@ +Before: + Save g:ale_cpp_cppcheck_executable + Save g:ale_cpp_cppcheck_options + + unlet! g:ale_cpp_cppcheck_executable + unlet! b:ale_cpp_cppcheck_executable + unlet! g:ale_cpp_cppcheck_options + unlet! b:ale_cpp_cppcheck_options + + runtime ale_linters/cpp/cppcheck.vim + + let b:command_tail = ' -q --language=c++ --enable=style %t' + + call ale#test#SetDirectory('/testplugin/test/command_callback') + +After: + Restore + unlet! b:command_tail + unlet! b:ale_cpp_cppcheck_executable + unlet! b:ale_cpp_cppcheck_options + call ale#linter#Reset() + call ale#test#RestoreDirectory() + +Execute(The executable should be configurable): + AssertEqual 'cppcheck', ale_linters#cpp#cppcheck#GetExecutable(bufnr('')) + + let b:ale_cpp_cppcheck_executable = 'foobar' + + AssertEqual 'foobar', ale_linters#cpp#cppcheck#GetExecutable(bufnr('')) + +Execute(The executable should be used in the command): + AssertEqual + \ ale#Escape('cppcheck') . b:command_tail, + \ ale_linters#cpp#cppcheck#GetCommand(bufnr('')) + + let b:ale_cpp_cppcheck_executable = 'foobar' + + AssertEqual + \ ale#Escape('foobar') . b:command_tail, + \ ale_linters#cpp#cppcheck#GetCommand(bufnr('')) + +Execute(cppcheck for C++ should detect compile_commands.json files): + call ale#test#SetFilename('cppcheck_paths/one/foo.cpp') + + AssertEqual + \ 'cd ' . ale#Escape(g:dir . '/cppcheck_paths/one') . ' && ' + \ . ale#Escape('cppcheck') + \ . ' -q --language=c++ --project=compile_commands.json --enable=style %t', + \ ale_linters#cpp#cppcheck#GetCommand(bufnr('')) diff --git a/test/command_callback/test_cppcheck_command_callbacks.vader b/test/command_callback/test_cppcheck_command_callbacks.vader deleted file mode 100644 index 69bb214d..00000000 --- a/test/command_callback/test_cppcheck_command_callbacks.vader +++ /dev/null @@ -1,47 +0,0 @@ -Before: - silent! cd /testplugin/test/command_callback - let b:dir = getcwd() - -After: - silent execute 'cd ' . fnameescape(b:dir) - unlet! b:dir - - call ale#linter#Reset() - -Execute(The default C cppcheck command should be correct): - runtime ale_linters/c/cppcheck.vim - - call ale#test#SetFilename('cppcheck_paths/two/foo.cpp') - - AssertEqual - \ 'cppcheck -q --language=c --enable=style %t', - \ ale_linters#c#cppcheck#GetCommand(bufnr('')) - -Execute(cppcheck for C should detect compile_commands.json files): - runtime ale_linters/c/cppcheck.vim - - call ale#test#SetFilename('cppcheck_paths/one/foo.cpp') - - AssertEqual - \ 'cd ' . ale#Escape(b:dir . '/cppcheck_paths/one') . ' && ' - \ . 'cppcheck -q --language=c --project=compile_commands.json --enable=style %t', - \ ale_linters#c#cppcheck#GetCommand(bufnr('')) - -Execute(The default C++ cppcheck command should be correct): - runtime ale_linters/cpp/cppcheck.vim - - call ale#test#SetFilename('cppcheck_paths/two/foo.cpp') - - AssertEqual - \ 'cppcheck -q --language=c++ --enable=style %t', - \ ale_linters#cpp#cppcheck#GetCommand(bufnr('')) - -Execute(cppcheck for C++ should detect compile_commands.json files): - runtime ale_linters/cpp/cppcheck.vim - - call ale#test#SetFilename('cppcheck_paths/one/foo.cpp') - - AssertEqual - \ 'cd ' . ale#Escape(b:dir . '/cppcheck_paths/one') . ' && ' - \ . 'cppcheck -q --language=c++ --project=compile_commands.json --enable=style %t', - \ ale_linters#cpp#cppcheck#GetCommand(bufnr('')) |