diff --git a/autoload/ale/fixers/xmllint.vim b/autoload/ale/fixers/xmllint.vim index 9e478feb3b..4c74508b27 100644 --- a/autoload/ale/fixers/xmllint.vim +++ b/autoload/ale/fixers/xmllint.vim @@ -7,15 +7,8 @@ call ale#Set('xml_xmllint_indentsize', 2) function! ale#fixers#xmllint#Fix(buffer) abort let l:executable = ale#Escape(ale#Var(a:buffer, 'xml_xmllint_executable')) - let l:filename = bufname(a:buffer) - if empty(l:filename) - let l:filename = '%t' - else - let l:filename = ale#Escape(l:filename) - endif - - let l:command = l:executable . ' --format ' . l:filename + let l:command = l:executable . ' --format' let l:indent = ale#Var(a:buffer, 'xml_xmllint_indentsize') @@ -31,6 +24,6 @@ function! ale#fixers#xmllint#Fix(buffer) abort endif return { - \ 'command': l:command + \ 'command': l:command . ' -' \} endfunction diff --git a/test/fixers/test_xmllint_fixer_callback.vader b/test/fixers/test_xmllint_fixer_callback.vader index 103b0f7bd8..adf41fbf3f 100644 --- a/test/fixers/test_xmllint_fixer_callback.vader +++ b/test/fixers/test_xmllint_fixer_callback.vader @@ -18,39 +18,39 @@ Execute(The xmllint callback should return the correct default command with unpe AssertEqual \ { \ 'command': ale#Escape('/path/to/xmllint') - \ . ' --format %t' + \ . ' --format -' \ }, \ ale#fixers#xmllint#Fix(bufnr('')) Execute(The xmllint callback should return the correct default command): + call ale#test#SetFilename('../test-files/xml/dummy.xml') + AssertEqual \ { \ 'command': ale#Escape('/path/to/xmllint') - \ . ' --format ' - \ . ale#Escape(bufname(bufnr(''))) + \ . ' --format -' \ }, - \ ale#fixers#xmllint#Fix(bufnr('')) + \ ale#fixers#xmllint#Fix(bufname(bufnr(''))) Execute(The xmllint callback should include the XMLLINT_INDENT variable): + call ale#test#SetFilename('../test-files/xml/dummy.xml') let g:ale_xml_xmllint_indentsize = 2 AssertEqual \ { \ 'command': ale#Env('XMLLINT_INDENT', ' ') \ . ale#Escape('/path/to/xmllint') - \ . ' --format ' - \ . ale#Escape(bufname(bufnr(''))) + \ . ' --format -' \ }, \ ale#fixers#xmllint#Fix(bufnr('')) Execute(The xmllint callback should include additional options): - let g:ale_xml_xmllint_options = '--nonet' + call ale#test#SetFilename('../test-files/xml/dummy.xml') + let g:ale_xml_xmllint_options = '--nonet --custom-opt 2' AssertEqual \ { \ 'command': ale#Escape('/path/to/xmllint') - \ . ' --format ' - \ . ale#Escape(bufname(bufnr(''))) - \ . ' --nonet' + \ . ' --format --nonet --custom-opt 2 -' \ }, \ ale#fixers#xmllint#Fix(bufnr('')) diff --git a/test/test-files/xml/dummy.xml b/test/test-files/xml/dummy.xml new file mode 100644 index 0000000000..18b2953130 --- /dev/null +++ b/test/test-files/xml/dummy.xml @@ -0,0 +1,4 @@ + + + +