2017-02-11 18:14:18 +00:00
|
|
|
Before:
|
|
|
|
silent! cd /testplugin/test
|
2017-05-08 21:59:25 +00:00
|
|
|
silent file top/middle/bottom/dummy.txt
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
After:
|
|
|
|
unlet! g:result
|
|
|
|
unlet! g:match
|
|
|
|
|
|
|
|
Execute(FormatCommand should do nothing to basic command strings):
|
2017-05-17 10:17:49 +00:00
|
|
|
AssertEqual ['', 'awesome-linter do something'], ale#command#FormatCommand(bufnr('%'), 'awesome-linter do something', 0)
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
Execute(FormatCommand should handle %%, and ignore other percents):
|
2017-05-17 10:17:49 +00:00
|
|
|
AssertEqual ['', '% %%d %%f %x %'], ale#command#FormatCommand(bufnr('%'), '%% %%%d %%%f %x %', 0)
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
Execute(FormatCommand should convert %s to the current filename):
|
2017-05-17 10:17:49 +00:00
|
|
|
AssertEqual ['', 'foo ' . shellescape(expand('%:p')) . ' bar ' . shellescape(expand('%:p'))], ale#command#FormatCommand(bufnr('%'), 'foo %s bar %s', 0)
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
Execute(FormatCommand should convert %t to a new temporary filename):
|
2017-05-17 10:17:49 +00:00
|
|
|
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo %t bar %t', 0)
|
2017-05-08 21:59:25 +00:00
|
|
|
let g:match = matchlist(g:result[1], '\v^foo (''/tmp/[^'']*/dummy.txt'') bar (''/tmp/[^'']*/dummy.txt'')$')
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
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.
|
2017-05-08 21:59:25 +00:00
|
|
|
AssertEqual shellescape(g:result[0]), g:match[1]
|
2017-02-11 18:14:18 +00:00
|
|
|
" 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):
|
2017-05-17 10:17:49 +00:00
|
|
|
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo %t bar %s', 0)
|
2017-05-08 21:59:25 +00:00
|
|
|
let g:match = matchlist(g:result[1], '\v^foo (''/tmp/.*/dummy.txt'') bar (''.*/dummy.txt'')$')
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
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.
|
2017-05-08 21:59:25 +00:00
|
|
|
AssertEqual shellescape(g:result[0]), g:match[1]
|
2017-02-11 18:14:18 +00:00
|
|
|
" The second item should be equal to the original filename.
|
2017-05-08 21:59:25 +00:00
|
|
|
AssertEqual shellescape(expand('%:p')), g:match[2]
|
2017-02-11 18:14:18 +00:00
|
|
|
|
|
|
|
Execute(EscapeCommandPart should escape all percent signs):
|
|
|
|
AssertEqual '%%s %%t %%%% %%s %%t %%%%', ale#engine#EscapeCommandPart('%s %t %% %s %t %%')
|
2017-05-17 10:17:49 +00:00
|
|
|
|
|
|
|
Execute(EscapeCommandPart should pipe in temporary files appropriately):
|
|
|
|
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo bar', 1)
|
|
|
|
let g:match = matchlist(g:result[1], '\v^foo bar \< (''/tmp/[^'']*/dummy.txt'')$')
|
|
|
|
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
|
|
|
|
AssertEqual shellescape(g:result[0]), g:match[1]
|
|
|
|
|
|
|
|
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo bar %t', 1)
|
|
|
|
let g:match = matchlist(g:result[1], '\v^foo bar (''/tmp/[^'']*/dummy.txt'')$')
|
|
|
|
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
|
|
|
|
AssertEqual shellescape(g:result[0]), g:match[1]
|