summaryrefslogtreecommitdiff
path: root/test/fixers
diff options
context:
space:
mode:
Diffstat (limited to 'test/fixers')
-rw-r--r--test/fixers/test_autopep8_fixer_callback.vader8
-rw-r--r--test/fixers/test_elm_format_fixer_callback.vader7
-rw-r--r--test/fixers/test_eslint_fixer_callback.vader25
-rw-r--r--test/fixers/test_isort_fixer_callback.vader6
-rw-r--r--test/fixers/test_phpcbf_fixer_callback.vader62
-rw-r--r--test/fixers/test_prettier_eslint_fixer.callback.vader2
-rw-r--r--test/fixers/test_prettier_fixer_callback.vader4
-rw-r--r--test/fixers/test_puppetlint_fixer_callback.vader2
-rw-r--r--test/fixers/test_rubocop_fixer_callback.vader4
-rw-r--r--test/fixers/test_standard_fixer_callback.vader21
-rw-r--r--test/fixers/test_stylelint_fixer_callback.vader21
11 files changed, 97 insertions, 65 deletions
diff --git a/test/fixers/test_autopep8_fixer_callback.vader b/test/fixers/test_autopep8_fixer_callback.vader
index c8c0bd46..600fb194 100644
--- a/test/fixers/test_autopep8_fixer_callback.vader
+++ b/test/fixers/test_autopep8_fixer_callback.vader
@@ -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(''))
diff --git a/test/fixers/test_elm_format_fixer_callback.vader b/test/fixers/test_elm_format_fixer_callback.vader
index b8b9ed00..8552c5d5 100644
--- a/test/fixers/test_elm_format_fixer_callback.vader
+++ b/test/fixers/test_elm_format_fixer_callback.vader
@@ -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(''))
-
diff --git a/test/fixers/test_eslint_fixer_callback.vader b/test/fixers/test_eslint_fixer_callback.vader
index 21eb450d..d4783fc7 100644
--- a/test/fixers/test_eslint_fixer_callback.vader
+++ b/test/fixers/test_eslint_fixer_callback.vader
@@ -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(''))
diff --git a/test/fixers/test_isort_fixer_callback.vader b/test/fixers/test_isort_fixer_callback.vader
index 437e2764..ea4426d1 100644
--- a/test/fixers/test_isort_fixer_callback.vader
+++ b/test/fixers/test_isort_fixer_callback.vader
@@ -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(''))
diff --git a/test/fixers/test_phpcbf_fixer_callback.vader b/test/fixers/test_phpcbf_fixer_callback.vader
index c2fe3a66..cf02a0b5 100644
--- a/test/fixers/test_phpcbf_fixer_callback.vader
+++ b/test/fixers/test_phpcbf_fixer_callback.vader
@@ -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(''))
diff --git a/test/fixers/test_prettier_eslint_fixer.callback.vader b/test/fixers/test_prettier_eslint_fixer.callback.vader
index 56daf93f..b48a7085 100644
--- a/test/fixers/test_prettier_eslint_fixer.callback.vader
+++ b/test/fixers/test_prettier_eslint_fixer.callback.vader
@@ -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(''))
diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader
index a684ad02..cc7d34d0 100644
--- a/test/fixers/test_prettier_fixer_callback.vader
+++ b/test/fixers/test_prettier_fixer_callback.vader
@@ -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(''))
diff --git a/test/fixers/test_puppetlint_fixer_callback.vader b/test/fixers/test_puppetlint_fixer_callback.vader
index 04a85e56..224d72ab 100644
--- a/test/fixers/test_puppetlint_fixer_callback.vader
+++ b/test/fixers/test_puppetlint_fixer_callback.vader
@@ -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(''))
diff --git a/test/fixers/test_rubocop_fixer_callback.vader b/test/fixers/test_rubocop_fixer_callback.vader
index 87d56d07..ff2ca965 100644
--- a/test/fixers/test_rubocop_fixer_callback.vader
+++ b/test/fixers/test_rubocop_fixer_callback.vader
@@ -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',
\ },
diff --git a/test/fixers/test_standard_fixer_callback.vader b/test/fixers/test_standard_fixer_callback.vader
index 88169bbb..34c752db 100644
--- a/test/fixers/test_standard_fixer_callback.vader
+++ b/test/fixers/test_standard_fixer_callback.vader
@@ -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(''))
diff --git a/test/fixers/test_stylelint_fixer_callback.vader b/test/fixers/test_stylelint_fixer_callback.vader
index 482704d4..a0fc6ff4 100644
--- a/test/fixers/test_stylelint_fixer_callback.vader
+++ b/test/fixers/test_stylelint_fixer_callback.vader
@@ -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(''))