summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--autoload/ale/assert.vim14
-rw-r--r--doc/ale-supported-languages-and-tools.txt1
-rw-r--r--test/fixers/test_html_beautify_fixer_callback.vader21
3 files changed, 15 insertions, 21 deletions
diff --git a/autoload/ale/assert.vim b/autoload/ale/assert.vim
index dac5efb7..291edcee 100644
--- a/autoload/ale/assert.vim
+++ b/autoload/ale/assert.vim
@@ -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')
diff --git a/doc/ale-supported-languages-and-tools.txt b/doc/ale-supported-languages-and-tools.txt
index e2379b70..55be8af5 100644
--- a/doc/ale-supported-languages-and-tools.txt
+++ b/doc/ale-supported-languages-and-tools.txt
@@ -194,6 +194,7 @@ Notes:
* HTML
* `alex`!!
* `fecs`
+ * `html-beautify`
* `HTMLHint`
* `prettier`
* `proselint`
diff --git a/test/fixers/test_html_beautify_fixer_callback.vader b/test/fixers/test_html_beautify_fixer_callback.vader
index dacd1cb2..05e10a36 100644
--- a/test/fixers/test_html_beautify_fixer_callback.vader
+++ b/test/fixers/test_html_beautify_fixer_callback.vader
@@ -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(''))