Fix the test issues with html-beautify

This commit is contained in:
w0rp 2019-10-28 13:45:25 +00:00
parent 47eb3dd0c0
commit 9a0b604a99
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
3 changed files with 15 additions and 21 deletions

View File

@ -267,14 +267,22 @@ function! ale#assert#TearDownLinterTest() abort
endif
endfunction
function! ale#assert#SetUpFixerTest(filetype, name) abort
function! ale#assert#SetUpFixerTest(filetype, name, ...) abort
" If the suffix of the option names format is different, an additional
" argument can be used for that instead.
if a:0 > 1
throw 'Too many arguments'
endif
" Set up a marker so ALE doesn't create real random temporary filenames.
let g:ale_create_dummy_temporary_file = 1
let l:function_name = ale#fix#registry#GetFunc(a:name)
let s:FixerFunction = function(l:function_name)
let l:prefix = 'ale_' . a:filetype . '_' . a:name
let l:option_suffix = get(a:000, 0, a:name)
let l:prefix = 'ale_' . a:filetype . '_'
\ . substitute(l:option_suffix, '-', '_', 'g')
let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
for l:key in filter(keys(g:), b:filter_expr)
@ -286,7 +294,7 @@ function! ale#assert#SetUpFixerTest(filetype, name) abort
unlet b:[l:key]
endfor
execute 'runtime autoload/ale/fixers/' . a:name . '.vim'
execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim'
if !exists('g:dir')
call ale#test#SetDirectory('/testplugin/test/fixers')

View File

@ -194,6 +194,7 @@ Notes:
* HTML
* `alex`!!
* `fecs`
* `html-beautify`
* `HTMLHint`
* `prettier`
* `proselint`

View File

@ -1,31 +1,16 @@
Before:
Save g:ale_html_beautify_executable
Save g:ale_html_beautify_options
let g:ale_html_beautify_options = ''
call ale#assert#SetUpFixerTest('html', 'html-beautify', 'beautify')
call ale#test#SetDirectory('/testplugin/test/fixers')
silent cd ..
silent cd command_callback
let g:dir = getcwd()
After:
Restore
unlet! b:bin_dir
call ale#test#RestoreDirectory()
Execute(The html-beautify callback should return 0 if html-beautify not found):
let g:ale_html_beautify_executable = 'xxxinvalidpath'
AssertEqual
\ 0,
\ ale#fixers#html_beautify#Fix(bufnr(''))
call ale#assert#TearDownFixerTest()
Execute(The html-beautify callback should return the correct default command):
AssertEqual
\ {
\ 'command': ale#Escape('html_beautify_paths/html-beautify')
\ . ' -'
\ },
\ {'command': '''html-beautify'' -'},
\ ale#fixers#html_beautify#Fix(bufnr(''))