diff options
author | w0rp <devw0rp@gmail.com> | 2018-07-15 18:24:53 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2018-07-15 18:28:28 +0100 |
commit | a42999a639b2916b769a85f37d037be314d9d61b (patch) | |
tree | 5ebfb4d357dc673efa93fd32a66b489c4510de40 /test/command_callback/test_textlint_command_callbacks.vader | |
parent | 5155a35a80fe3b20659eb0f28cc6cc720532dd3f (diff) | |
download | ale-a42999a639b2916b769a85f37d037be314d9d61b.zip |
Massively reduce the amount of code needed for linter tests
Diffstat (limited to 'test/command_callback/test_textlint_command_callbacks.vader')
-rw-r--r-- | test/command_callback/test_textlint_command_callbacks.vader | 70 |
1 files changed, 25 insertions, 45 deletions
diff --git a/test/command_callback/test_textlint_command_callbacks.vader b/test/command_callback/test_textlint_command_callbacks.vader index 212f34d3..794c7fde 100644 --- a/test/command_callback/test_textlint_command_callbacks.vader +++ b/test/command_callback/test_textlint_command_callbacks.vader @@ -1,85 +1,65 @@ " Author: januswel, w0rp Before: + " This is just one language for the linter. + call ale#assert#SetUpLinterTest('markdown', 'textlint') + + " The configuration is shared between many languages. Save g:ale_textlint_executable Save g:ale_textlint_use_global Save g:ale_textlint_options - unlet! g:ale_textlint_executable + let g:ale_textlint_executable = 'textlint' + let g:ale_textlint_use_global = 0 + let g:ale_textlint_options = '' + unlet! b:ale_textlint_executable - unlet! g:ale_textlint_use_global unlet! b:ale_textlint_use_global - unlet! g:ale_textlint_options unlet! b:ale_textlint_options - runtime autoload/ale/handlers/textlint.vim - - call ale#test#SetDirectory('/testplugin/test/command_callback') - After: - Restore - unlet! b:command_tail unlet! b:ale_textlint_executable unlet! b:ale_textlint_use_global unlet! b:ale_textlint_options - call ale#test#RestoreDirectory() - call ale#linter#Reset() + call ale#assert#TearDownLinterTest() -Execute(The executable should be configurable): - AssertEqual 'textlint', ale#handlers#textlint#GetExecutable(bufnr('')) - - let b:ale_textlint_executable = 'foobar' - - AssertEqual 'foobar', ale#handlers#textlint#GetExecutable(bufnr('')) - -Execute(The executable should be used in the command): - AssertEqual - \ ale#Escape('textlint') . ' -f json --stdin --stdin-filename %s', - \ ale#handlers#textlint#GetCommand(bufnr('')) +Execute(The default command should be correct): + AssertLinter 'textlint', + \ ale#Escape('textlint') . ' -f json --stdin --stdin-filename %s' +Execute(The executable should be configurable): let b:ale_textlint_executable = 'foobar' - AssertEqual - \ ale#Escape('foobar') . ' -f json --stdin --stdin-filename %s', - \ ale#handlers#textlint#GetCommand(bufnr('')) - \ + AssertLinter 'foobar', + \ ale#Escape('foobar') . ' -f json --stdin --stdin-filename %s' Execute(The options should be configurable): let b:ale_textlint_options = '--something' - AssertEqual - \ ale#Escape('textlint') . ' --something -f json --stdin --stdin-filename %s', - \ ale#handlers#textlint#GetCommand(bufnr('')) + AssertLinter 'textlint', + \ ale#Escape('textlint') . ' --something -f json --stdin --stdin-filename %s' Execute(The local executable from .bin should be used if available): call ale#test#SetFilename('textlint_paths/with_bin_path/foo.txt') - AssertEqual + AssertLinter \ ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint'), - \ ale#handlers#textlint#GetExecutable(bufnr('')) - - AssertEqual \ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_bin_path/node_modules/.bin/textlint')) - \ . ' -f json --stdin --stdin-filename %s', - \ ale#handlers#textlint#GetCommand(bufnr('')) + \ . ' -f json --stdin --stdin-filename %s' Execute(The local executable from textlint/bin should be used if available): call ale#test#SetFilename('textlint_paths/with_textlint_bin_path/foo.txt') - AssertEqual - \ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'), - \ ale#handlers#textlint#GetExecutable(bufnr('')) - if has('win32') - AssertEqual + AssertLinter + \ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'), \ ale#Escape('node.exe') . ' ' . ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js')) - \ . ' -f json --stdin --stdin-filename %s', - \ ale#handlers#textlint#GetCommand(bufnr('')) + \ . ' -f json --stdin --stdin-filename %s' else - AssertEqual + AssertLinter + \ ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js'), \ ale#Escape(ale#path#Simplify(g:dir . '/textlint_paths/with_textlint_bin_path/node_modules/textlint/bin/textlint.js')) - \ . ' -f json --stdin --stdin-filename %s', - \ ale#handlers#textlint#GetCommand(bufnr('')) + \ . ' -f json --stdin --stdin-filename %s' endif |