Files
ale/test/fixers/test_xmllint_fixer_callback.vader
Vangelis 83ec182bdf xmllint fixer must read from stdin - not buffer filename (#4884)
The current xmllint fixer reads and formats the file that a buffer is
associated with from disk instead of accepting input from stdin. This
has the side effect that if the filename is changed in the buffer, but
not saved yet, the fixer discards all the pending changes and replaces
the buffer contents with the formatted text from the file contents on
disk.
2025-01-10 13:34:56 +09:00

57 lines
1.5 KiB
Plaintext

Before:
Save g:ale_xml_xmllint_executable
Save g:ale_xml_xmllint_indentsize
Save g:ale_xml_xmllint_options
let g:ale_xml_xmllint_executable = '/path/to/xmllint'
let g:ale_xml_xmllint_indentsize = ''
let g:ale_xml_xmllint_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
Execute(The xmllint callback should return the correct default command with unpersisted buffer):
new
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/xmllint')
\ . ' --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#fixers#xmllint#Fix(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#fixers#xmllint#Fix(bufnr(''))
Execute(The xmllint callback should include additional options):
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 --nonet --custom-opt 2 -'
\ },
\ ale#fixers#xmllint#Fix(bufnr(''))