diff options
author | w0rp <devw0rp@gmail.com> | 2017-02-11 18:14:18 +0000 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-02-11 18:14:18 +0000 |
commit | 03ab963d1a02b0f4d45fb10915efa9fd9c5deaf7 (patch) | |
tree | 8d3f183a8e170328bc06243e015436bddfb4d697 /test/test_format_command.vader | |
parent | 88192e8662585f809bd248c1d689638ab007ac7b (diff) | |
download | ale-03ab963d1a02b0f4d45fb10915efa9fd9c5deaf7.zip |
Add support for temporary filename substitution, for replacing stdin_wrapper
Diffstat (limited to 'test/test_format_command.vader')
-rw-r--r-- | test/test_format_command.vader | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/test_format_command.vader b/test/test_format_command.vader new file mode 100644 index 00000000..d57729b0 --- /dev/null +++ b/test/test_format_command.vader @@ -0,0 +1,41 @@ +Before: + silent! cd /testplugin/test + :e! top/middle/bottom/dummy.txt + +After: + unlet! g:result + unlet! g:match + +Execute(FormatCommand should do nothing to basic command strings): + AssertEqual ['', 'awesome-linter do something'], ale#engine#FormatCommand(bufnr('%'), 'awesome-linter do something') + +Execute(FormatCommand should handle %%, and ignore other percents): + AssertEqual ['', '% %%d %%f %x %'], ale#engine#FormatCommand(bufnr('%'), '%% %%%d %%%f %x %') + +Execute(FormatCommand should convert %s to the current filename): + AssertEqual ['', 'foo ' . fnameescape(expand('%:p')) . ' bar ' . fnameescape(expand('%:p'))], ale#engine#FormatCommand(bufnr('%'), 'foo %s bar %s') + +Execute(FormatCommand should convert %t to a new temporary filename): + let g:result = ale#engine#FormatCommand(bufnr('%'), 'foo %t bar %t') + let g:match = matchlist(g:result[1], '\v^foo (/tmp/.*/dummy.txt) bar (/tmp/.*/dummy.txt)$') + + Assert !empty(g:match), 'No match found! Result was: ' . g:result[1] + " The first item of the result should be a temporary filename, and it should + " be the same as the escaped name in the command string. + AssertEqual g:result[0], fnameescape(g:match[1]) + " The two temporary filenames formatted in should be the same. + AssertEqual g:match[1], g:match[2] + +Execute(FormatCommand should let you combine %s and %t): + let g:result = ale#engine#FormatCommand(bufnr('%'), 'foo %t bar %s') + let g:match = matchlist(g:result[1], '\v^foo (/tmp/.*/dummy.txt) bar (.*/dummy.txt)$') + + Assert !empty(g:match), 'No match found! Result was: ' . g:result[1] + " The first item of the result should be a temporary filename, and it should + " be the same as the escaped name in the command string. + AssertEqual g:result[0], fnameescape(g:match[1]) + " The second item should be equal to the original filename. + AssertEqual fnameescape(expand('%:p')), g:match[2] + +Execute(EscapeCommandPart should escape all percent signs): + AssertEqual '%%s %%t %%%% %%s %%t %%%%', ale#engine#EscapeCommandPart('%s %t %% %s %t %%') |