1
0
mirror of https://github.com/amix/vimrc synced 2025-06-16 09:35:01 +08:00

Update Ale.

This commit is contained in:
Kurtis Moxley
2022-05-19 21:16:38 +08:00
parent 0071859401
commit dd26bc4697
1324 changed files with 56041 additions and 437 deletions

View File

@ -0,0 +1,47 @@
Before:
call ale#assert#SetUpFixerTest('swift', 'apple-swift-format')
After:
call ale#assert#TearDownFixerTest()
Execute(The swiftformat callback should return the correct default values):
call ale#test#SetFilename('../test-files/swift/dummy.swift')
let g:ale_swift_appleswiftformat_executable = 'xxxinvalid'
let g:ale_swift_appleswiftformat_use_swiftpm = 0
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_swift_appleswiftformat_executable)
\ . ' format --in-place %t',
\ },
\ ale#fixers#appleswiftformat#Fix(bufnr(''))
Execute(The swiftformat callback should return the correct default values and located configuration):
call ale#test#SetDirectory('/testplugin/test/test-files/swift/swift-package-project-with-config')
call ale#test#SetFilename('src/folder/dummy.swift')
let g:ale_swift_appleswiftformat_executable = 'xxxinvalid'
let g:ale_swift_appleswiftformat_use_swiftpm = 0
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_swift_appleswiftformat_executable)
\ . ' format --in-place %t --configuration ' . glob(g:dir . '/.swift-format'),
\ },
\ ale#fixers#appleswiftformat#Fix(bufnr(''))
call ale#test#RestoreDirectory()
Execute(The swiftformat callback should use swiftpm is use_swiftpm is set to 1):
call ale#test#SetFilename('../test-files/swift/swift-package-project/src/folder/dummy.swift')
let g:ale_swift_appleswiftformat_use_swiftpm = 1
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('swift')
\ . ' run swift-format format --in-place %t',
\ },
\ ale#fixers#appleswiftformat#Fix(bufnr(''))

View File

@ -0,0 +1,96 @@
Before:
Save g:ale_c_astyle_executable
Save g:ale_c_astyle_project_options
Save g:ale_cpp_astyle_project_options
" Use an invalid global executable, so we don't match it.
let g:ale_c_astyle_executable = 'xxxinvalid'
let g:ale_cpp_astyle_executable = 'invalidpp'
let g:ale_c_astyle_project_options = ''
let g:ale_cpp_astyle_project_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The astyle callback should return the correct default values):
" Because this file doesn't exist, no astylrc config
" exists near it. Therefore, project_options is empty.
call ale#test#SetFilename('../c_files/testfile.c')
let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_astyle_executable)
\ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
Execute(The astyle callback should support cpp files):
" Because this file doesn't exist, no astylrc config
" exists near it. Therefore, project_options is empty.
call ale#test#SetFilename('../cpp_files/dummy.cpp')
set filetype=cpp " The test fails without this
let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_cpp_astyle_executable)
\ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
Execute(The astyle callback should support cpp files with option file set):
call ale#test#SetFilename('../cpp_files/dummy.cpp')
let g:ale_cpp_astyle_project_options = '.astylerc_cpp'
let targetfile = bufname(bufnr('%'))
set filetype=cpp " The test fails without this
AssertEqual
\ {
\ 'command': ale#Escape('invalidpp')
\ . ' --project=' . g:ale_cpp_astyle_project_options
\ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
Execute(The astyle callback should return the correct default values with a specified option file):
call ale#test#SetFilename('../c_files/testfile.c')
let g:ale_c_astyle_project_options = '.astylerc_c'
let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' --project=' . g:ale_c_astyle_project_options
\ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
Execute(The astyle callback should find nearest default option file _astylrc):
call ale#test#SetFilename('../test-files/c/makefile_project/subdir/file.c')
let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' --project=_astylerc'
\ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))
Execute(The astyle callback should find .astylrc in the same directory as src):
call ale#test#SetFilename('../test-files/cpp/dummy.cpp')
set filetype=cpp " The test fails without this
let targetfile = bufname(bufnr('%'))
AssertEqual
\ {
\ 'command': ale#Escape('invalidpp')
\ . ' --project=.astylerc'
\ . ' --stdin=' . ale#Escape(targetfile)
\ },
\ ale#fixers#astyle#Fix(bufnr(''))

View File

@ -0,0 +1,49 @@
Before:
Save g:ale_python_autoflake_executable
Save g:ale_python_autoflake_options
" Use an invalid global executable, so we don't match it.
let g:ale_python_autoflake_executable = 'xxxinvalid'
let g:ale_python_autoflake_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
let g:dir = getcwd()
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
Restore
unlet! b:bin_dir
call ale#test#RestoreDirectory()
Execute(The autoflake callback should return the correct default values):
AssertEqual
\ 0,
\ ale#fixers#autoflake#Fix(bufnr(''))
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autoflake'))
\ . ' --in-place '
\ . ' %t',
\ 'read_temporary_file': 1,
\ },
\ ale#fixers#autoflake#Fix(bufnr(''))
Execute(The autoflake callback should include options):
let g:ale_python_autoflake_options = '--some-option'
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autoflake'))
\ . ' --some-option'
\ . ' --in-place '
\ . ' %t',
\ 'read_temporary_file': 1,
\ },
\ ale#fixers#autoflake#Fix(bufnr(''))

View File

@ -0,0 +1,47 @@
Before:
Save g:ale_python_autoimport_executable
Save g:ale_python_autoimport_options
" Use an invalid global executable, so we don't match it.
let g:ale_python_autoimport_executable = 'xxxinvalid'
let g:ale_python_autoimport_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
Restore
unlet! b:bin_dir
call ale#test#RestoreDirectory()
Execute(The autoimport callback should return the correct default values):
AssertEqual
\ 0,
\ ale#fixers#autoimport#Fix(bufnr(''))
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autoimport')) . ' -',
\ },
\ ale#fixers#autoimport#Fix(bufnr(''))
Execute(The autoimport callback should respect custom options):
let g:ale_python_autoimport_options = '--multi-line=3 --trailing-comma'
AssertEqual
\ 0,
\ ale#fixers#autoimport#Fix(bufnr(''))
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autoimport'))
\ . ' --multi-line=3 --trailing-comma -',
\ },
\ ale#fixers#autoimport#Fix(bufnr(''))

View File

@ -0,0 +1,37 @@
Before:
Save g:ale_python_autopep8_executable
Save g:ale_python_autopep8_options
" Use an invalid global executable, so we don't match it.
let g:ale_python_autopep8_executable = 'xxxinvalid'
let g:ale_python_autopep8_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
let g:dir = getcwd()
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
Restore
unlet! b:bin_dir
call ale#test#RestoreDirectory()
Execute(The autopep8 callback should return the correct default values):
AssertEqual
\ 0,
\ ale#fixers#autopep8#Fix(bufnr(''))
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autopep8')) . ' -'},
\ ale#fixers#autopep8#Fix(bufnr(''))
Execute(The autopep8 callback should include options):
let g:ale_python_autopep8_options = '--some-option'
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/autopep8')) . ' --some-option -' },
\ ale#fixers#autopep8#Fix(bufnr(''))

View File

@ -0,0 +1,30 @@
Before:
Save g:ale_bib_bibclean_executable
Save g:ale_bib_bibclean_options
let g:ale_bib_bibclean_executable = 'xxxinvalid'
let g:ale_bib_bibclean_options = '-align-equals'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The bibclean callback should return the correct default values):
call ale#test#SetFilename('../test-files/bib/dummy.bib')
AssertEqual
\ {'command': ale#Escape(g:ale_bib_bibclean_executable) . ' -align-equals'},
\ ale#fixers#bibclean#Fix(bufnr(''))
Execute(The bibclean callback should include custom bibclean options):
let g:ale_bib_bibclean_options = '-author -check-values'
call ale#test#SetFilename('../test-files/bib/dummy.bib')
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_bib_bibclean_executable) . ' -author -check-values'
\ },
\ ale#fixers#bibclean#Fix(bufnr(''))

View File

@ -0,0 +1,67 @@
Before:
call ale#assert#SetUpFixerTest('python', 'black')
let g:dir = getcwd()
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
call ale#assert#TearDownFixerTest()
unlet! g:dir
unlet! b:bin_dir
Execute(The black callback should return the correct default values):
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' -'},
\ ale#fixers#black#Fix(bufnr(''))
Execute(The black callback should include options):
let g:ale_python_black_options = '--some-option'
let g:ale_python_black_change_directory = 0
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option -' },
\ ale#fixers#black#Fix(bufnr(''))
Execute(The black callback should include --pyi for .pyi files):
let g:ale_python_black_change_directory = 0
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.pyi')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --pyi -' },
\ ale#fixers#black#Fix(bufnr(''))
Execute(The black callback should not concatenate options):
let g:ale_python_black_options = '--some-option'
let g:ale_python_black_change_directory = 0
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.pyi')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/black')) . ' --some-option --pyi -' },
\ ale#fixers#black#Fix(bufnr(''))
Execute(Pipenv is detected when python_black_auto_pipenv is set):
let g:ale_python_black_auto_pipenv = 1
let g:ale_python_black_change_directory = 0
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
AssertEqual
\ {'command': ale#Escape('pipenv') . ' run black -'},
\ ale#fixers#black#Fix(bufnr(''))
Execute(Poetry is detected when python_black_auto_poetry is set):
let g:ale_python_black_auto_poetry = 1
let g:ale_python_black_change_directory = 0
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
AssertEqual
\ {'command': ale#Escape('poetry') . ' run black -'},
\ ale#fixers#black#Fix(bufnr(''))

View File

@ -0,0 +1,39 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
call ale#test#RestoreDirectory()
Execute(Long lines with basic function calls should be broken up correctly):
AssertEqual
\ [
\ 'def foo():',
\ ' some_variable = this_is_a_longer_function(',
\ 'first_argument,',
\ ' second_argument,',
\ ' third_with_function_call(',
\ 'foo,',
\ ' bar,',
\ '))',
\ ],
\ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), [
\ 'def foo():',
\ ' some_variable = this_is_a_longer_function(first_argument, second_argument, third_with_function_call(foo, bar))',
\ ])
Execute(Longer lines should be permitted if a configuration file allows it):
call ale#test#SetFilename('../test-files/long-line/foo/bar.py')
AssertEqual
\ [
\ 'x = this_line_is_between_79_and_90_characters(first, second, third, fourth, fifth)',
\ 'y = this_line_is_longer_than_90_characters(',
\ 'much_longer_word,',
\ ' another_longer_word,',
\ ' a_third_long_word,',
\ ')'
\ ],
\ ale#fixers#generic_python#BreakUpLongLines(bufnr(''), [
\ 'x = this_line_is_between_79_and_90_characters(first, second, third, fourth, fifth)',
\ 'y = this_line_is_longer_than_90_characters(much_longer_word, another_longer_word, a_third_long_word)',
\ ])

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_haskell_brittany_executable
" Use an invalid global executable, so we don't match it.
let g:ale_haskell_brittany_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The brittany callback should return the correct default values):
call ale#test#SetFilename('../haskell_files/testfile.hs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' --write-mode inplace'
\ . ' %t',
\ },
\ ale#fixers#brittany#Fix(bufnr(''))

View File

@ -0,0 +1,21 @@
Before:
Save g:ale_proto_buf_format_executable
" Use an invalid global executable, so we don't match it.
let g:ale_proto_buf_format_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The buf-format callback should return the correct default values):
call ale#test#SetFilename('../test-files/proto/testfile.proto')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid') . ' format %t',
\ },
\ ale#fixers#buf_format#Fix(bufnr(''))

View File

@ -0,0 +1,29 @@
Before:
let g:ale_bazel_buildifier_options = ''
call ale#assert#SetUpFixerTest('bzl', 'buildifier')
After:
call ale#assert#TearDownFixerTest()
Execute(The buildifier callback should return the correct default values):
call ale#test#SetFilename('../test-files/bazel/WORKSPACE')
AssertFixer
\ {
\ 'command': ale#Escape(g:ale_bazel_buildifier_executable)
\ . ' -mode fix -lint fix -path '
\ . ale#Escape(ale#test#GetFilename('../test-files/bazel/WORKSPACE'))
\ . ' -'
\ }
Execute(The buildifier callback should include any additional options):
call ale#test#SetFilename('../test-files/bazel/WORKSPACE')
let g:ale_bazel_buildifier_options = '--some-option'
AssertFixer
\ {
\ 'command': ale#Escape(g:ale_bazel_buildifier_executable)
\ . ' -mode fix -lint fix -path '
\ . ale#Escape(ale#test#GetFilename('../test-files/bazel/WORKSPACE'))
\ . ' --some-option -'
\ }

View File

@ -0,0 +1,64 @@
Before:
Save g:ale_c_clangformat_executable
Save g:c_clangformat_style_option
Save g:c_clangformat_use_local_file
" Use an invalid global executable, so we don't match it.
let g:ale_c_clangformat_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
let g:dir = getcwd()
After:
Restore
call ale#test#RestoreDirectory()
Execute(The clang-format callback should return the correct default values):
call ale#test#SetFilename('../test-files/c/dummy.c')
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
\ . ' --assume-filename=' . ale#Escape(bufname(bufnr('')))
\ },
\ ale#fixers#clangformat#Fix(bufnr(''))
Execute(The clangformat callback should include any additional options):
call ale#test#SetFilename('../test-files/c/dummy.c')
let g:ale_c_clangformat_options = '--some-option'
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
\ . ' --assume-filename=' . ale#Escape(bufname(bufnr('')))
\ . ' --some-option',
\ },
\ ale#fixers#clangformat#Fix(bufnr(''))
Execute(The clangformat callback should include style options as well):
call ale#test#SetFilename('../test-files/c/dummy.c')
let g:ale_c_clangformat_options = '--some-option'
let g:ale_c_clangformat_style_option = '{BasedOnStyle: Microsoft, ColumnLimit:80,}'
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
\ . ' --assume-filename=' . ale#Escape(bufname(bufnr('')))
\ . ' --some-option' . " -style='{BasedOnStyle: Microsoft, ColumnLimit:80,}'",
\ },
\ ale#fixers#clangformat#Fix(bufnr(''))
Execute(The clangformat callback should use local file instead of style options):
call ale#test#SetFilename('../test-files/clangformat/with_clangformat/dummy.c')
let g:ale_c_clangformat_options = '--some-option'
let g:ale_c_clangformat_style_option = '{BasedOnStyle: Microsoft, ColumnLimit:80,}'
let g:ale_c_clangformat_use_local_file = 1
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_clangformat_executable)
\ . ' --assume-filename=' . ale#Escape(bufname(bufnr('')))
\ . ' --some-option' . ' -style=file',
\ },
\ ale#fixers#clangformat#Fix(bufnr(''))

View File

@ -0,0 +1,47 @@
Before:
Save g:ale_c_build_dir
Save g:ale_c_clangtidy_executable
Save g:ale_c_clangtidy_checks
Save g:ale_c_clangtidy_extra_options
Save g:ale_cpp_clangtidy_executable
Save g:ale_cpp_clangtidy_checks
Save g:ale_cpp_clangtidy_extra_options
" Use an invalid global executable, so we don't match it.
let g:ale_c_clangtidy_executable = 'xxxinvalid'
let g:ale_c_clangtidy_checks = []
let g:ale_c_clangtidy_extra_options = ''
let g:ale_cpp_clangtidy_executable = 'xxxinvalidpp'
let g:ale_cpp_clangtidy_checks = []
let g:ale_cpp_clangtidy_extra_options = ''
let g:ale_c_build_dir = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The clangtidy callback should return the correct default values):
call ale#test#SetFilename('../test-files/c/dummy.c')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_c_clangtidy_executable)
\ . ' -fix -fix-errors %t'
\ },
\ ale#fixers#clangtidy#Fix(bufnr(''))
Execute(The clangtidy callback should include any additional options):
call ale#test#SetFilename('../test-files/c/dummy.c')
let g:ale_c_clangtidy_extra_options = '--some-option'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_c_clangtidy_executable)
\ . ' -fix -fix-errors --some-option %t',
\ },
\ ale#fixers#clangtidy#Fix(bufnr(''))

View File

@ -0,0 +1,36 @@
Before:
Save g:ale_cmake_cmakeformat_executable
Save g:ale_cmake_cmakeformat_options
" Use an invalid global executable, so we don't match it.
let g:ale_cmake_cmakeformat_executable = 'xxxinvalid'
let g:ale_cmake_cmakeformat_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The cmakeformat callback should return the correct default values):
call ale#test#SetFilename('../cmake_files/CMakeList.txt')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' -'
\ },
\ ale#fixers#cmakeformat#Fix(bufnr(''))
Execute(The cmakeformat callback should include custom cmakeformat options):
let g:ale_cmake_cmakeformat_options = "-r '(a) -> a'"
call ale#test#SetFilename('../cmake_files/CMakeList.txt')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_cmake_cmakeformat_options
\ . ' -',
\ },
\ ale#fixers#cmakeformat#Fix(bufnr(''))

View File

@ -0,0 +1,33 @@
Before:
Save g:ale_crystal_format_executable
Save g:ale_crystal_format_options
" Use an invalid global executable, so we don't match it.
let g:ale_crystal_format_executable = 'xxxinvalid'
let g:ale_crystal_format_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The crystal format callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid') . ' tool format -',
\ },
\ ale#fixers#crystal#Fix(bufnr(''))
Execute(The crystal format callback should include custom options):
let g:ale_crystal_format_options = "-list=true"
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' tool format ' . g:ale_crystal_format_options
\ . ' -',
\ },
\ ale#fixers#crystal#Fix(bufnr(''))

View File

@ -0,0 +1,40 @@
Before:
Save g:ale_dart_format_executable
Save g:ale_dart_format_options
" Use an invalid global executable, so we don't match it.
let g:ale_dart_format_executable = 'xxxinvalid'
let g:ale_dart_format_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The dart format callback should return the correct default values):
call ale#test#SetFilename('../test-files/dart/testfile.dart')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' format'
\ . ' %t',
\ },
\ ale#fixers#dart_format#Fix(bufnr(''))
Execute(The dart format callback should include custom dart format options):
let g:ale_dart_format_options = "-l 80"
call ale#test#SetFilename('../test-files/dart/testfile.dart')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' format'
\ . ' ' . g:ale_dart_format_options
\ . ' %t',
\ },
\ ale#fixers#dart_format#Fix(bufnr(''))

View File

@ -0,0 +1,40 @@
Before:
Save g:ale_dart_dartfmt_executable
Save g:ale_dart_dartfmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_dart_dartfmt_executable = 'xxxinvalid'
let g:ale_dart_dartfmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The dartfmt callback should return the correct default values):
call ale#test#SetFilename('../test-files/dart/testfile.dart')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -w'
\ . ' %t',
\ },
\ ale#fixers#dartfmt#Fix(bufnr(''))
Execute(The dartfmt callback should include custom dartfmt options):
let g:ale_dart_dartfmt_options = "-l 80"
call ale#test#SetFilename('../test-files/dart/testfile.dart')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -w'
\ . ' ' . g:ale_dart_dartfmt_options
\ . ' %t',
\ },
\ ale#fixers#dartfmt#Fix(bufnr(''))

View File

@ -0,0 +1,40 @@
Before:
Save g:ale_d_dfmt_executable
Save g:ale_d_dfmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_d_dfmt_executable = 'xxxinvalid'
let g:ale_d_dfmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The dfmt callback should return the correct default values):
call ale#test#SetFilename('../test-files/d/test.d')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -i'
\ . ' %t',
\ },
\ ale#fixers#dfmt#Fix(bufnr(''))
Execute(The dfmt callback should include custom dfmt options):
let g:ale_d_dfmt_options = "--space-after-cast"
call ale#test#SetFilename('../test-files/d/test.d')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -i'
\ . ' ' . g:ale_d_dfmt_options
\ . ' %t',
\ },
\ ale#fixers#dfmt#Fix(bufnr(''))

View File

@ -0,0 +1,22 @@
Before:
Save g:ale_dhall_executable
Save g:ale_dhall_options
" Use an invalid global executable, so we dont match it.
let g:ale_dhall_executable = 'odd-dhall'
let g:ale_dhall_options = '--ascii'
call ale#assert#SetUpFixerTest('dhall', 'dhall-format')
After:
call ale#assert#TearDownFixerTest()
Execute(The dhall-format callback should return the correct options):
call ale#test#SetFilename('../dhall_files/testfile.dhall')
AssertFixer
\ {
\ 'command': ale#Escape('odd-dhall')
\ . ' --ascii'
\ . ' format'
\ }

View File

@ -0,0 +1,22 @@
Before:
Save g:ale_dhall_executable
Save g:ale_dhall_options
" Use an invalid global executable, so we dont match it.
let g:ale_dhall_executable = 'odd-dhall'
let g:ale_dhall_options = '--ascii'
let g:ale_dhall_freeze_options = '--all'
call ale#assert#SetUpFixerTest('dhall', 'dhall-freeze')
After:
call ale#assert#TearDownFixerTest()
Execute(The dhall-freeze callback should return the correct options):
AssertFixer
\ {
\ 'command': ale#Escape('odd-dhall')
\ . ' --ascii'
\ . ' freeze'
\ . ' --all'
\ }

View File

@ -0,0 +1,20 @@
Before:
Save g:ale_dhall_executable
Save g:ale_dhall_options
" Use an invalid global executable, so we dont match it.
let g:ale_dhall_executable = 'odd-dhall'
let g:ale_dhall_options = '--ascii'
call ale#assert#SetUpFixerTest('dhall', 'dhall-lint')
After:
call ale#assert#TearDownFixerTest()
Execute(The dhall-lint callback should return the correct options):
AssertFixer
\ {
\ 'command': ale#Escape('odd-dhall')
\ . ' --ascii'
\ . ' lint'
\ }

View File

@ -0,0 +1,41 @@
Before:
Save g:ale_cs_dotnet_format_executable
Save g:ale_cs_dotnet_format_options
" Use an invalid global executable, so we don't match it.
let g:ale_cs_dotnet_format_executable = 'xxxinvalid'
let g:ale_cs_dotnet_format_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The dotnet format callback should return the correct default values):
call ale#test#SetFilename('../test-files/cs/testfile.cs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' format'
\ . ' --folder --include %t "$(dirname %t)"',
\ },
\ ale#fixers#dotnet_format#Fix(bufnr(''))
Execute(The dotnet format callback should include custom dotnet format options):
let g:ale_cs_dotnet_format_options = "-l 80"
call ale#test#SetFilename('../test-files/cs/testfile.cs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' format'
\ . ' ' . g:ale_cs_dotnet_format_options
\ . ' --folder --include %t "$(dirname %t)"',
\ },
\ ale#fixers#dotnet_format#Fix(bufnr(''))

View File

@ -0,0 +1,44 @@
Before:
call ale#assert#SetUpFixerTest('typescript', 'dprint')
call ale#test#SetFilename('../test-files/dprint/blank.ts')
let g:ale_dprint_executable_override = 0
let g:ale_dprint_executable = 'dprint'
let g:ale_dprint_config = ''
After:
Restore
call ale#assert#TearDownFixerTest()
Execute(The dprint callback should return 0 for a non-existent executable):
let g:ale_dprint_executable = 'foo'
AssertFixer 0
Execute(The dprint callback should return the correct default values):
let g:ale_dprint_executable_override = 1
AssertFixer {
\ 'command': ale#Escape('dprint')
\ . ' fmt '
\ . ' --stdin %s'
\ }
Execute(The dprint callback should include config):
let g:ale_dprint_executable_override = 1
let g:ale_dprint_config = 'dprint.json'
AssertFixer {
\ 'command': ale#Escape('dprint')
\ . ' fmt '
\ . ' -c '
\ . ale#Escape((has('win32') ? 'C:\testplugin\test\test-files\dprint\dprint.json' : '/testplugin/test/test-files/dprint/dprint.json'))
\ . ' --stdin %s'
\ }
Execute(The dprint callback should include custom options):
let g:ale_dprint_executable_override = 1
let g:ale_dprint_options = '--verbose'
AssertFixer {
\ 'command': ale#Escape('dprint')
\ . ' fmt '
\ . '--verbose' . ' --stdin %s'
\ }

View File

@ -0,0 +1,74 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
unlet! b:ale_elm_format_executable
unlet! b:ale_elm_format_use_global
unlet! b:ale_elm_format_options
call ale#test#RestoreDirectory()
Execute(The elm-format command should have default params):
call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape(ale#path#Simplify(g:dir . '/../test-files/elm/node_modules/.bin/elm-format'))
\ . ' %t --yes',
\ },
\ ale#fixers#elm_format#Fix(bufnr(''))
Execute(The elm-format command should manage use_global = 1 param):
call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
let b:ale_elm_format_use_global = 1
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('elm-format')
\ . ' %t --yes',
\ },
\ ale#fixers#elm_format#Fix(bufnr(''))
Execute(The elm-format command should manage executable param):
call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
let b:ale_elm_format_use_global = 1
let b:ale_elm_format_executable = 'elmformat'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('elmformat')
\ . ' %t --yes',
\ },
\ ale#fixers#elm_format#Fix(bufnr(''))
Execute(The elm-format command should manage empty options):
call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
let b:ale_elm_format_options = ''
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape(ale#path#Simplify(g:dir . '/../test-files/elm/node_modules/.bin/elm-format'))
\ . ' %t',
\ },
\ ale#fixers#elm_format#Fix(bufnr(''))
Execute(The elm-format command should manage custom options):
call ale#test#SetFilename('../test-files/elm/src/subdir/testfile.elm')
let b:ale_elm_format_options = '--param1 --param2'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape(ale#path#Simplify(g:dir . '/../test-files/elm/node_modules/.bin/elm-format'))
\ . ' %t --param1 --param2',
\ },
\ ale#fixers#elm_format#Fix(bufnr(''))

View File

@ -0,0 +1,55 @@
Before:
Save g:ale_eruby_erblint_executable
Save g:ale_eruby_erblint_options
" Use an invalid global executable, so we don't match it.
let g:ale_eruby_erblint_executable = 'xxxinvalid'
let g:ale_eruby_erblint_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The erblint callback should return the correct default values):
call ale#test#SetFilename('../test-files/eruby/dummy.html.erb')
AssertEqual
\ {
\ 'process_with': 'ale#fixers#erblint#PostProcess',
\ 'command': ale#Escape(g:ale_eruby_erblint_executable)
\ . ' --autocorrect --stdin %s',
\ },
\ ale#fixers#erblint#Fix(bufnr(''))
Execute(The erblint callback should include custom erblint options):
let g:ale_eruby_erblint_options = '--lint-all'
call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')
AssertEqual
\ {
\ 'process_with': 'ale#fixers#erblint#PostProcess',
\ 'command': ale#Escape(g:ale_eruby_erblint_executable)
\ . ' --lint-all'
\ . ' --autocorrect --stdin %s',
\ },
\ ale#fixers#erblint#Fix(bufnr(''))
Execute(The erblint post-processor should remove diagnostics content):
AssertEqual
\ [
\ '<div>',
\ '',
\ '</div>',
\ ],
\ ale#fixers#erblint#PostProcess(bufnr(''), [
\ 'Linting 1 files with 11 autocorrectable linters...',
\ '',
\ '1 error(s) corrected in ERB files',
\ '================ /home/user/demo.html.erb ==================',
\ '<div>',
\ '',
\ '</div>',
\ ])

View File

@ -0,0 +1,25 @@
Before:
Save b:ale_elm_format_executable
Save b:ale_elm_format_options
let b:ale_elm_format_executable = 'erlfmt'
let b:ale_elm_format_options = ''
After:
Restore
Execute(The erlfmt command should handle empty options):
AssertEqual
\ {
\ 'command': ale#Escape('erlfmt') . ' %s'
\ },
\ ale#fixers#erlfmt#Fix(bufnr(''))
Execute(The erlfmt command should handle custom options):
let b:ale_erlang_erlfmt_options = '--insert-pragma'
AssertEqual
\ {
\ 'command': ale#Escape('erlfmt') . ' --insert-pragma %s'
\ },
\ ale#fixers#erlfmt#Fix(bufnr(''))

View File

@ -0,0 +1,339 @@
Before:
call ale#assert#SetUpFixerTest('javascript', 'eslint')
Save g:ale_command_wrapper
runtime autoload/ale/handlers/eslint.vim
let g:ale_command_wrapper = ''
After:
call ale#assert#TearDownFixerTest()
Execute(The executable path should be correct):
call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js')
" eslint_d output with an older eslint version is used here.
GivenCommandOutput ['v4.4.1 (eslint_d v5.1.0)']
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/.eslintrc.js'))
\ . ' --fix %t',
\ }
Execute(The ESLint fixer shouldn't run if no configuration file can be found):
call ale#test#SetFilename('../no-configuration')
AssertFixerNotExecuted
Execute(The ESLint fixer should use a config file option if set for old versions):
call ale#test#SetFilename('../no-configuration')
let b:ale_javascript_eslint_options = '-c /foo.cfg'
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': '',
\ 'command': ale#Escape('eslint') . ' -c /foo.cfg --fix %t',
\ }
let b:ale_javascript_eslint_options = '--bar -c /foo.cfg'
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': '',
\ 'command': ale#Escape('eslint') . ' --bar -c /foo.cfg --fix %t',
\ }
let b:ale_javascript_eslint_options = '--config /foo.cfg'
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': '',
\ 'command': ale#Escape('eslint') . ' --config /foo.cfg --fix %t',
\ }
let b:ale_javascript_eslint_options = '--bar --config /foo.cfg'
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': '',
\ 'command': ale#Escape('eslint') . ' --bar --config /foo.cfg --fix %t',
\ }
Execute(The ESLint fixer should use a -c file option if set for eslint_d):
let b:ale_javascript_eslint_executable = '/bin/eslint_d'
GivenCommandOutput ['v3.19.0 (eslint_d v4.2.0)']
call ale#test#SetFilename('../no-configuration')
let b:ale_javascript_eslint_options = '-c /foo.cfg'
AssertFixer
\ {
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
\ 'cwd': '',
\ 'command': ale#Escape('/bin/eslint_d')
\ . ' -c /foo.cfg'
\ . ' --stdin-filename %s --stdin --fix-to-stdout'
\ }
let b:ale_javascript_eslint_options = '--bar -c /foo.cfg'
AssertFixer
\ {
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
\ 'cwd': '',
\ 'command': ale#Escape('/bin/eslint_d')
\ . ' --bar -c /foo.cfg'
\ . ' --stdin-filename %s --stdin --fix-to-stdout'
\ }
let b:ale_javascript_eslint_options = '--config /foo.cfg'
AssertFixer
\ {
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
\ 'cwd': '',
\ 'command': ale#Escape('/bin/eslint_d')
\ . ' --config /foo.cfg'
\ . ' --stdin-filename %s --stdin --fix-to-stdout'
\ }
let b:ale_javascript_eslint_options = '--bar --config /foo.cfg'
AssertFixer
\ {
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
\ 'cwd': '',
\ 'command': ale#Escape('/bin/eslint_d')
\ . ' --bar --config /foo.cfg'
\ . ' --stdin-filename %s --stdin --fix-to-stdout'
\ }
Execute(The ESLint fixer should use a config file option if set for new versions):
GivenCommandOutput ['4.9.0']
call ale#test#SetFilename('../no-configuration')
let b:ale_javascript_eslint_options = '-c /foo.cfg'
AssertFixer
\ {
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
\ 'cwd': '',
\ 'command': ale#Escape('eslint')
\ . ' -c /foo.cfg'
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
\ }
let b:ale_javascript_eslint_options = '--bar -c /foo.cfg'
AssertFixer
\ {
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
\ 'cwd': '',
\ 'command': ale#Escape('eslint')
\ . ' --bar -c /foo.cfg'
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
\ }
let b:ale_javascript_eslint_options = '--config /foo.cfg'
AssertFixer
\ {
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
\ 'cwd': '',
\ 'command': ale#Escape('eslint')
\ . ' --config /foo.cfg'
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
\ }
let b:ale_javascript_eslint_options = '--bar --config /foo.cfg'
AssertFixer
\ {
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
\ 'cwd': '',
\ 'command': ale#Escape('eslint')
\ . ' --bar --config /foo.cfg'
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json'
\ }
Execute(The lower priority configuration file in a nested directory should be preferred):
call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-config/testfile.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/subdir-with-config/.eslintrc'))
\ . ' --fix %t',
\ }
Execute(--config in options should override configuration file detection for old versions):
call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-config/testfile.js')
let b:ale_javascript_eslint_options = '--config /foo.cfg'
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' --config /foo.cfg'
\ . ' --fix %t',
\ }
let b:ale_javascript_eslint_options = '-c /foo.cfg'
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' -c /foo.cfg'
\ . ' --fix %t',
\ }
Execute(package.json should be used as a last resort):
call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-package-json/testfile.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/.eslintrc.js'))
\ . ' --fix %t',
\ }
call ale#test#SetFilename('../test-files/eslint/package.json')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint'),
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/node_modules/.bin/eslint'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/package.json'))
\ . ' --fix %t',
\ }
Execute(The version check should be correct):
call ale#test#SetFilename('../test-files/eslint/react-app/subdir-with-config/testfile.js')
" We should run the command to get the version the first time.
GivenCommandOutput ['4.9.0']
AssertFixer [
\ (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' --version',
\ {
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
\ },
\]
AssertFixer [
\ {
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
\ },
\]
Execute(--fix-dry-run should be used for 4.9.0 and up):
call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js')
GivenCommandOutput ['4.9.0']
AssertFixer
\ {
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/react-app'),
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' --stdin-filename %s --stdin --fix-dry-run --format=json',
\ 'process_with': 'ale#fixers#eslint#ProcessFixDryRunOutput',
\ }
Execute(--fix-to-stdout should be used for eslint_d):
call ale#test#SetFilename('../test-files/eslint/app-with-eslint-d/testfile.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/app-with-eslint-d'),
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/app-with-eslint-d/node_modules/.bin/eslint_d'))
\ . ' -c ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/package.json'))
\ . ' --fix %t',
\ }
" The option should be used when eslint_d is new enough.
" We look at the ESLint version instead of the eslint_d version.
GivenCommandOutput ['v3.19.0 (eslint_d v4.2.0)']
AssertFixer
\ {
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/app-with-eslint-d'),
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/app-with-eslint-d/node_modules/.bin/eslint_d'))
\ . ' --stdin-filename %s --stdin --fix-to-stdout',
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
\ }
" The option should be used for new versions too.
GivenCommandOutput ['4.9.0']
AssertFixer
\ {
\ 'cwd': ale#path#Simplify(g:dir . '/../test-files/eslint/app-with-eslint-d'),
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/app-with-eslint-d/node_modules/.bin/eslint_d'))
\ . ' --stdin-filename %s --stdin --fix-to-stdout',
\ 'process_with': 'ale#fixers#eslint#ProcessEslintDOutput',
\ }
Execute(The --fix-dry-run post-processor should handle JSON output correctly):
AssertEqual
\ [],
\ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), [])
AssertEqual
\ [],
\ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), [''])
AssertEqual
\ [],
\ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), ['[{}]'])
AssertEqual
\ ['foo', 'bar'],
\ ale#fixers#eslint#ProcessFixDryRunOutput(bufnr(''), ['[{"output": "foo\nbar"}]'])
Execute(The eslint_d post-processor should permit regular JavaScript content):
AssertEqual
\ [
\ 'const x = ''Error: foo''',
\ 'const y = 3',
\ ],
\ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
\ 'const x = ''Error: foo''',
\ 'const y = 3',
\ ])
Execute(The eslint_d post-processor should handle error messages correctly):
AssertEqual
\ [],
\ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
\ 'Error: No ESLint configuration found.',
\ ])
Execute(The eslint_d post-processor should handle failing to connect properly):
AssertEqual
\ [],
\ ale#fixers#eslint#ProcessEslintDOutput(bufnr(''), [
\ 'Could not connect',
\ ])

View File

@ -0,0 +1,24 @@
Before:
call ale#assert#SetUpFixerTest('javascript', 'fecs')
runtime autoload/ale/handlers/fecs.vim
After:
call ale#assert#TearDownFixerTest()
Execute(The fecs fixer should respect to g:ale_javascript_fecs_executable):
let g:ale_javascript_fecs_executable = '../test-files/fecs/fecs'
let g:ale_javascript_fecs_use_global = 1
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_javascript_fecs_executable) . ' format --replace=true %t',
\ 'read_temporary_file': 1,
\ },
\ ale#fixers#fecs#Fix(bufnr(''))
Execute(The fecs fixer should return 0 when executable not found):
let g:ale_javascript_fecs_executable = 'fecs-invalid'
let g:ale_javascript_fecs_use_global = 1
AssertEqual
\ 0,
\ ale#fixers#fecs#Fix(bufnr(''))

View File

@ -0,0 +1,40 @@
Before:
Save g:ale_fish_fish_indent_executable
Save g:ale_fish_fish_indent_options
" Use an invalid global executable, so we don't match it.
let g:ale_fish_fish_indent_executable = 'xxxinvalid'
let g:ale_fish_fish_indent_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The fish_indent callback should return the correct default values):
call ale#test#SetFilename('../test-files/fish/testfile.fish')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -w '
\ . ' %t',
\ },
\ ale#fixers#fish_indent#Fix(bufnr(''))
Execute(The fish_indent callback should include custom fish_indent options):
let g:ale_fish_fish_indent_options = "-d"
call ale#test#SetFilename('../test-files/fish/testfile.fish')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -w '
\ . ' -d'
\ . ' %t',
\ },
\ ale#fixers#fish_indent#Fix(bufnr(''))

View File

@ -0,0 +1,50 @@
Before:
Save g:ale_json_fixjson_executable
Save g:ale_json_fixjson_options
let g:ale_json_fixjson_executable = '/path/to/fixjson'
let g:ale_json_fixjson_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
Execute(The fixjson callback should return the correct default command):
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/fixjson')
\ . ' --stdin-filename '
\ . ale#Escape(bufname(bufnr('')))
\ },
\ ale#fixers#fixjson#Fix(bufnr(''))
Execute(The fixjson callback should set the buffer name as file name):
call ale#test#SetFilename('../test-files/json/testfile.json')
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/fixjson')
\ . ' --stdin-filename '
\ . ale#Escape(bufname(bufnr('')))
\ },
\ ale#fixers#fixjson#Fix(bufnr(''))
AssertNotEqual
\ stridx(
\ ale#fixers#fixjson#Fix(bufnr('')).command,
\ 'testfile.json',
\ ),
\ -1
Execute(The fixjson callback should include additional options):
let g:ale_json_fixjson_options = '-i 2'
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/fixjson')
\ . ' --stdin-filename '
\ . ale#Escape(bufname(bufnr('')))
\ . ' -i 2'
\ },
\ ale#fixers#fixjson#Fix(bufnr(''))

View File

@ -0,0 +1,23 @@
Before:
Save g:ale_haskell_floskell_executable
" Use an invalid global executable, so we don't match it.
let g:ale_haskell_floskell_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The floskell callback should return the correct default values):
call ale#test#SetFilename('../haskell_files/testfile.hs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' %t',
\ },
\ ale#fixers#floskell#Fix(bufnr(''))

View File

@ -0,0 +1,28 @@
Before:
call ale#assert#SetUpFixerTest('ada', 'gnatpp')
After:
" Reset fixers, variables, etc.
"
" Vader's 'Restore' command will be called here.
call ale#assert#TearDownFixerTest()
Execute(The default command should be correct):
call ale#test#SetFilename('../test-files/ada/testfile.adb')
AssertFixer
\ {
\ 'command': ale#Escape(g:ale_ada_gnatpp_executable) .' %t',
\ 'read_temporary_file': 1,
\ }
Execute(The version check should be correct):
call ale#test#SetFilename('../test-files/ada/testfile.adb')
let g:ale_ada_gnatpp_options = '--no-alignment'
AssertFixer
\ {
\ 'command': ale#Escape(g:ale_ada_gnatpp_executable)
\ . ' --no-alignment %t',
\ 'read_temporary_file': 1,
\ }

View File

@ -0,0 +1,50 @@
Before:
Save g:ale_go_gofmt_executable
Save g:ale_go_gofmt_options
Save g:ale_go_go111module
" Use an invalid global executable, so we don't match it.
let g:ale_go_gofmt_executable = 'xxxinvalid'
let g:ale_go_gofmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
unlet! b:ale_go_go111module
call ale#test#RestoreDirectory()
Execute(The gofmt callback should return the correct default values):
call ale#test#SetFilename('../test-files/go/testfile.go')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid'),
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))
Execute(The gofmt callback should include custom gofmt options):
let g:ale_go_gofmt_options = "-r '(a) -> a'"
call ale#test#SetFilename('../test-files/go/testfile.go')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_go_gofmt_options,
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))
Execute(The gofmt callback should support Go environment variables):
let g:ale_go_go111module = 'off'
call ale#test#SetFilename('../test-files/go/testfile.go')
AssertEqual
\ {
\ 'command': ale#Env('GO111MODULE', 'off')
\ . ale#Escape('xxxinvalid')
\ },
\ ale#fixers#gofmt#Fix(bufnr(''))

View File

@ -0,0 +1,27 @@
Before:
call ale#assert#SetUpFixerTest('go', 'gofumpt')
After:
call ale#assert#TearDownFixerTest()
Execute(The gofumpt callback should return the correct default values):
AssertFixer {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('gofumpt') . ' -w -- %t'
\}
Execute(The gofumpt callback should allow custom gofumpt executables):
let g:ale_go_gofumpt_executable = 'foo/bar'
AssertFixer {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('foo/bar') . ' -w -- %t'
\}
Execute(The gofumpt callback should allow custom gofumpt options):
let g:ale_go_gofumpt_options = '--foobar'
AssertFixer {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('gofumpt') . ' --foobar -w -- %t'
\}

View File

@ -0,0 +1,57 @@
Before:
Save g:ale_go_goimports_executable
Save g:ale_go_goimports_options
Save g:ale_go_go111module
" Use an invalid global executable, so we don't match it.
let g:ale_go_goimports_executable = 'xxxinvalid'
let g:ale_go_goimports_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
call ale#test#SetFilename('../test-files/go/testfile.go')
After:
Restore
unlet! b:ale_go_go111module
call ale#test#RestoreDirectory()
Execute(The goimports callback should return 0 when the executable isn't executable):
AssertEqual
\ 0,
\ ale#fixers#goimports#Fix(bufnr(''))
Execute(The goimports callback should the command when the executable test passes):
let g:ale_go_goimports_executable = has('win32') ? 'cmd' : 'echo'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w -srcdir %s %t'
\ },
\ ale#fixers#goimports#Fix(bufnr(''))
Execute(The goimports callback should include extra options):
let g:ale_go_goimports_executable = has('win32') ? 'cmd' : 'echo'
let g:ale_go_goimports_options = '--xxx'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_go_goimports_executable) . ' -l -w -srcdir %s --xxx %t'
\ },
\ ale#fixers#goimports#Fix(bufnr(''))
Execute(The goimports callback should support Go environment variables):
let g:ale_go_goimports_executable = has('win32') ? 'cmd' : 'echo'
let g:ale_go_go111module = 'on'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Env('GO111MODULE', 'on')
\ . ale#Escape(g:ale_go_goimports_executable)
\ . ' -l -w -srcdir %s %t'
\ },
\ ale#fixers#goimports#Fix(bufnr(''))

View File

@ -0,0 +1,54 @@
Before:
Save g:ale_go_golines_executable
Save g:ale_go_golines_options
Save g:ale_go_go111module
" Use an invalid global executable, so we don't match it.
let g:ale_go_golines_executable = 'xxxinvalid'
let g:ale_go_golines_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
unlet! b:ale_go_go111module
call ale#test#RestoreDirectory()
Execute(The golines callback should return 0 when the executable isn't executable):
AssertEqual
\ 0,
\ ale#fixers#golines#Fix(bufnr(''))
Execute(The golines callback should return the correct default values):
let g:ale_go_golines_executable = has('win32') ? 'cmd' : 'echo'
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_go_golines_executable),
\ },
\ ale#fixers#golines#Fix(bufnr(''))
Execute(The golines callback should include custom golines options):
let g:ale_go_golines_executable = has('win32') ? 'cmd' : 'echo'
let g:ale_go_golines_options = "--max-len --shorten-comments"
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_go_golines_executable)
\ . ' ' . g:ale_go_golines_options,
\ },
\ ale#fixers#golines#Fix(bufnr(''))
Execute(The golines callback should support Go environment variables):
let g:ale_go_golines_executable = has('win32') ? 'cmd' : 'echo'
let g:ale_go_go111module = 'off'
AssertEqual
\ {
\ 'command': ale#Env('GO111MODULE', 'off')
\ . ale#Escape(g:ale_go_golines_executable)
\ },
\ ale#fixers#golines#Fix(bufnr(''))

View File

@ -0,0 +1,41 @@
Before:
Save g:ale_go_go_executable
Save g:ale_go_go111module
" Use an invalid global executable, so we don't match it.
let g:ale_go_go_executable = 'xxxinvalid'
let g:ale_go_go111module = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
unlet! b:ale_go_go111module
call ale#test#RestoreDirectory()
Execute(The gomod callback should return the correct default values):
call ale#test#SetFilename('../test-files/go/go.mod')
setl filetype=gomod
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' mod edit -fmt'
\ . ' %t',
\ },
\ ale#fixers#gomod#Fix(bufnr(''))
Execute(The gomod callback should support Go environment variables):
call ale#test#SetFilename('../test-files/go/go.mod')
setl filetype=gomod
let g:ale_go_go111module = 'on'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Env('GO111MODULE', 'on')
\ . ale#Escape('xxxinvalid') . ' mod edit -fmt %t'
\ },
\ ale#fixers#gomod#Fix(bufnr(''))

View File

@ -0,0 +1,27 @@
Before:
Save g:ale_java_google_java_format_executable
" Use an invalid global executable, so we don't match it.
let g:ale_java_google_java_format_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The google-java-format callback should return 0 when the executable isn't executable):
AssertEqual
\ 0,
\ ale#fixers#google_java_format#Fix(bufnr(''))
Execute(The google-java-format callback should run the command when the executable test passes):
let g:ale_java_google_java_format_executable = has('win32') ? 'cmd' : 'echo'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(ale_java_google_java_format_executable) . ' --replace %t'
\ },
\ ale#fixers#google_java_format#Fix(bufnr(''))

View File

@ -0,0 +1,37 @@
Before:
Save g:ale_hack_hackfmt_executable
Save g:ale_hack_hackfmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_hack_hackfmt_executable = 'xxxinvalid'
let g:ale_hack_hackfmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The hackfmt callback should return the correct default values):
call ale#test#SetFilename('../hack_files/testfile.hack')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -i %t',
\ },
\ ale#fixers#hackfmt#Fix(bufnr(''))
Execute(The hackfmt callback should include custom hackfmt options):
let g:ale_hack_hackfmt_options = "--some-option"
call ale#test#SetFilename('../hack_files/testfile.hack')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -i --some-option %t',
\ },
\ ale#fixers#hackfmt#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_haskell_hfmt_executable
" Use an invalid global executable, so we don't match it.
let g:ale_haskell_hfmt_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The hfmt callback should return the correct default values):
call ale#test#SetFilename('../haskell_files/testfile.hs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -w'
\ . ' %t',
\ },
\ ale#fixers#hfmt#Fix(bufnr(''))

View File

@ -0,0 +1,18 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The hindent callback should return the correct default values):
call ale#test#SetFilename('../haskell_files/testfile.hs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('hindent')
\ . ' %t',
\ },
\ ale#fixers#hindent#Fix(bufnr(''))

View File

@ -0,0 +1,20 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The hlint callback should return the correct default values):
call ale#test#SetFilename('../haskell_files/testfile.hs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('hlint')
\ . ' --refactor'
\ . ' --refactor-options="--inplace"'
\ . ' %t',
\ },
\ ale#fixers#hlint#Fix(bufnr(''))

View File

@ -0,0 +1,12 @@
Before:
call ale#assert#SetUpFixerTest('html', 'html-beautify', 'beautify')
After:
Restore
call ale#assert#TearDownFixerTest()
Execute(The html-beautify callback should return the correct default command):
AssertEqual
\ {'command': ale#Escape('html-beautify') . ' -'},
\ ale#fixers#html_beautify#Fix(bufnr(''))

View File

@ -0,0 +1,35 @@
Before:
Save g:ale_javascript_importjs_executable
" Use an invalid global executable, so we don't match it.
let g:ale_javascript_importjs_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
call ale#test#SetFilename('../test-files/javascript/test.js')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The importjs callback should return 0 when the executable isn't executable):
AssertEqual
\ 0,
\ ale#fixers#importjs#Fix(bufnr(''))
Execute(The importjs callback should run the command when the executable test passes):
let g:ale_javascript_importjs_executable = has('win32') ? 'cmd' : 'echo'
AssertEqual
\ {
\ 'process_with': 'ale#fixers#importjs#ProcessOutput',
\ 'command': ale#Escape(g:ale_javascript_importjs_executable) . ' fix %s'
\ },
\ ale#fixers#importjs#Fix(bufnr(''))
Execute(The ProcessOutput callback should return the expected output):
let g:testOutput = '{"messages":[],"fileContent":"one\ntwo","unresolvedImports":{}}'
AssertEqual
\ ['one', 'two'],
\ ale#fixers#importjs#ProcessOutput(bufnr(''), g:testOutput)

View File

@ -0,0 +1,70 @@
Before:
call ale#assert#SetUpFixerTest('python', 'isort')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
call ale#assert#TearDownFixerTest()
unlet! g:dir
unlet! b:bin_dir
Execute(The isort callback should return the correct default values):
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
" --filename option exists only after 5.7.0
GivenCommandOutput ['VERSION 5.7.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/isort')) . ' --filename %s' . ' -',
\ }
Execute(The isort callback should respect custom options):
let g:ale_python_isort_options = '--multi-line=3 --trailing-comma'
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
" --filename option exists only after 5.7.0
GivenCommandOutput ['VERSION 5.7.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/isort'))
\ . ' --filename %s' . ' --multi-line=3 --trailing-comma -',
\ }
Execute(Pipenv is detected when python_isort_auto_pipenv is set):
let g:ale_python_isort_auto_pipenv = 1
call ale#test#SetFilename('../test-files/python/pipenv/whatever.py')
GivenCommandOutput ['VERSION 5.7.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape('pipenv') . ' run isort' . ' --filename %s' . ' -'
\ }
Execute(Poetry is detected when python_isort_auto_poetry is set):
let g:ale_python_isort_auto_poetry = 1
call ale#test#SetFilename('../test-files/python/poetry/whatever.py')
GivenCommandOutput ['VERSION 5.7.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape('poetry') . ' run isort' . ' --filename %s' . ' -'
\ }
Execute(The isort callback should not use --filename for older versions):
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
" --filename option exists only after 5.7.0
GivenCommandOutput ['VERSION 5.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/' . b:bin_dir . '/isort')) . ' -',
\ }

View File

@ -0,0 +1,26 @@
Before:
Save g:ale_json_jq_executable
Save g:ale_json_jq_options
Save g:ale_json_jq_filters
After:
Restore
Execute(The jq fixer should use the options you set):
let g:ale_json_jq_executable = 'foo'
let g:ale_json_jq_options = '--bar'
let g:ale_json_jq_filters = '.baz'
AssertEqual
\ {'command': ale#Escape('foo') . ' .baz --bar'},
\ ale#fixers#jq#Fix(bufnr(''))
Execute(The jq fixer should return 0 when there are no filters):
let g:ale_json_jq_executable = 'jq'
let g:ale_json_jq_options = ''
let g:ale_json_jq_filters = ''
AssertEqual
\ 0,
\ ale#fixers#jq#Fix(bufnr(''))

View File

@ -0,0 +1,38 @@
Before:
Save g:ale_jsonnet_jsonnetfmt_executable
Save g:ale_jsonnet_jsonnetfmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_jsonnet_jsonnetfmt_executable = 'xxxinvalid'
let g:ale_jsonnet_jsonnetfmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
call ale#assert#SetUpFixerTest('jsonnet', 'jsonnetfmt')
After:
call ale#test#RestoreDirectory()
call ale#assert#TearDownFixerTest()
Execute(The jsonnetfmt callback should return the correct default values):
call ale#test#SetFilename('../jsonnet_files/testfile.jsonnet')
AssertFixer {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_jsonnet_jsonnetfmt_executable)
\ . ' -i'
\ . ' %t',
\}
Execute(The jsonnetfmt callback should include custom options):
let g:ale_jsonnet_jsonnetfmt_options = '--pad-arrays'
call ale#test#SetFilename('../jsonnet_files/testfile.jsonnet')
AssertFixer {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_jsonnet_jsonnetfmt_executable)
\ . ' -i'
\ . ' ' . g:ale_jsonnet_jsonnetfmt_options
\ . ' %t',
\}

View File

@ -0,0 +1,42 @@
Before:
Save g:ale_kotlin_ktlint_executable
Save g:ale_kotlin_ktlint_options
Save g:ale_kotlin_ktlint_rulesets
" Use an invalid global executable, so we don't match it.
let g:ale_kotlin_ktlint_executable = 'xxxinvalid'
let g:ale_kotlin_ktlint_options = ''
let g:ale_kotlin_ktlint_rulesets = []
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The ktlint callback should return the correct default values):
call ale#test#SetFilename('../test-files/kotlin/testfile.kt')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' --stdin'
\ . ' --format',
\ },
\ ale#fixers#ktlint#Fix(bufnr(''))
Execute(The ktlint callback should include custom ktlint options):
let g:ale_kotlin_ktlint_options = "--android"
let g:ale_kotlin_ktlint_rulesets = ['/path/to/custom/ruleset.jar']
call ale#test#SetFilename('../test-files/kotlin/testfile.kt')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_kotlin_ktlint_options
\ . ' --ruleset /path/to/custom/ruleset.jar'
\ . ' --stdin'
\ . ' --format',
\ },
\ ale#fixers#ktlint#Fix(bufnr(''))

View File

@ -0,0 +1,36 @@
Before:
Save g:ale_tex_latexindent_executable
Save g:ale_tex_latexindent_options
" Use an invalid global executable, so we don't match it.
let g:ale_tex_latexindent_executable = 'xxxinvalid'
let g:ale_tex_latexindent_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The latexindent callback should return the correct default values):
call ale#test#SetFilename('../test-files/tex/testfile.tex')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' -l'
\ },
\ ale#fixers#latexindent#Fix(bufnr(''))
Execute(The latexindent callback should include custom gofmt options):
let g:ale_tex_latexindent_options = "-l '~/.indentconfig.yaml'"
call ale#test#SetFilename('../test-files/tex/testfile.tex')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' -l'
\ . ' ' . g:ale_tex_latexindent_options
\ },
\ ale#fixers#latexindent#Fix(bufnr(''))

View File

@ -0,0 +1,35 @@
Before:
Save g:ale_lua_lua_format_executable
Save g:ale_lua_lua_format_options
" Use an invalid global executable, so we don't match it.
let g:ale_lua_lua_format_executable = 'xxxinvalid'
let g:ale_lua_lua_format_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The lua_format callback should return the correct default values):
call ale#test#SetFilename('../test-files/lua/testfile.lua')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid') . ' -i',
\ },
\ ale#fixers#lua_format#Fix(bufnr(''))
Execute(The lua_format callback should include custom lua_format options):
let g:ale_lua_lua_format_options = "--no-chop-down-table"
call ale#test#SetFilename('../test-files/lua/testfile.lua')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_lua_lua_format_options
\ . ' -i',
\ },
\ ale#fixers#lua_format#Fix(bufnr(''))

View File

@ -0,0 +1,35 @@
Before:
Save g:ale_lua_luafmt_executable
Save g:ale_lua_luafmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_lua_luafmt_executable = 'xxxinvalid'
let g:ale_lua_luafmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The luafmt callback should return the correct default values):
call ale#test#SetFilename('../test-files/lua/testfile.lua')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid') . ' --stdin',
\ },
\ ale#fixers#luafmt#Fix(bufnr(''))
Execute(The luafmt callback should include custom luafmt options):
let g:ale_lua_luafmt_options = "--skip-children"
call ale#test#SetFilename('../test-files/lua/testfile.lua')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_lua_luafmt_options
\ . ' --stdin',
\ },
\ ale#fixers#luafmt#Fix(bufnr(''))

View File

@ -0,0 +1,36 @@
Before:
Save g:ale_elixir_mix_executable
Save g:ale_elixir_mix_format_options
let g:ale_elixir_mix_executable = 'xxxinvalid'
let g:ale_elixir_mix_format_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The mix_format callback should return the correct default values):
call ale#test#SetFilename('../test-files/elixir/testfile.ex')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' format %t',
\ },
\ ale#fixers#mix_format#Fix(bufnr(''))
Execute(The mix_format callback should include the correct format options):
let g:ale_elixir_mix_format_options = 'invalid_options'
call ale#test#SetFilename('../test-files/elixir/testfile.ex')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' format invalid_options %t',
\ },
\ ale#fixers#mix_format#Fix(bufnr(''))

View File

@ -0,0 +1,23 @@
Before:
call ale#assert#SetUpFixerTest('nim', 'nimpretty')
After:
call ale#assert#TearDownFixerTest()
Execute(The nimpretty callback should return the correct default values):
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('nimpretty') . ' %t --maxLineLen:80'
\ },
\ ale#fixers#nimpretty#Fix(bufnr(''))
Execute(The nimpretty callback should include any additional options):
let g:ale_nim_nimpretty_options = '--some-option'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('nimpretty') . ' %t --some-option'
\ },
\ ale#fixers#nimpretty#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_nix_nixfmt_executable
Save g:ale_nix_nixfmt_options
After:
Restore
Execute(The nixfmt callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('nixfmt')
\ },
\ ale#fixers#nixfmt#Fix(bufnr(''))
Execute(The nixfmt executable and options should be configurable):
let g:ale_nix_nixfmt_executable = '/path/to/nixfmt'
let g:ale_nix_nixfmt_options = '--help'
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/nixfmt')
\ . ' --help',
\ },
\ ale#fixers#nixfmt#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_nix_nixpkgsfmt_executable
Save g:ale_nix_nixpkgsfmt_options
After:
Restore
Execute(The nixpkgs-fmt callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('nixpkgs-fmt')
\ },
\ ale#fixers#nixpkgsfmt#Fix(bufnr(''))
Execute(The nixpkgs-fmt executable and options should be configurable):
let g:ale_nix_nixpkgsfmt_executable = '/path/to/nixpkgs-fmt'
let g:ale_nix_nixpkgsfmt_options = '-h'
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/nixpkgs-fmt')
\ . ' -h',
\ },
\ ale#fixers#nixpkgsfmt#Fix(bufnr(''))

View File

@ -0,0 +1,36 @@
Before:
Save g:ale_ocaml_ocamlformat_executable
Save g:ale_ocaml_ocamlformat_options
" Use an invalid global executable, so we don't match it.
let g:ale_ocaml_ocamlformat_executable = 'xxxinvalid'
let g:ale_ocaml_ocamlformat_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The ocamlformat callback should return the correct default values):
call ale#test#SetFilename('../test-files/ocaml/testfile.re')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' --name=%s -',
\ },
\ ale#fixers#ocamlformat#Fix(bufnr(''))
Execute(The ocamlformat callback should include custom ocamlformat options):
let g:ale_ocaml_ocamlformat_options = "-m 78"
call ale#test#SetFilename('../test-files/ocaml/testfile.re')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_ocaml_ocamlformat_options
\ . ' --name=%s -',
\ },
\ ale#fixers#ocamlformat#Fix(bufnr(''))

View File

@ -0,0 +1,34 @@
Before:
Save g:ale_ocaml_ocp_indent_executable
Save g:ale_ocaml_ocpindent_options
" Use an invalid global executable
let g:ale_ocaml_ocp_indent_executable = 'xxxinvalid'
let g:ale_ocaml_ocp_indent_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The ocp_indent callback should return the correct default values):
call ale#test#SetFilename('../test-files/ocaml/ocp_inden_testfile.re')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ },
\ ale#fixers#ocp_indent#Fix(bufnr(''))
Execute(The ocp_indent callback should include custom ocp_indent options):
let g:ale_ocaml_ocp_indent_config = "base=4, type=4"
call ale#test#SetFilename('../test-files/ocaml/ocp_inden_testfile.re')
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' --config=' . ale#Escape(g:ale_ocaml_ocp_indent_config)
\ },
\ ale#fixers#ocp_indent#Fix(bufnr(''))

View File

@ -0,0 +1,33 @@
Before:
Save g:ale_opa_fmt_executable
Save g:ale_opa_fmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_opa_fmt_executable = 'xxxinvalid'
let g:ale_opa_fmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The opa fmt callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid') . ' fmt',
\ },
\ ale#fixers#opafmt#Fix(bufnr(''))
Execute(The opa fmt callback should include custom options):
let g:ale_opa_fmt_options = "--list"
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' fmt'
\ . ' ' . g:ale_opa_fmt_options
\ },
\ ale#fixers#opafmt#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_haskell_ormolu_executable
Save g:ale_haskell_ormolu_options
After:
Restore
Execute(The ormolu callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('ormolu')
\ },
\ ale#fixers#ormolu#Fix(bufnr(''))
Execute(The ormolu executable and options should be configurable):
let g:ale_nix_nixpkgsfmt_executable = '/path/to/ormolu'
let g:ale_nix_nixpkgsfmt_options = '-h'
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/ormolu')
\ . ' -h',
\ },
\ ale#fixers#nixpkgsfmt#Fix(bufnr(''))

View File

@ -0,0 +1,34 @@
Before:
Save g:ale_packer_fmt_executable
Save g:ale_packer_fmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_packer_fmt_executable = 'xxxinvalid'
let g:ale_packer_fmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The packer fmt callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid') . ' fmt -',
\ },
\ ale#fixers#packer#Fix(bufnr(''))
Execute(The packer fmt callback should include custom options):
let g:ale_packer_fmt_options = "-list=true"
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' fmt'
\ . ' ' . g:ale_packer_fmt_options
\ . ' -',
\ },
\ ale#fixers#packer#Fix(bufnr(''))

View File

@ -0,0 +1,23 @@
Before:
Save g:ale_markdown_pandoc_executable
Save g:ale_markdown_pandoc_options
After:
Restore
Execute(The pandoc callback should return 'pandoc' as default command):
setlocal noexpandtab
Assert
\ ale#fixers#pandoc#Fix(bufnr('')).command =~# '^' . ale#Escape('pandoc'),
\ "Default command name is expected to be 'pandoc'"
Execute(The pandoc executable and options should be configurable):
let g:ale_markdown_pandoc_executable = 'foobar'
let g:ale_markdown_pandoc_options = '--some-option'
AssertEqual
\ {
\ 'command': ale#Escape('foobar')
\ . ' --some-option',
\ },
\ ale#fixers#pandoc#Fix(bufnr(''))

View File

@ -0,0 +1,40 @@
Before:
Save g:ale_perl_perltidy_executable
Save g:ale_perl_perltidy_options
" Use an invalid global executable, so we don't match it.
let g:ale_perl_perltidy_executable = 'xxxinvalid'
let g:ale_perl_perltidy_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The perltidy callback should return the correct default values):
call ale#test#SetFilename('../pl_files/testfile.pl')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -b'
\ . ' %t',
\ },
\ ale#fixers#perltidy#Fix(bufnr(''))
Execute(The perltidy callback should include custom perltidy options):
let g:ale_perl_perltidy_options = "-r '(a) -> a'"
call ale#test#SetFilename('../pl_files/testfile.pl')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' -b'
\ . ' ' . g:ale_perl_perltidy_options
\ . ' %t',
\ },
\ ale#fixers#perltidy#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_sql_pgformatter_executable
Save g:ale_sql_pgformatter_options
After:
Restore
Execute(The pgFormatter callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('pg_format')
\ },
\ ale#fixers#pgformatter#Fix(bufnr(''))
Execute(The pgFormatter executable and options should be configurable):
let g:ale_sql_pgformatter_executable = '/path/to/pg_format'
let g:ale_sql_pgformatter_options = '-n'
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/pg_format')
\ . ' -n',
\ },
\ ale#fixers#pgformatter#Fix(bufnr(''))

View File

@ -0,0 +1,62 @@
Before:
Save g:ale_php_cs_fixer_executable
Save g:ale_php_cs_fixer_options
let g:ale_php_cs_fixer_executable = 'php-cs-fixer'
let g:ale_php_cs_fixer_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(project with php-cs-fixer should use local by default):
call ale#test#SetFilename('../test-files/php/project-with-php-cs-fixer/test.php')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/php/project-with-php-cs-fixer/vendor/bin/php-cs-fixer'),
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
Execute(use-global should override local detection):
let g:ale_php_cs_fixer_use_global = 1
call ale#test#SetFilename('../test-files/php/project-with-php-cs-fixer/test.php')
AssertEqual
\ 'php-cs-fixer',
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
Execute(project without php-cs-fixer should use global):
call ale#test#SetFilename('../test-files/php/project-without-php-cs-fixer/test.php')
AssertEqual
\ 'php-cs-fixer',
\ ale#fixers#php_cs_fixer#GetExecutable(bufnr(''))
Execute(The php-cs-fixer callback should return the correct default values):
call ale#test#SetFilename('../test-files/php/project-without-php-cs-fixer/foo/test.php')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('php-cs-fixer')
\ . ' ' . g:ale_php_cs_fixer_options
\ . ' fix %t'
\ },
\ ale#fixers#php_cs_fixer#Fix(bufnr(''))
Execute(The php-cs-fixer callback should include custom php-cs-fixer options):
let g:ale_php_cs_fixer_options = '--config="$HOME/.php_cs"'
call ale#test#SetFilename('../test-files/php/project-without-php-cs-fixer/test.php')
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_php_cs_fixer_executable)
\ . ' --config="$HOME/.php_cs" fix %t',
\ 'read_temporary_file': 1,
\ },
\ ale#fixers#php_cs_fixer#Fix(bufnr(''))

View File

@ -0,0 +1,117 @@
Before:
Save g:ale_php_phpcbf_executable
Save g:ale_php_phpcbf_standard
Save g:ale_php_phpcbf_use_global
let g:ale_php_phpcbf_executable = 'phpcbf_test'
let g:ale_php_phpcbf_standard = ''
let g:ale_php_phpcbf_options = ''
let g:ale_php_phpcbf_use_global = 0
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(project with phpcbf should use local by default):
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/php/project-with-phpcbf/vendor/bin/phpcbf'),
\ ale#fixers#phpcbf#GetExecutable(bufnr(''))
Execute(use-global should override local detection):
let g:ale_php_phpcbf_use_global = 1
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ 'phpcbf_test',
\ ale#fixers#phpcbf#GetExecutable(bufnr(''))
Execute(project without phpcbf should use global):
call ale#test#SetFilename('../test-files/php/project-without-phpcbf/foo/test.php')
AssertEqual
\ 'phpcbf_test',
\ ale#fixers#phpcbf#GetExecutable(bufnr(''))
Execute(The phpcbf callback should return the correct default values):
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/php/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s -' },
\ ale#fixers#phpcbf#Fix(bufnr(''))
Execute(The phpcbf callback should include the phpcbf_standard option):
let g:ale_php_phpcbf_standard = 'phpcbf_ruleset.xml'
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/php/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml' . ' -'},
\ ale#fixers#phpcbf#Fix(bufnr(''))
Execute(User provided options should be used):
let g:ale_php_phpcbf_options = '--my-user-provided-option my-value'
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/php/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . ale#Pad('--my-user-provided-option my-value') . ' -'},
\ ale#fixers#phpcbf#Fix(bufnr(''))
Before:
Save g:ale_php_phpcbf_executable
Save g:ale_php_phpcbf_standard
Save g:ale_php_phpcbf_use_global
let g:ale_php_phpcbf_executable = 'phpcbf_test'
let g:ale_php_phpcbf_standard = ''
let g:ale_php_phpcbf_options = ''
let g:ale_php_phpcbf_use_global = 0
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(project with phpcbf should use local by default):
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ ale#path#Simplify(g:dir . '/../test-files/php/project-with-phpcbf/vendor/bin/phpcbf'),
\ ale#fixers#phpcbf#GetExecutable(bufnr(''))
Execute(use-global should override local detection):
let g:ale_php_phpcbf_use_global = 1
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ 'phpcbf_test',
\ ale#fixers#phpcbf#GetExecutable(bufnr(''))
Execute(project without phpcbf should use global):
call ale#test#SetFilename('../test-files/php/project-without-phpcbf/foo/test.php')
AssertEqual
\ 'phpcbf_test',
\ ale#fixers#phpcbf#GetExecutable(bufnr(''))
Execute(The phpcbf callback should return the correct default values):
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/php/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s -' },
\ ale#fixers#phpcbf#Fix(bufnr(''))
Execute(The phpcbf callback should include the phpcbf_standard option):
let g:ale_php_phpcbf_standard = 'phpcbf_ruleset.xml'
call ale#test#SetFilename('../test-files/php/project-with-phpcbf/foo/test.php')
AssertEqual
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/php/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml' . ' -'},
\ ale#fixers#phpcbf#Fix(bufnr(''))

View File

@ -0,0 +1,97 @@
Before:
call ale#assert#SetUpFixerTest('javascript', 'prettier_eslint')
Save g:ale_command_wrapper
let g:ale_command_wrapper = ''
After:
call ale#assert#TearDownFixerTest()
Execute(The default command should be correct):
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --write'
\ }
Execute(Additional options should be used when set):
let b:ale_javascript_prettier_eslint_options = '--foobar'
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --foobar --write'
\ }
Execute(--eslint-config-path should be set for 4.2.0 and up):
call ale#test#SetFilename('../test-files/eslint/react-app/foo/bar.js')
GivenCommandOutput ['4.2.0']
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --eslint-config-path ' . ale#Escape(ale#test#GetFilename('../test-files/eslint/react-app/.eslintrc.js'))
\ . ' --write'
\ }
Execute(--eslint-config-path shouldn't be used for older versions):
call ale#test#SetFilename('../test-files/eslint/react-app/foo/bar.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --write'
\ }
Execute(The version check should be correct):
AssertFixer [
\ ale#Escape('prettier-eslint') . ' --version',
\ {
\ 'read_temporary_file': 1,
\ 'command':
\ ale#Escape('prettier-eslint')
\ . ' %t'
\ . ' --write'
\ }
\]
Execute(The new --stdin-filepath option should be used when the version is new enough):
call ale#test#SetFilename('../test-files/eslint/react-app/foo/bar.js')
GivenCommandOutput ['4.4.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape('prettier-eslint')
\ . ' --eslint-config-path ' . ale#Escape(ale#test#GetFilename('../test-files/eslint/react-app/.eslintrc.js'))
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(The version number should be cached):
GivenCommandOutput ['4.4.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape('prettier-eslint')
\ . ' --stdin-filepath %s --stdin',
\ }
GivenCommandOutput []
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape('prettier-eslint')
\ . ' --stdin-filepath %s --stdin',
\ }

View File

@ -0,0 +1,337 @@
Before:
call ale#assert#SetUpFixerTest('javascript', 'prettier')
Save g:ale_command_wrapper
let g:ale_command_wrapper = ''
After:
call ale#assert#TearDownFixerTest()
Execute(The prettier callback should return the correct default values):
call ale#test#SetFilename('../test-files/prettier/testfile.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --write',
\ }
Execute(The --config option should not be set automatically):
let g:ale_javascript_prettier_use_local_config = 1
call ale#test#SetFilename('../test-files/prettier/with_config/testfile.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --write',
\ }
Execute(The prettier callback should include custom prettier options):
let g:ale_javascript_prettier_options = '--no-semi'
call ale#test#SetFilename('../test-files/prettier/with_config/testfile.js')
AssertFixer
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' %t'
\ . ' --no-semi'
\ . ' --write',
\ }
Execute(The version check should be correct):
call ale#test#SetFilename('../test-files/prettier/testfile.js')
AssertFixer [
\ ale#Escape('prettier') . ' --version',
\ {'read_temporary_file': 1, 'command': ale#Escape('prettier') . ' %t --write'}
\]
Execute(--stdin-filepath should be used when prettier is new enough):
let g:ale_javascript_prettier_options = '--no-semi'
call ale#test#SetFilename('../test-files/prettier/with_config/testfile.js')
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --no-semi'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(The version number should be cached):
call ale#test#SetFilename('../test-files/prettier/with_config/testfile.js')
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --stdin-filepath %s --stdin',
\ }
GivenCommandOutput []
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser to `babylon` by default, < 1.16.0):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=javascript
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser babylon'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser to `babel` by default, >= 1.16.0):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=javascript
GivenCommandOutput ['1.16.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser babel'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, TypeScript):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=typescript
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser typescript'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, CSS):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=css
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser css'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, LESS):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=less
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser less'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, SCSS):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=scss
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser scss'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, JSON):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=json
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser json'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, JSON5):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=json5
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser json5'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, GraphQL):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=graphql
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser graphql'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, Markdown):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=markdown
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser markdown'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, Vue):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=vue
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser vue'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, YAML):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=yaml
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser yaml'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, HTML):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=html
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser html'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on filetype, Ruby):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=ruby
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser ruby'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser based on first filetype of multiple filetypes):
call ale#test#SetFilename('../test-files/prettier/testfile')
set filetype=css.scss
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser css'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Should set --parser for experimental language, Handlebars):
call ale#test#SetFilename('../test-files/prettier/testfile.hbs')
set filetype=html.handlebars
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': '%s:h',
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --parser glimmer'
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(Changes to directory where .prettierignore is found):
call ale#test#SetFilename('../test-files/prettier/with_prettierignore/src/testfile.js')
GivenCommandOutput ['1.6.0']
AssertFixer
\ {
\ 'cwd': expand('%:p:h:h'),
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
\ . ' --stdin-filepath %s --stdin',
\ }
Execute(The prettier_d post-processor should permit regular JavaScript content):
AssertEqual
\ [
\ 'const x = ''Error: foo''',
\ 'const y = 3',
\ ],
\ ale#fixers#prettier#ProcessPrettierDOutput(bufnr(''), [
\ 'const x = ''Error: foo''',
\ 'const y = 3',
\ ])
Execute(The prettier_d post-processor should handle error messages correctly):
AssertEqual
\ [],
\ ale#fixers#prettier#ProcessPrettierDOutput(bufnr(''), [
\ 'SyntaxError: Unexpected token, expected "," (36:28)',
\ ])

View File

@ -0,0 +1,15 @@
Before:
call ale#assert#SetUpFixerTest('javascript', 'prettier_standard')
After:
call ale#assert#TearDownFixerTest()
Execute(The prettier callback should return the correct default values):
call ale#test#SetFilename('../test-files/prettier/testfile.js')
AssertFixer
\ {
\ 'command': ale#Escape(g:ale_javascript_prettier_standard_executable)
\ . ' --stdin'
\ . ' --stdin-filepath=%s ',
\ }

View File

@ -0,0 +1,28 @@
Before:
call ale#assert#SetUpFixerTest('proto', 'protolint')
call ale#test#SetFilename('test.proto')
After:
call ale#assert#TearDownFixerTest()
Execute(The default command should be correct):
AssertFixer
\ {
\ 'command': ale#Escape('protolint')
\ . ' -fix'
\ . ' %t',
\ 'read_temporary_file': 1,
\ }
Execute(The callback should include any additional options):
let b:ale_proto_protolint_executable = '/tmp/protolint'
let b:ale_proto_protolint_config = '/tmp/protolint.yaml'
AssertFixer
\ {
\ 'command': ale#Escape('/tmp/protolint')
\ . ' -config_path=' . ale#Escape('/tmp/protolint.yaml')
\ . ' -fix'
\ . ' %t',
\ 'read_temporary_file': 1,
\ }

View File

@ -0,0 +1,38 @@
Before:
Save g:ale_pascal_ptop_executable
Save g:ale_pascal_ptop_options
" Use an invalid global executable, so we don't match it.
let g:ale_pascal_ptop_executable = 'xxxinvalid'
let g:ale_pascal_ptop_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The ptop callback should return the correct default values):
call ale#test#SetFilename('../test-files/pascal/test.pas')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' %s %t',
\ },
\ ale#fixers#ptop#Fix(bufnr(''))
Execute(The ptop callback should include custom ptop options):
let g:ale_pascal_ptop_options = "-i 2"
call ale#test#SetFilename('../test-files/pascal/test.pas')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_pascal_ptop_options
\ . ' %s %t',
\ },
\ ale#fixers#ptop#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_puppet_puppetlint_executable
Save g:ale_puppet_puppetlint_options
" Use an invalid global executable, so we don't match it.
let g:ale_puppet_puppetlint_executable = 'xxxinvalid'
let g:ale_puppet_puppetlint_options = '--invalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The puppetlint callback should return the correct default values):
silent execute 'file ' . fnameescape(g:dir . '/../test-files/puppet/dummy.pp')
AssertEqual
\ {'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_puppet_puppetlint_executable)
\ . ' ' . g:ale_puppet_puppetlint_options
\ . ' --fix %t' },
\ ale#fixers#puppetlint#Fix(bufnr(''))

View File

@ -0,0 +1,20 @@
Before:
Save g:ale_purescript_tidy_executable
Save g:ale_purescript_tidy_options
" Use an invalid global executable, so we dont match it.
let g:ale_purescript_tidy_executable = 'odd-purs-tidy'
let g:ale_purescript_tidy_options = '--indent 3'
call ale#assert#SetUpFixerTest('purescript', 'purs-tidy')
After:
call ale#assert#TearDownFixerTest()
Execute(The purs-tidy callback should return the correct custom options):
AssertFixer
\ {
\ 'command': ale#Escape('odd-purs-tidy')
\ . ' format'
\ . ' --indent 3'
\ }

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_purescript_purty_executable
" Use an invalid global executable, so we don't match it.
let g:ale_purescript_purty_executable = 'my-special-purty'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The purty callback should return the correct options):
call ale#test#SetFilename('../purescript_files/testfile.purs')
AssertEqual
\ {
\ 'command': ale#Escape('my-special-purty')
\ . ' --write'
\ . ' %t',
\ 'read_temporary_file': 1,
\ },
\ ale#fixers#purty#Fix(bufnr(''))

View File

@ -0,0 +1,167 @@
Before:
Save g:ale_fixers
After:
Restore
Given python(Some Python without blank lines):
def foo():
""" This is a simple test docstring """
return 1
def bar():
'''This is another simple test docstring'''
return 1
return 4
def bar():
"""
This is a multi-line
docstring
"""
if x:
pass
for l in x:
pass
for l in x:
pass
break
continue
elif x:
pass
while x:
pass
while x:
pass
else:
pass
if x:
pass
elif x:
pass
else:
pass
Execute(Blank lines should be added appropriately):
let g:ale_fixers = {'python': ['add_blank_lines_for_python_control_statements']}
ALEFix
Expect python(Newlines should be added):
def foo():
""" This is a simple test docstring """
return 1
def bar():
'''This is another simple test docstring'''
return 1
return 4
def bar():
"""
This is a multi-line
docstring
"""
if x:
pass
for l in x:
pass
for l in x:
pass
break
continue
elif x:
pass
while x:
pass
while x:
pass
else:
pass
if x:
pass
elif x:
pass
else:
pass
Given python(A file with a main block):
import os
def main():
print('hello')
if __name__ == '__main__':
main()
Execute(Fix the file):
let g:ale_fixers = {'python': ['add_blank_lines_for_python_control_statements']}
ALEFix
Expect python(extra newlines shouldn't be added to the main block):
import os
def main():
print('hello')
if __name__ == '__main__':
main()
Given python(A file with variables/docstring that start with a control statement):
def some():
"""
This is a docstring that contains an
break control statement and also contains a
return something funny.
"""
continue_some_var = True
forward_something = False
if (
continue_some_var and
forwarded_something
):
return True
Execute(Fix the file):
let g:ale_fixers = {'python': ['add_blank_lines_for_python_control_statements']}
ALEFix
Expect python(Extra new lines are not added to the file):
def some():
"""
This is a docstring that contains an
break control statement and also contains a
return something funny.
"""
continue_some_var = True
forward_something = False
if (
continue_some_var and
forwarded_something
):
return True

View File

@ -0,0 +1,12 @@
Before:
Save g:ale_qml_qmlfmt_executable
After:
Restore
Execute(The qmlfmt fixer should use the options you set):
let g:ale_qml_qmlfmt_executable = 'foo-exe'
AssertEqual
\ {'command': ale#Escape('foo-exe')},
\ ale#fixers#qmlfmt#Fix(bufnr(''))

View File

@ -0,0 +1,41 @@
Before:
Save g:ale_reasonml_refmt_executable
Save g:ale_reasonml_refmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_reasonml_refmt_executable = 'xxxinvalid'
let g:ale_reasonml_refmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The refmt callback should return the correct default values):
call ale#test#SetFilename('../test-files/reasonml/testfile.re')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' --in-place'
\ . ' %t',
\ },
\ ale#fixers#refmt#Fix(bufnr(''))
Execute(The refmt callback should include custom refmt options):
let g:ale_reasonml_refmt_options = "-w 80"
call ale#test#SetFilename('../test-files/reasonml/testfile.re')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_reasonml_refmt_options
\ . ' --in-place'
\ . ' %t',
\ },
\ ale#fixers#refmt#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_markdown_remark_lint_executable
Save g:ale_markdown_remark_lint_options
After:
Restore
Execute(The remark callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('remark')
\ },
\ ale#fixers#remark_lint#Fix(bufnr(''))
Execute(The remark executable and options should be configurable):
let g:ale_markdown_remark_lint_executable = '/path/to/remark'
let g:ale_markdown_remark_lint_options = '-h'
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/remark')
\ . ' -h',
\ },
\ ale#fixers#remark_lint#Fix(bufnr(''))

View File

@ -0,0 +1,46 @@
Before:
Save g:ale_python_reorder_python_imports_executable
Save g:ale_python_reorder_python_imports_options
" Use an invalid global executable, so we don't match it.
let g:ale_python_reorder_python_imports_executable = 'xxxinvalid'
let g:ale_python_reorder_python_imports_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
After:
Restore
unlet! b:bin_dir
call ale#test#RestoreDirectory()
Execute(The reorder_python_imports callback should return the correct default values):
AssertEqual
\ 0,
\ ale#fixers#reorder_python_imports#Fix(bufnr(''))
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/'
\ . b:bin_dir . '/reorder-python-imports')) . ' -',
\ },
\ ale#fixers#reorder_python_imports#Fix(bufnr(''))
Execute(The reorder_python_imports callback should respect custom options):
let g:ale_python_reorder_python_imports_options = '--py3-plus'
AssertEqual
\ 0,
\ ale#fixers#reorder_python_imports#Fix(bufnr(''))
silent execute 'file ' . fnameescape(g:dir . '/../test-files/python/with_virtualenv/subdir/foo/bar.py')
AssertEqual
\ {
\ 'command': ale#Escape(ale#path#Simplify(g:dir . '/../test-files/python/with_virtualenv/env/'
\ . b:bin_dir . '/reorder-python-imports')) . ' --py3-plus -',
\ },
\ ale#fixers#reorder_python_imports#Fix(bufnr(''))

View File

@ -0,0 +1,89 @@
Before:
Save g:ale_ruby_rubocop_executable
Save g:ale_ruby_rubocop_options
" Use an invalid global executable, so we don't match it.
let g:ale_ruby_rubocop_executable = 'xxxinvalid'
let g:ale_ruby_rubocop_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The rubocop callback should return the correct default values):
call ale#test#SetFilename('../test-files/ruby/dummy.rb')
AssertEqual
\ {
\ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
\ . ' --auto-correct --force-exclusion --stdin %s',
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
Execute(The rubocop callback should include custom rubocop options):
let g:ale_ruby_rubocop_options = '--except Lint/Debugger'
call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')
AssertEqual
\ {
\ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
\ . ' --except Lint/Debugger'
\ . ' --auto-correct --force-exclusion --stdin %s',
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
Execute(The rubocop callback should use auto-correct-all option when set):
let g:ale_ruby_rubocop_auto_correct_all = 1
call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')
AssertEqual
\ {
\ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
\ . ' --auto-correct-all --force-exclusion --stdin %s'
\ },
\ ale#fixers#rubocop#Fix(bufnr(''))
Execute(The rubocop post-processor should remove diagnostics content):
AssertEqual
\ [
\ 'class MyModel < ApplicationRecord',
\ ' # rubocop:disable Rails/InverseOf',
\ ' has_one :something',
\ ' # rubocop:enable Rails/InverseOf',
\ 'end',
\ '',
\ 'array = [1, 2, 3,',
\ ' 4, 5, 6]',
\ 'array = [''run'',',
\ ' ''forrest'',',
\ ' ''run'']',
\ ],
\ ale#fixers#rubocop#PostProcess(bufnr(''), [
\ 'Inspecting 1 file',
\ 'C',
\ '',
\ 'Offenses:',
\ 'app/models/my_model.rb:8:3: C: [Corrected] Layout/ArrayAlignment: ',
\ '4, 5, 6]',
\ '^',
\ '',
\ '1 file inspected, 3 offenses detected, 3 offenses corrected',
\ '====================',
\ 'class MyModel < ApplicationRecord',
\ ' # rubocop:disable Rails/InverseOf',
\ ' has_one :something',
\ ' # rubocop:enable Rails/InverseOf',
\ 'end',
\ '',
\ 'array = [1, 2, 3,',
\ ' 4, 5, 6]',
\ 'array = [''run'',',
\ ' ''forrest'',',
\ ' ''run'']',
\ ])

View File

@ -0,0 +1,30 @@
Before:
Save g:ale_ruby_rufo_executable
" Use an invalid global executable, so we don't match it.
let g:ale_ruby_rufo_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The rufo command should contain `bundle exec` when executable is `bundle`):
let g:ale_ruby_rufo_executable = 'bundle'
call ale#test#SetFilename('../test-files/ruby/dummy.rb')
AssertEqual
\ ale#Escape('bundle') . ' exec rufo %t',
\ ale#fixers#rufo#GetCommand(bufnr(''))
Execute(The rufo callback should return the correct default values):
call ale#test#SetFilename('../test-files/ruby/dummy.rb')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid') . ' %t'
\ },
\ ale#fixers#rufo#Fix(bufnr(''))

View File

@ -0,0 +1,16 @@
Before:
call ale#assert#SetUpFixerTest('rust', 'rustfmt')
After:
call ale#assert#TearDownFixerTest()
Execute(The rustfmt callback should return the correct default values):
call ale#test#SetFilename('../test-files/rust/testfile.rs')
AssertFixer {'command': ale#Escape('rustfmt')}
Execute(The rustfmt callback should include custom rustfmt options):
let g:ale_rust_rustfmt_options = "--skip-children"
call ale#test#SetFilename('../test-files/rust/testfile.rs')
AssertFixer {'command': ale#Escape('rustfmt') . ' ' . g:ale_rust_rustfmt_options}

View File

@ -0,0 +1,66 @@
Before:
Save g:ale_scala_scalafmt_executable
Save g:ale_scala_scalafmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_scala_scalafmt_executable = 'xxxinvalid'
let g:ale_scala_scalafmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The scalafmt callback should return the correct default values):
call ale#test#SetFilename('../test-files/scala/dummy.scala')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_scala_scalafmt_executable)
\ . ' %t',
\ },
\ ale#fixers#scalafmt#Fix(bufnr(''))
Execute(The scalafmt callback should use ng with scalafmt automatically):
let g:ale_scala_scalafmt_executable = 'ng'
call ale#test#SetFilename('../test-files/scala/dummy.scala')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('ng')
\ . ' scalafmt'
\ . ' %t',
\ },
\ ale#fixers#scalafmt#Fix(bufnr(''))
Execute(The scalafmt callback should include custom scalafmt options):
let g:ale_scala_scalafmt_options = '--diff'
call ale#test#SetFilename('../test-files/scala/dummy.scala')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_scala_scalafmt_executable)
\ . ' --diff'
\ . ' %t',
\ },
\ ale#fixers#scalafmt#Fix(bufnr(''))
Execute(The scalafmt callback should include custom scalafmt options and use ng with scalafmt):
let g:ale_scala_scalafmt_options = '--diff'
let g:ale_scala_scalafmt_executable = 'ng'
call ale#test#SetFilename('../test-files/scala/dummy.scala')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('ng')
\ . ' scalafmt'
\ . ' --diff'
\ . ' %t',
\ },
\ ale#fixers#scalafmt#Fix(bufnr(''))

View File

@ -0,0 +1,59 @@
Before:
Save g:ale_sh_shfmt_executable
Save g:ale_sh_shfmt_options
Save &l:expandtab
Save &l:shiftwidth
Save &l:tabstop
After:
Restore
Execute(The shfmt callback should return 'shfmt' as default command):
setlocal noexpandtab
Assert
\ ale#fixers#shfmt#Fix(bufnr('')).command =~# '^' . ale#Escape('shfmt'),
\ "Default command name is expected to be 'shfmt'"
Execute(The shfmt callback should return the command with no option as default when noexpandtab is set):
let g:ale_sh_shfmt_executable = 'shfmt'
let g:ale_sh_shfmt_options = ''
setlocal noexpandtab
AssertEqual
\ {
\ 'command': ale#Escape('shfmt'),
\ },
\ ale#fixers#shfmt#Fix(bufnr(''))
Execute(The shfmt callback should return the command specifying indent width by looking shiftwidth as default):
let g:ale_sh_shfmt_executable = 'shfmt'
let g:ale_sh_shfmt_options = ''
setlocal expandtab
setlocal shiftwidth=4
AssertEqual
\ {
\ 'command': ale#Escape('shfmt') . ' -i 4',
\ },
\ ale#fixers#shfmt#Fix(bufnr(''))
Execute(The shfmt callback should return the command specifying indent width by looking tabstop when shiftwidth is 0 as default):
let g:ale_sh_shfmt_executable = 'shfmt'
let g:ale_sh_shfmt_options = ''
setlocal expandtab
setlocal shiftwidth=0
setlocal tabstop=8
AssertEqual
\ {
\ 'command': ale#Escape('shfmt') . ' -i 8',
\ },
\ ale#fixers#shfmt#Fix(bufnr(''))
Execute(The shfmt executable and options should be configurable):
let g:ale_sh_shfmt_executable = 'foobar'
let g:ale_sh_shfmt_options = '--some-option'
AssertEqual
\ {
\ 'command': ale#Escape('foobar')
\ . ' --some-option',
\ },
\ ale#fixers#shfmt#Fix(bufnr(''))

View File

@ -0,0 +1,38 @@
Before:
Save g:ale_ruby_sorbet_executable
Save g:ale_ruby_sorbet_options
" Use an invalid global executable, so we don't match it.
let g:ale_ruby_sorbet_executable = 'xxxinvalid'
let g:ale_ruby_sorbet_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The sorbet callback should return the correct default values):
call ale#test#SetFilename('../test-files/ruby/dummy.rb')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_ruby_sorbet_executable)
\ . ' tc --autocorrect --file %t',
\ },
\ ale#fixers#sorbet#Fix(bufnr(''))
Execute(The sorbet callback should include custom sorbet options):
let g:ale_ruby_sorbet_options = '--enable-experimental-lsp-hover'
call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_ruby_sorbet_executable)
\ . ' tc --enable-experimental-lsp-hover'
\ . ' --autocorrect --file %t',
\ },
\ ale#fixers#sorbet#Fix(bufnr(''))

View File

@ -0,0 +1,26 @@
Before:
Save g:ale_sql_sqlfmt_executable
Save g:ale_sql_sqlfmt_options
After:
Restore
Execute(The sqlfmt callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('sqlfmt')
\ . ' -w',
\ },
\ ale#fixers#sqlfmt#Fix(bufnr(''))
Execute(The sqlfmt executable and options should be configurable):
let g:ale_sql_sqlfmt_executable = '/path/to/sqlfmt'
let g:ale_sql_sqlfmt_options = '-u'
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/sqlfmt')
\ . ' -w'
\ . ' -u',
\ },
\ ale#fixers#sqlfmt#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_sql_sqlformat_executable
Save g:ale_sql_sqlformat_options
After:
Restore
Execute(The sqlformat callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('sqlformat') . ' -'
\ },
\ ale#fixers#sqlformat#Fix(bufnr(''))
Execute(The sqlformat executable and options should be configurable):
let g:ale_sql_sqlformat_executable = '/path/to/sqlformat'
let g:ale_sql_sqlformat_options = '-a'
AssertEqual
\ {
\ 'command': ale#Escape('/path/to/sqlformat')
\ . ' -a -'
\ },
\ ale#fixers#sqlformat#Fix(bufnr(''))

View File

@ -0,0 +1,31 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
unlet! b:ale_javascript_standard_executable
unlet! b:ale_javascript_standard_options
After:
call ale#test#RestoreDirectory()
Execute(The executable path should be correct):
call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.js')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/standard/bin/cmd.js'))
\ . ' --fix --stdin < %s > %t',
\ },
\ ale#fixers#standard#Fix(bufnr(''))
Execute(Custom options should be supported):
let b:ale_javascript_standard_use_global = 1
let b:ale_javascript_standard_options = '--foo-bar'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('standard') . ' --foo-bar --fix --stdin < %s > %t',
\ },
\ ale#fixers#standard#Fix(bufnr(''))

View File

@ -0,0 +1,51 @@
Before:
Save g:ale_ruby_standardrb_executable
Save g:ale_ruby_standardrb_options
" Use an invalid global executable, so we don't match it.
let g:ale_ruby_standardrb_executable = 'xxxinvalid'
let g:ale_ruby_standardrb_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The standardrb callback should return the correct default values):
call ale#test#SetFilename('../test-files/ruby/dummy.rb')
AssertEqual
\ {
\ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
\ . ' --fix --force-exclusion --stdin %s',
\ },
\ ale#fixers#standardrb#Fix(bufnr(''))
Execute(The standardrb callback should include configuration files):
call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')
AssertEqual
\ {
\ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/ruby/with_config/.standard.yml'))
\ . ' --fix --force-exclusion --stdin %s',
\ },
\ ale#fixers#standardrb#Fix(bufnr(''))
Execute(The standardrb callback should include custom rubocop options):
let g:ale_ruby_standardrb_options = '--except Lint/Debugger'
call ale#test#SetFilename('../test-files/ruby/with_config/dummy.rb')
AssertEqual
\ {
\ 'process_with': 'ale#fixers#rubocop#PostProcess',
\ 'command': ale#Escape(g:ale_ruby_standardrb_executable)
\ . ' --config ' . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/ruby/with_config/.standard.yml'))
\ . ' --except Lint/Debugger'
\ . ' --fix --force-exclusion --stdin %s',
\ },
\ ale#fixers#standardrb#Fix(bufnr(''))

View File

@ -0,0 +1,18 @@
Before:
call ale#assert#SetUpFixerTest('nix', 'statix')
After:
call ale#assert#TearDownFixerTest()
Execute(The callback should return the correct default values):
AssertFixer { 'command': ale#Escape('statix') . ' fix --stdin' }
Execute(The callback should include a custom runtime):
let g:ale_nix_statix_fix_executable = 'foo/bar'
AssertFixer { 'command': ale#Escape('foo/bar') . ' fix --stdin' }
Execute(The callback should include custom options):
let g:ale_nix_statix_fix_options = '--foobar'
AssertFixer { 'command': ale#Escape('statix') . ' fix --stdin --foobar' }

View File

@ -0,0 +1,34 @@
Before:
Save g:ale_stylelint_options
let g:ale_stylelint_options = ''
call ale#assert#SetUpFixerTest('css', 'stylelint')
After:
call ale#assert#TearDownFixerTest()
Execute(The stylelint callback should return the correct default values):
call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.css')
AssertFixer
\ {
\ 'read_temporary_file': 0,
\ 'cwd': '%s:h',
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/stylelint/bin/stylelint.js'))
\ . ' --fix --stdin --stdin-filename %s',
\ }
Execute(The stylelint callback should include custom stylelint options):
let g:ale_stylelint_options = '--cache'
call ale#test#SetFilename('../test-files/eslint/react-app/subdir/testfile.css')
AssertFixer
\ {
\ 'read_temporary_file': 0,
\ 'cwd': '%s:h',
\ 'command': (has('win32') ? 'node.exe ' : '')
\ . ale#Escape(ale#path#Simplify(g:dir . '/../test-files/eslint/react-app/node_modules/stylelint/bin/stylelint.js'))
\ . ' --cache --fix --stdin --stdin-filename %s',
\ }

View File

@ -0,0 +1,21 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The styler callback should include custom styler options):
let g:ale_r_styler_options = "a_custom_option"
AssertEqual
\ {
\ 'command': 'Rscript --vanilla -e '
\ . '"suppressPackageStartupMessages(library(styler));'
\ . 'style_file(commandArgs(TRUE), transformers = '
\ . 'a_custom_option)"'
\ . ' %t',
\ 'read_temporary_file': 1,
\ },
\ ale#fixers#styler#Fix(bufnr(''))

View File

@ -0,0 +1,24 @@
Before:
Save g:ale_haskell_stylish_haskell_executable
" Use an invalid global executable, so we don't match it.
let g:ale_haskell_stylish_haskell_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The stylish-haskell callback should return the correct default values):
call ale#test#SetFilename('../haskell_files/testfile.hs')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' --inplace'
\ . ' %t',
\ },
\ ale#fixers#stylish_haskell#Fix(bufnr(''))

View File

@ -0,0 +1,19 @@
Before:
call ale#assert#SetUpFixerTest('lua', 'stylua')
After:
call ale#assert#TearDownFixerTest()
Execute(The default command should be correct):
AssertFixer {'command': ale#Escape('stylua') . ' -'}
Execute(The stylua callback should include custom stylua options):
let g:ale_lua_stylua_executable = 'xxxinvalid'
let g:ale_lua_stylua_options = '--search-parent-directories'
AssertFixer
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' ' . g:ale_lua_stylua_options
\ . ' -',
\ }

View File

@ -0,0 +1,35 @@
Before:
Save g:ale_swift_swiftformat_executable
" Use an invalid global executable, so we don't match it.
let g:ale_swift_swiftformat_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The swiftformat callback should return the correct default values):
call ale#test#SetFilename('../test-files/swift/dummy.swift')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_swift_swiftformat_executable)
\ . ' %t ',
\ },
\ ale#fixers#swiftformat#Fix(bufnr(''))
Execute(The swiftformat callback should include any additional options):
call ale#test#SetFilename('../test-files/swift/dummy.swift')
let g:ale_swift_swiftformat_options = '--some-option'
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape(g:ale_swift_swiftformat_executable)
\ . ' %t --some-option',
\ },
\ ale#fixers#swiftformat#Fix(bufnr(''))

View File

@ -0,0 +1,34 @@
Before:
Save g:ale_terraform_fmt_executable
Save g:ale_terraform_fmt_options
" Use an invalid global executable, so we don't match it.
let g:ale_terraform_fmt_executable = 'xxxinvalid'
let g:ale_terraform_fmt_options = ''
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The terraform fmt callback should return the correct default values):
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid') . ' fmt -',
\ },
\ ale#fixers#terraform#Fix(bufnr(''))
Execute(The terraform fmt callback should include custom options):
let g:ale_terraform_fmt_options = "-list=true"
AssertEqual
\ {
\ 'command': ale#Escape('xxxinvalid')
\ . ' fmt'
\ . ' ' . g:ale_terraform_fmt_options
\ . ' -',
\ },
\ ale#fixers#terraform#Fix(bufnr(''))

View File

@ -0,0 +1,42 @@
Before:
Save g:ale_textlint_executable
Save g:ale_textlint_options
Save g:ale_textlint_use_global
" Use an invalid global executable, so we don't match it.
let g:ale_textlint_executable = 'xxxinvalid'
let g:ale_textlint_options = ''
let g:ale_textlint_use_global = 0
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The textlint callback should return the correct default values):
call ale#test#SetFilename('../test-files/markdown/testfile.md')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' --fix'
\ . ' %t',
\ },
\ ale#fixers#textlint#Fix(bufnr(''))
Execute(The textlint callback should include custom textlint options):
let g:ale_textlint_options = "--quiet"
call ale#test#SetFilename('../test-files/markdown/testfile.md')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('xxxinvalid')
\ . ' --fix'
\ . ' ' . g:ale_textlint_options
\ . ' %t',
\ },
\ ale#fixers#textlint#Fix(bufnr(''))

View File

@ -0,0 +1,25 @@
Before:
Save g:ale_html_tidy_executable
let g:ale_html_tidy_executable = '../test-files/tidy/tidy'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The tidy callback should return 0 if tidy not found):
let g:ale_html_tidy_executable = 'xxxinvalidpath'
AssertEqual
\ 0,
\ ale#fixers#tidy#Fix(bufnr(''))
Execute(The tidy callback should return the correct default command):
AssertEqual
\ {
\ 'command': ale#Escape('../test-files/tidy/tidy')
\ . ' -q --tidy-mark no --show-errors 0 --show-warnings 0'
\ },
\ ale#fixers#tidy#Fix(bufnr(''))

View File

@ -0,0 +1,28 @@
Before:
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
call ale#test#RestoreDirectory()
Execute(Should delete all whitespace at the end of different lines):
AssertEqual
\ [
\ 'def foo():',
\ ' some_variable = this_is_a_longer_function(',
\ 'first_argument,',
\ ' second_argument,',
\ ' third_with_function_call(',
\ 'foo,',
\ ' bar,',
\ '))',
\ ],
\ ale#fixers#generic#TrimWhitespace(bufnr(''), [
\ 'def foo():',
\ ' some_variable = this_is_a_longer_function(',
\ 'first_argument,',
\ ' second_argument,',
\ ' third_with_function_call(',
\ 'foo,',
\ ' bar,',
\ '))',
\ ])

View File

@ -0,0 +1,42 @@
Before:
Save g:ale_typescript_tslint_executable
Save g:ale_typescript_tslint_config_path
unlet! g:ale_typescript_tslint_executable
unlet! g:ale_typescript_tslint_config_path
unlet! b:ale_typescript_tslint_executable
unlet! b:ale_typescript_tslint_config_path
call ale#handlers#tslint#InitVariables()
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The tslint callback should return the correct default values):
let g:ale_typescript_tslint_config_path = 'tslint.json'
call ale#test#SetFilename('../test-files/prettier/testfile.ts')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('tslint')
\ . ' -c ' . ale#Escape('tslint.json')
\ . ' --outputAbsolutePaths --fix %t',
\ },
\ ale#fixers#tslint#Fix(bufnr(''))
Execute(The tslint callback should include custom tslint config option):
let g:ale_typescript_tslint_config_path = '.tslintrc'
call ale#test#SetFilename('../test-files/prettier/testfile.ts')
AssertEqual
\ {
\ 'read_temporary_file': 1,
\ 'command': ale#Escape('tslint')
\ . ' -c ' . ale#Escape('.tslintrc')
\ . ' --outputAbsolutePaths --fix %t',
\ },
\ ale#fixers#tslint#Fix(bufnr(''))

View File

@ -0,0 +1,108 @@
Before:
Save g:ale_c_uncrustify_executable
" Use an invalid global executable, so we don't match it.
let g:ale_c_uncrustify_executable = 'xxxinvalid'
call ale#test#SetDirectory('/testplugin/test/fixers')
After:
Restore
call ale#test#RestoreDirectory()
Execute(The clang-format callback should return the correct default values):
call ale#test#SetFilename('../test-files/c/dummy.c')
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l C'
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
Execute(The uncrustify callback should include any additional options):
call ale#test#SetFilename('../test-files/c/dummy.c')
let b:ale_c_uncrustify_options = '--some-option'
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l C --some-option',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
Execute(The uncrustify callback should set proper language):
unlet b:ale_c_uncrustify_options
set filetype=c
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l C',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
set filetype=cpp
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l CPP',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
set filetype=cs
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l CS',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
set filetype=objc
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l OC',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
set filetype=objcpp
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l OC+',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
set filetype=d
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l D',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
set filetype=java
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l JAVA',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
set filetype=vala
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l VALA',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))
set filetype=p
AssertEqual
\ {
\ 'command': ale#Escape(g:ale_c_uncrustify_executable)
\ . ' --no-backup -l PAWN',
\ },
\ ale#fixers#uncrustify#Fix(bufnr(''))

Some files were not shown because too many files have changed in this diff Show More