Get fixer tests to work on Windows
This commit is contained in:
parent
638ca42082
commit
5091e2de45
15 changed files with 106 additions and 68 deletions
|
@ -12,7 +12,7 @@ function! ale#fixers#autopep8#Fix(buffer) abort
|
|||
\ ['autopep8'],
|
||||
\)
|
||||
|
||||
if !executable(l:executable)
|
||||
if !ale#python#IsExecutable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ function! ale#fixers#isort#Fix(buffer) abort
|
|||
\ ['isort'],
|
||||
\)
|
||||
|
||||
if !executable(l:executable)
|
||||
if !ale#python#IsExecutable(l:executable)
|
||||
return 0
|
||||
endif
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
" Author: Sumner Evans <sumner.evans98@gmail.com>
|
||||
" Description: Fixing files with Standard.
|
||||
|
||||
call ale#Set('javascript_standard_executable', 'standard')
|
||||
call ale#Set('javascript_standard_use_global', 0)
|
||||
call ale#Set('javascript_standard_options', '')
|
||||
|
||||
function! ale#fixers#standard#GetExecutable(buffer) abort
|
||||
return ale#node#FindExecutable(a:buffer, 'javascript_standard', [
|
||||
\ 'node_modules/standard/bin/cmd.js',
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
" Author: w0rp <devw0rp@gmail.com>
|
||||
" Description: Functions for working with eslint, for checking or fixing files.
|
||||
|
||||
let s:sep = has('win32') ? '\' : '/'
|
||||
|
||||
call ale#Set('javascript_eslint_options', '')
|
||||
call ale#Set('javascript_eslint_executable', 'eslint')
|
||||
call ale#Set('javascript_eslint_use_global', 0)
|
||||
|
@ -15,7 +17,7 @@ function! ale#handlers#eslint#FindConfig(buffer) abort
|
|||
\ '.eslintrc.json',
|
||||
\ '.eslintrc',
|
||||
\]
|
||||
let l:config = ale#path#Simplify(l:path . '/' . l:basename)
|
||||
let l:config = ale#path#Simplify(join([l:path, l:basename], s:sep))
|
||||
|
||||
if filereadable(l:config)
|
||||
return l:config
|
||||
|
|
|
@ -11,9 +11,13 @@ Before:
|
|||
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 autopep8 callback should return the correct default values):
|
||||
|
@ -23,7 +27,7 @@ Execute(The autopep8 callback should return the correct default values):
|
|||
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/autopep8' -" },
|
||||
\ {'command': ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autopep8')) . ' -'},
|
||||
\ ale#fixers#autopep8#Fix(bufnr(''))
|
||||
|
||||
Execute(The autopep8 callback should include options):
|
||||
|
@ -31,5 +35,5 @@ Execute(The autopep8 callback should include options):
|
|||
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/autopep8' --some-option -" },
|
||||
\ {'command': ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/autopep8')) . ' --some-option -' },
|
||||
\ ale#fixers#autopep8#Fix(bufnr(''))
|
||||
|
|
|
@ -15,7 +15,7 @@ Execute(The elm-format command should have default params):
|
|||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||
\ ale#Escape(ale#path#Winify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||
\ . ' %t --yes',
|
||||
\ },
|
||||
\ ale#fixers#format#Fix(bufnr(''))
|
||||
|
@ -55,7 +55,7 @@ Execute(The elm-format command should manage empty options):
|
|||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||
\ ale#Escape(ale#path#Winify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||
\ . ' %t',
|
||||
\ },
|
||||
\ ale#fixers#format#Fix(bufnr(''))
|
||||
|
@ -68,8 +68,7 @@ Execute(The elm-format command should manage custom options):
|
|||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||
\ ale#Escape(ale#path#Winify(g:dir . '/../elm-test-files/node_modules/.bin/elm-format'))
|
||||
\ . ' %t --param1 --param2',
|
||||
\ },
|
||||
\ ale#fixers#format#Fix(bufnr(''))
|
||||
|
||||
|
|
|
@ -2,18 +2,17 @@ Before:
|
|||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
let g:ale_has_override = {}
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The path to eslint.js should be run on Unix):
|
||||
Execute(The executable path should be correct):
|
||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js'))
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js'))
|
||||
\ . ' --fix %t',
|
||||
\ },
|
||||
\ ale#fixers#eslint#Fix(bufnr(''))
|
||||
|
@ -24,9 +23,9 @@ Execute(The lower priority configuration file in a nested directory should be pr
|
|||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/subdir-with-config/.eslintrc'))
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/subdir-with-config/.eslintrc'))
|
||||
\ . ' --fix %t',
|
||||
\ },
|
||||
\ ale#fixers#eslint#Fix(bufnr(''))
|
||||
|
@ -37,9 +36,9 @@ Execute(package.json should be used as a last resort):
|
|||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js'))
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/.eslintrc.js'))
|
||||
\ . ' --fix %t',
|
||||
\ },
|
||||
\ ale#fixers#eslint#Fix(bufnr(''))
|
||||
|
@ -50,8 +49,8 @@ Execute(package.json should be used as a last resort):
|
|||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../eslint-test-files/node_modules/.bin/eslint'))
|
||||
\ . ' -c ' . ale#Escape(simplify(g:dir . '/../eslint-test-files/package.json'))
|
||||
\ ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/node_modules/.bin/eslint'))
|
||||
\ . ' -c ' . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/package.json'))
|
||||
\ . ' --fix %t',
|
||||
\ },
|
||||
\ ale#fixers#eslint#Fix(bufnr(''))
|
||||
|
|
|
@ -9,9 +9,13 @@ Before:
|
|||
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 isort callback should return the correct default values):
|
||||
|
@ -21,5 +25,5 @@ Execute(The isort callback should return the correct default values):
|
|||
|
||||
silent execute 'file ' . fnameescape(g:dir . '/python_paths/with_virtualenv/subdir/foo/bar.py')
|
||||
AssertEqual
|
||||
\ {'command': "'" . g:dir . "/python_paths/with_virtualenv/env/bin/isort' -" },
|
||||
\ {'command': ale#Escape(ale#path#Winify(g:dir . '/python_paths/with_virtualenv/env/' . b:bin_dir . '/isort')) . ' -' },
|
||||
\ ale#fixers#isort#Fix(bufnr(''))
|
||||
|
|
|
@ -21,7 +21,7 @@ Execute(project with phpcbf should use local by default):
|
|||
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf',
|
||||
\ ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf'),
|
||||
\ ale#fixers#phpcbf#GetExecutable(bufnr(''))
|
||||
|
||||
Execute(use-global should override local detection):
|
||||
|
@ -43,7 +43,7 @@ Execute(The phpcbf callback should return the correct default values):
|
|||
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ {'command': ale#Escape(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf') . ' --stdin-path=%s ' },
|
||||
\ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' },
|
||||
\ ale#fixers#phpcbf#Fix(bufnr(''))
|
||||
|
||||
Execute(The phpcbf callback should include the phpcbf_standard option):
|
||||
|
@ -51,6 +51,62 @@ Execute(The phpcbf callback should include the phpcbf_standard option):
|
|||
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ {'command': ale#Escape(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf') . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'},
|
||||
\ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'},
|
||||
\ 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_use_global = 0
|
||||
|
||||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
silent cd ..
|
||||
silent cd command_callback
|
||||
let g:dir = getcwd()
|
||||
|
||||
After:
|
||||
Restore
|
||||
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(project with phpcbf should use local by default):
|
||||
call ale#test#SetFilename('php_paths/project-with-phpcbf/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ ale#path#Winify(g:dir . '/php_paths/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('php_paths/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('php_paths/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('php_paths/project-with-phpcbf/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/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('php_paths/project-with-phpcbf/foo/test.php')
|
||||
|
||||
AssertEqual
|
||||
\ {'command': ale#Escape(ale#path#Winify(g:dir . '/php_paths/project-with-phpcbf/vendor/bin/phpcbf')) . ' --stdin-path=%s ' . '--standard=phpcbf_ruleset.xml'},
|
||||
\ ale#fixers#phpcbf#Fix(bufnr(''))
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ Execute(Configuration files should be detected):
|
|||
\ 'command':
|
||||
\ ale#Escape('prettier-eslint')
|
||||
\ . ' %t'
|
||||
\ . ' --eslint-config-path ' . ale#Escape(g:dir . '/eslint-test-files/react-app/.eslintrc.js')
|
||||
\ . ' --eslint-config-path ' . ale#Escape(ale#path#Winify(g:dir . '/eslint-test-files/react-app/.eslintrc.js'))
|
||||
\ . ' --write'
|
||||
\ },
|
||||
\ ale#fixers#prettier_eslint#Fix(bufnr(''))
|
||||
|
|
|
@ -39,7 +39,7 @@ Execute(The prettier callback should include configuration files when the option
|
|||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' %t'
|
||||
\ . ' --parser babylon'
|
||||
\ . ' --config ' . ale#Escape(simplify(g:dir . '/../prettier-test-files/with_config/.prettierrc'))
|
||||
\ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/../prettier-test-files/with_config/.prettierrc'))
|
||||
\ . ' --write',
|
||||
\ },
|
||||
\ ale#fixers#prettier#Fix(bufnr(''))
|
||||
|
@ -54,7 +54,7 @@ Execute(The prettier callback should include custom prettier options):
|
|||
\ 'command': ale#Escape(g:ale_javascript_prettier_executable)
|
||||
\ . ' %t'
|
||||
\ . ' --no-semi --parser babylon'
|
||||
\ . ' --config ' . ale#Escape(simplify(g:dir . '/../prettier-test-files/with_config/.prettierrc'))
|
||||
\ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/../prettier-test-files/with_config/.prettierrc'))
|
||||
\ . ' --write',
|
||||
\ },
|
||||
\ ale#fixers#prettier#Fix(bufnr(''))
|
||||
|
|
|
@ -21,7 +21,7 @@ Execute(The puppetlint callback should return the correct default values):
|
|||
|
||||
AssertEqual
|
||||
\ {'read_temporary_file': 1,
|
||||
\ 'command': "'" . g:ale_puppet_puppetlint_executable . "'"
|
||||
\ 'command': ale#Escape(g:ale_puppet_puppetlint_executable)
|
||||
\ . ' ' . g:ale_puppet_puppetlint_options
|
||||
\ . ' --fix %t' },
|
||||
\ ale#fixers#puppetlint#Fix(bufnr(''))
|
||||
|
|
|
@ -34,7 +34,7 @@ Execute(The rubocop callback should include configuration files):
|
|||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
|
||||
\ . ' --config ' . ale#Escape(g:dir . '/ruby_paths/with_config/.rubocop.yml')
|
||||
\ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/ruby_paths/with_config/.rubocop.yml'))
|
||||
\ . ' --auto-correct %t',
|
||||
\ },
|
||||
\ ale#fixers#rubocop#Fix(bufnr(''))
|
||||
|
@ -47,7 +47,7 @@ Execute(The rubocop callback should include custom rubocop options):
|
|||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape(g:ale_ruby_rubocop_executable)
|
||||
\ . ' --config ' . ale#Escape(g:dir . '/ruby_paths/with_config/.rubocop.yml')
|
||||
\ . ' --config ' . ale#Escape(ale#path#Winify(g:dir . '/ruby_paths/with_config/.rubocop.yml'))
|
||||
\ . ' --except Lint/Debugger'
|
||||
\ . ' --auto-correct %t',
|
||||
\ },
|
||||
|
|
|
@ -2,31 +2,16 @@ Before:
|
|||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
let g:ale_has_override = {}
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The path to standard.js should be run on Unix):
|
||||
Execute(The executable path should be correct):
|
||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js'))
|
||||
\ . ' --fix %t',
|
||||
\ },
|
||||
\ ale#fixers#standard#Fix(bufnr(''))
|
||||
|
||||
Execute(The standard fixer with standard.js should be run with node on Windows):
|
||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.js')
|
||||
let g:ale_has_override['win32'] = 1
|
||||
|
||||
" We have to execute the file with node.
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('node.exe') . ' '
|
||||
\ . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js'))
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/standard/bin/cmd.js'))
|
||||
\ . ' --fix %t',
|
||||
\ },
|
||||
\ ale#fixers#standard#Fix(bufnr(''))
|
||||
|
|
|
@ -2,31 +2,16 @@ Before:
|
|||
call ale#test#SetDirectory('/testplugin/test/fixers')
|
||||
|
||||
After:
|
||||
let g:ale_has_override = {}
|
||||
call ale#test#RestoreDirectory()
|
||||
|
||||
Execute(The path to stylelint.js should be run on Unix):
|
||||
Execute(The executable path should be correct):
|
||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css')
|
||||
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command':
|
||||
\ ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js'))
|
||||
\ . ' --fix %t',
|
||||
\ },
|
||||
\ ale#fixers#stylelint#Fix(bufnr(''))
|
||||
|
||||
Execute(The stylelint fixer with stylelint.js should be run with node on Windows):
|
||||
call ale#test#SetFilename('../eslint-test-files/react-app/subdir/testfile.css')
|
||||
let g:ale_has_override['win32'] = 1
|
||||
|
||||
" We have to execute the file with node.
|
||||
AssertEqual
|
||||
\ {
|
||||
\ 'read_temporary_file': 1,
|
||||
\ 'command': ale#Escape('node.exe') . ' '
|
||||
\ . ale#Escape(simplify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js'))
|
||||
\ 'command': (has('win32') ? 'node.exe ' : '')
|
||||
\ . ale#Escape(ale#path#Winify(g:dir . '/../eslint-test-files/react-app/node_modules/stylelint/bin/stylelint.js'))
|
||||
\ . ' --fix %t',
|
||||
\ },
|
||||
\ ale#fixers#stylelint#Fix(bufnr(''))
|
||||
|
|
Reference in a new issue