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_standard_command_callback.vader | 62 ++++------------------ 1 file changed, 9 insertions(+), 53 deletions(-) (limited to 'test/command_callback/test_standard_command_callback.vader') diff --git a/test/command_callback/test_standard_command_callback.vader b/test/command_callback/test_standard_command_callback.vader index 3dee2856..a47e2ec9 100644 --- a/test/command_callback/test_standard_command_callback.vader +++ b/test/command_callback/test_standard_command_callback.vader @@ -1,28 +1,10 @@ Before: - Save g:ale_javascript_standard_executable - Save g:ale_javascript_standard_use_global - Save g:ale_javascript_standard_options - - unlet! b:executable - unlet! g:ale_javascript_standard_executable - unlet! b:ale_javascript_standard_executable - unlet! g:ale_javascript_standard_use_global - unlet! g:ale_javascript_standard_options - - call ale#test#SetDirectory('/testplugin/test/command_callback') + call ale#assert#SetUpLinterTest('javascript', 'standard') call ale#test#SetFilename('testfile.js') - - runtime ale_linters/javascript/standard.vim - -After: - Restore - unlet! b:executable - call ale#test#SetFilename('test.txt') - - call ale#test#RestoreDirectory() - call ale#linter#Reset() +After: + call ale#assert#TearDownLinterTest() Execute(bin/cmd.js paths should be preferred): call ale#test#SetFilename('standard-test-files/with-cmd/testfile.js') @@ -32,15 +14,10 @@ Execute(bin/cmd.js paths should be preferred): \ . '/standard-test-files/with-cmd/node_modules/standard/bin/cmd.js' \) - AssertEqual - \ b:executable, - \ ale_linters#javascript#standard#GetExecutable(bufnr('')) - - AssertEqual + AssertLinter b:executable, \ (has('win32') ? 'node.exe ' : '') \ . ale#Escape(b:executable) - \ . ' --stdin %s', - \ ale_linters#javascript#standard#GetCommand(bufnr('')) + \ . ' --stdin %s' Execute(.bin directories should be used too): call ale#test#SetFilename('standard-test-files/with-bin/testfile.js') @@ -50,38 +27,17 @@ Execute(.bin directories should be used too): \ . '/standard-test-files/with-bin/node_modules/.bin/standard' \) - AssertEqual - \ b:executable, - \ ale_linters#javascript#standard#GetExecutable(bufnr('')) - - AssertEqual - \ ale#Escape(b:executable) - \ . ' --stdin %s', - \ ale_linters#javascript#standard#GetCommand(bufnr('')) + AssertLinter b:executable, ale#Escape(b:executable) . ' --stdin %s' Execute(The global executable should be used otherwise): - AssertEqual - \ 'standard', - \ ale_linters#javascript#standard#GetExecutable(bufnr('')) - - AssertEqual - \ ale#Escape('standard') . ' --stdin %s', - \ ale_linters#javascript#standard#GetCommand(bufnr('')) + AssertLinter 'standard', ale#Escape('standard') . ' --stdin %s' Execute(The global executable should be configurable): let b:ale_javascript_standard_executable = 'foobar' - AssertEqual - \ 'foobar', - \ ale_linters#javascript#standard#GetExecutable(bufnr('')) - - AssertEqual - \ ale#Escape('foobar') . ' --stdin %s', - \ ale_linters#javascript#standard#GetCommand(bufnr('')) + AssertLinter 'foobar', ale#Escape('foobar') . ' --stdin %s' Execute(The options should be configurable): let b:ale_javascript_standard_options = '--wat' - AssertEqual - \ ale#Escape('standard') . ' --wat --stdin %s', - \ ale_linters#javascript#standard#GetCommand(bufnr('')) + AssertLinter 'standard', ale#Escape('standard') . ' --wat --stdin %s' -- cgit v1.2.3