Fix the test issues with html-beautify
This commit is contained in:
parent
47eb3dd0c0
commit
9a0b604a99
3 changed files with 15 additions and 21 deletions
|
@ -267,14 +267,22 @@ function! ale#assert#TearDownLinterTest() abort
|
||||||
endif
|
endif
|
||||||
endfunction
|
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.
|
" Set up a marker so ALE doesn't create real random temporary filenames.
|
||||||
let g:ale_create_dummy_temporary_file = 1
|
let g:ale_create_dummy_temporary_file = 1
|
||||||
|
|
||||||
let l:function_name = ale#fix#registry#GetFunc(a:name)
|
let l:function_name = ale#fix#registry#GetFunc(a:name)
|
||||||
let s:FixerFunction = function(l:function_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'
|
let b:filter_expr = 'v:val[: len(l:prefix) - 1] is# l:prefix'
|
||||||
|
|
||||||
for l:key in filter(keys(g:), b:filter_expr)
|
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]
|
unlet b:[l:key]
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
execute 'runtime autoload/ale/fixers/' . a:name . '.vim'
|
execute 'runtime autoload/ale/fixers/' . substitute(a:name, '-', '_', 'g') . '.vim'
|
||||||
|
|
||||||
if !exists('g:dir')
|
if !exists('g:dir')
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
|
|
|
@ -194,6 +194,7 @@ Notes:
|
||||||
* HTML
|
* HTML
|
||||||
* `alex`!!
|
* `alex`!!
|
||||||
* `fecs`
|
* `fecs`
|
||||||
|
* `html-beautify`
|
||||||
* `HTMLHint`
|
* `HTMLHint`
|
||||||
* `prettier`
|
* `prettier`
|
||||||
* `proselint`
|
* `proselint`
|
||||||
|
|
|
@ -1,31 +1,16 @@
|
||||||
Before:
|
Before:
|
||||||
Save g:ale_html_beautify_executable
|
call ale#assert#SetUpFixerTest('html', 'html-beautify', 'beautify')
|
||||||
Save g:ale_html_beautify_options
|
|
||||||
|
|
||||||
let g:ale_html_beautify_options = ''
|
|
||||||
|
|
||||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||||
silent cd ..
|
silent cd ..
|
||||||
silent cd command_callback
|
silent cd command_callback
|
||||||
let g:dir = getcwd()
|
|
||||||
|
|
||||||
After:
|
After:
|
||||||
Restore
|
Restore
|
||||||
|
|
||||||
unlet! b:bin_dir
|
call ale#assert#TearDownFixerTest()
|
||||||
|
|
||||||
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(''))
|
|
||||||
|
|
||||||
Execute(The html-beautify callback should return the correct default command):
|
Execute(The html-beautify callback should return the correct default command):
|
||||||
AssertEqual
|
AssertEqual
|
||||||
\ {
|
\ {'command': '''html-beautify'' -'},
|
||||||
\ 'command': ale#Escape('html_beautify_paths/html-beautify')
|
|
||||||
\ . ' -'
|
|
||||||
\ },
|
|
||||||
\ ale#fixers#html_beautify#Fix(bufnr(''))
|
\ ale#fixers#html_beautify#Fix(bufnr(''))
|
||||||
|
|
Reference in a new issue