mirror of
https://github.com/dense-analysis/ale.git
synced 2026-02-09 11:11:32 +08:00
merging master
This commit is contained in:
50
test/fixers/test_autoimport_fixer_callback.vader
Normal file
50
test/fixers/test_autoimport_fixer_callback.vader
Normal file
@@ -0,0 +1,50 @@
|
||||
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')
|
||||
silent cd ..
|
||||
silent cd command_callback
|
||||
let g:dir = getcwd()
|
||||
|
||||
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 . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/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 . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autoimport'))
|
||||
\ . ' --multi-line=3 --trailing-comma -',
|
||||
\ },
|
||||
\ ale#fixers#autoimport#Fix(bufnr(''))
|
||||
@@ -21,10 +21,7 @@ Execute(The gofmt callback should return the correct default values):
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' -l -w'
|
||||
\ . ' %t',
|
||||
\ 'command': ale#Escape('xxxinvalid'),
|
||||
\ },
|
||||
\ ale#fixers#gofmt#Fix(bufnr(''))
|
||||
|
||||
@@ -35,11 +32,8 @@ Execute(The gofmt callback should include custom gofmt options):
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' -l -w'
|
||||
\ . ' ' . g:ale_go_gofmt_options
|
||||
\ . ' %t',
|
||||
\ . ' ' . g:ale_go_gofmt_options,
|
||||
\ },
|
||||
\ ale#fixers#gofmt#Fix(bufnr(''))
|
||||
|
||||
@@ -50,9 +44,7 @@ Execute(The gofmt callback should support Go environment variables):
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Env('GO111MODULE', 'off')
|
||||
\ . ale#Escape('xxxinvalid') . ' -l -w'
|
||||
\ . ' %t',
|
||||
\ . ale#Escape('xxxinvalid')
|
||||
\ },
|
||||
\ ale#fixers#gofmt#Fix(bufnr(''))
|
||||
|
||||
35
test/fixers/test_luafmt_fixer_callback.vader
Normal file
35
test/fixers/test_luafmt_fixer_callback.vader
Normal 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('../lua_files/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('../lua_files/testfile.lua')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#Escape('xxxinvalid')
|
||||
\ . ' ' . g:ale_lua_luafmt_options
|
||||
\ . ' --stdin',
|
||||
\ },
|
||||
\ ale#fixers#luafmt#Fix(bufnr(''))
|
||||
24
test/fixers/test_ormolu_fixer_callback.vader
Normal file
24
test/fixers/test_ormolu_fixer_callback.vader
Normal 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(''))
|
||||
@@ -5,6 +5,7 @@ Before:
|
||||
|
||||
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')
|
||||
@@ -54,6 +55,15 @@ Execute(The phpcbf callback should include the phpcbf_standard option):
|
||||
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/php_paths/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('php_paths/project-with-phpcbf/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ {'command': ale#Escape(ale#path#Simplify(g:dir . '/php_paths/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
|
||||
@@ -61,6 +71,7 @@ Before:
|
||||
|
||||
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')
|
||||
|
||||
50
test/fixers/test_yamlfix_fixer_callback.vader
Normal file
50
test/fixers/test_yamlfix_fixer_callback.vader
Normal file
@@ -0,0 +1,50 @@
|
||||
Before:
|
||||
Save g:ale_python_yamlfix_executable
|
||||
Save g:ale_python_yamlfix_options
|
||||
|
||||
" Use an invalid global executable, so we don't match it.
|
||||
let g:ale_python_yamlfix_executable = 'xxxinvalid'
|
||||
let g:ale_python_yamlfix_options = ''
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
silent cd ..
|
||||
silent cd command_callback
|
||||
let g:dir = getcwd()
|
||||
|
||||
let b:bin_dir = has('win32') ? 'Scripts' : 'bin'
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
unlet! b:bin_dir
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The yamlfix callback should return the correct default values):
|
||||
AssertEqual
|
||||
\ 0,
|
||||
\ ale#fixers#yamlfix#Fix(bufnr(''))
|
||||
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.yaml')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yamlfix')) . ' -',
|
||||
\ },
|
||||
\ ale#fixers#yamlfix#Fix(bufnr(''))
|
||||
|
||||
Execute(The yamlfix callback should respect custom options):
|
||||
let g:ale_yaml_yamlfix_options = '--multi-line=3 --trailing-comma'
|
||||
|
||||
AssertEqual
|
||||
\ 0,
|
||||
\ ale#fixers#yamlfix#Fix(bufnr(''))
|
||||
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.yaml')
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'command': ale#path#BufferCdString(bufnr(''))
|
||||
\ . ale#Escape(ale#path#Simplify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/yamlfix'))
|
||||
\ . ' --multi-line=3 --trailing-comma -',
|
||||
\ },
|
||||
\ ale#fixers#yamlfix#Fix(bufnr(''))
|
||||
Reference in New Issue
Block a user