From a42999a639b2916b769a85f37d037be314d9d61b Mon Sep 17 00:00:00 2001 From: w0rp Date: Sun, 15 Jul 2018 18:24:53 +0100 Subject: Massively reduce the amount of code needed for linter tests --- .../test_cpp_clangcheck_command_callbacks.vader | 48 +++++----------------- 1 file changed, 10 insertions(+), 38 deletions(-) (limited to 'test/command_callback/test_cpp_clangcheck_command_callbacks.vader') diff --git a/test/command_callback/test_cpp_clangcheck_command_callbacks.vader b/test/command_callback/test_cpp_clangcheck_command_callbacks.vader index f708c52d..7aa09eed 100644 --- a/test/command_callback/test_cpp_clangcheck_command_callbacks.vader +++ b/test/command_callback/test_cpp_clangcheck_command_callbacks.vader @@ -1,63 +1,35 @@ Before: - Save g:ale_cpp_clangcheck_executable - Save g:ale_cpp_clangcheck_options - - unlet! g:ale_cpp_clangcheck_executable - unlet! b:ale_cpp_clangcheck_executable - unlet! g:ale_cpp_clangcheck_options - unlet! b:ale_cpp_clangcheck_options - - runtime ale_linters/cpp/clangcheck.vim + call ale#assert#SetUpLinterTest('cpp', 'clangcheck') After: - Restore - unlet! b:command_tail - unlet! b:ale_cpp_clangcheck_executable - unlet! b:ale_cpp_clangcheck_options - unlet! b:ale_c_build_dir - call ale#linter#Reset() + call ale#assert#TearDownLinterTest() Execute(The executable should be configurable): - AssertEqual 'clang-check', ale_linters#cpp#clangcheck#GetExecutable(bufnr('')) - - let b:ale_cpp_clangcheck_executable = 'foobar' - - AssertEqual 'foobar', ale_linters#cpp#clangcheck#GetExecutable(bufnr('')) - -Execute(The executable should be used in the command): - AssertEqual + AssertLinter 'clang-check', \ ale#Escape('clang-check') - \ . ' -analyze %s' - \ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text', - \ ale_linters#cpp#clangcheck#GetCommand(bufnr('')) + \ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text' let b:ale_cpp_clangcheck_executable = 'foobar' " The extra arguments in the command are used to prevent .plist files from " being generated. - AssertEqual + AssertLinter 'foobar', \ ale#Escape('foobar') - \ . ' -analyze %s' - \ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text', - \ ale_linters#cpp#clangcheck#GetCommand(bufnr('')) + \ . ' -analyze %s -extra-arg -Xclang -extra-arg -analyzer-output=text' Execute(The options should be configurable): let b:ale_cpp_clangcheck_options = '--something' - AssertEqual + AssertLinter 'clang-check', \ ale#Escape('clang-check') \ . ' -analyze %s' \ . ' -extra-arg -Xclang -extra-arg -analyzer-output=text' - \ . ' --something', - \ ale_linters#cpp#clangcheck#GetCommand(bufnr('')) + \ . ' --something' Execute(The build directory should be used when set): let b:ale_cpp_clangcheck_options = '--something' let b:ale_c_build_dir = '/foo/bar' - AssertEqual + AssertLinter 'clang-check', \ ale#Escape('clang-check') - \ . ' -analyze %s ' - \ . '--something -p ' - \ . ale#Escape('/foo/bar'), - \ ale_linters#cpp#clangcheck#GetCommand(bufnr('')) + \ . ' -analyze %s --something -p ' . ale#Escape('/foo/bar') -- cgit v1.2.3