summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/command_callback/test_dartanalyzer_command_callback.vader2
-rw-r--r--test/command_callback/test_haml_hamllint_command_callback.vader72
-rw-r--r--test/command_callback/test_shellcheck_command_callback.vader22
-rw-r--r--test/command_callback/test_write_good_command_callback.vader65
-rw-r--r--test/command_callback/write-good-node-modules-2/node_modules/write-good/bin/write-good.js0
-rw-r--r--test/command_callback/write-good-node-modules/node_modules/.bin/write-good0
-rw-r--r--test/elixir-test-files/testfile.ex0
-rw-r--r--test/fixers/test_hfmt_fixer_callback.vader24
-rw-r--r--test/fixers/test_mix_format_fixer_callback.vader20
-rw-r--r--test/fixers/test_prettier_fixer_callback.vader14
-rw-r--r--test/fixers/test_rustfmt_fixer_callback.vader38
-rw-r--r--test/hamllint-test-files/haml-lint-and-rubocop/.haml-lint.yml0
-rw-r--r--test/hamllint-test-files/haml-lint-and-rubocop/.rubocop.yml0
-rw-r--r--test/hamllint-test-files/haml-lint-and-rubocop/subdir/file.haml0
-rw-r--r--test/hamllint-test-files/haml-lint-yml/.haml-lint.yml0
-rw-r--r--test/hamllint-test-files/haml-lint-yml/subdir/file.haml0
-rw-r--r--test/hamllint-test-files/rubocop-yml/.rubocop.yml0
-rw-r--r--test/hamllint-test-files/rubocop-yml/subdir/file.haml0
-rw-r--r--test/handler/test_checkmake_handler.vader19
-rw-r--r--test/handler/test_clang_handler.vader12
-rw-r--r--test/handler/test_gcc_handler.vader74
-rw-r--r--test/handler/test_php_phan_handler.vader24
-rw-r--r--test/handler/test_php_phpmd_handler.vader24
-rw-r--r--test/handler/test_remark_lint_handler.vader27
-rw-r--r--test/handler/test_vint_handler.vader6
-rw-r--r--test/handler/test_write_good_handler.vader37
-rw-r--r--test/rust_files/testfile.rs0
-rwxr-xr-xtest/script/check-supported-tools-tables20
-rwxr-xr-xtest/script/check-toc13
-rw-r--r--test/sign/test_linting_sets_signs.vader4
-rw-r--r--test/test_ale_fix.vader140
-rw-r--r--test/test_ale_info.vader4
-rw-r--r--test/test_ale_lint_command.vader10
-rw-r--r--test/test_ale_toggle.vader2
-rw-r--r--test/test_c_import_paths.vader72
-rw-r--r--test/test_command_chain.vader10
-rw-r--r--test/test_csslint_config_detection.vader2
-rw-r--r--test/test_elm_executable_detection.vader2
-rw-r--r--test/test_errors_removed_after_filetype_changed.vader7
-rw-r--r--test/test_eslint_executable_detection.vader8
-rw-r--r--test/test_find_nearest_directory.vader2
-rw-r--r--test/test_flow_command.vader8
-rw-r--r--test/test_format_command.vader45
-rw-r--r--test/test_format_temporary_file_creation.vader4
-rw-r--r--test/test_get_abspath.vader4
-rw-r--r--test/test_gradle_build_classpath_command.vader39
-rw-r--r--test/test_gradle_find_executable.vader24
-rw-r--r--test/test_gradle_find_project_root.vader6
-rw-r--r--test/test_highlight_placement.vader4
-rw-r--r--test/test_history_saving.vader5
-rw-r--r--test/test_lint_on_enter_when_file_changed.vader7
51 files changed, 716 insertions, 206 deletions
diff --git a/test/command_callback/test_dartanalyzer_command_callback.vader b/test/command_callback/test_dartanalyzer_command_callback.vader
index c26028de..dbd8290c 100644
--- a/test/command_callback/test_dartanalyzer_command_callback.vader
+++ b/test/command_callback/test_dartanalyzer_command_callback.vader
@@ -35,6 +35,6 @@ Execute(The .packages file should be set if detected):
AssertEqual
\ ale#Escape('dartanalyzer')
- \ . ' --packages ' . ale#Escape(g:dir . '/dart_paths/.packages')
+ \ . ' --packages ' . ale#Escape(ale#path#Winify(g:dir . '/dart_paths/.packages'))
\ . ' %t',
\ ale_linters#dart#dartanalyzer#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_haml_hamllint_command_callback.vader b/test/command_callback/test_haml_hamllint_command_callback.vader
new file mode 100644
index 00000000..68aa1e62
--- /dev/null
+++ b/test/command_callback/test_haml_hamllint_command_callback.vader
@@ -0,0 +1,72 @@
+Before:
+ runtime ale_linters/haml/hamllint.vim
+
+ let g:default_command = 'haml-lint %t'
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+
+After:
+ Restore
+
+ unlet! g:default_command
+ unlet! b:conf
+
+ call ale#linter#Reset()
+ call ale#test#RestoreDirectory()
+
+Execute(The default command should be correct):
+ AssertEqual g:default_command, ale_linters#haml#hamllint#GetCommand(bufnr(''))
+
+Execute(The command should have the .rubocop.yml prepended as an env var if one exists):
+ call ale#test#SetFilename('../hamllint-test-files/rubocop-yml/subdir/file.haml')
+ let b:conf = ale#path#Winify(g:dir . '/../hamllint-test-files/rubocop-yml/.rubocop.yml')
+
+ if has('win32')
+ " Windows uses 'set var=... && command'
+ AssertEqual
+ \ 'set HAML_LINT_RUBOCOP_CONF='
+ \ . ale#Escape(b:conf)
+ \ . ' && ' . g:default_command,
+ \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
+ else
+ " Unix uses 'var=... command'
+ AssertEqual
+ \ 'HAML_LINT_RUBOCOP_CONF='
+ \ . ale#Escape(b:conf)
+ \ . ' ' . g:default_command,
+ \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
+ endif
+
+Execute(The command should have the nearest .haml-lint.yml set as --config if it exists):
+ call ale#test#SetFilename('../hamllint-test-files/haml-lint-yml/subdir/file.haml')
+ let b:conf = ale#path#Winify(g:dir . '/../hamllint-test-files/haml-lint-yml/.haml-lint.yml')
+
+ AssertEqual
+ \ 'haml-lint --config '
+ \ . ale#Escape(b:conf)
+ \ . ' %t',
+ \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
+
+Execute(The command should include a .rubocop.yml and a .haml-lint if both are found):
+ call ale#test#SetFilename('../hamllint-test-files/haml-lint-and-rubocop/subdir/file.haml')
+ let b:conf_hamllint = ale#path#Winify(g:dir . '/../hamllint-test-files/haml-lint-and-rubocop/.haml-lint.yml')
+ let b:conf_rubocop = ale#path#Winify(g:dir . '/../hamllint-test-files/haml-lint-and-rubocop/.rubocop.yml')
+
+ if has('win32')
+ " Windows uses 'set var=... && command'
+ AssertEqual
+ \ 'set HAML_LINT_RUBOCOP_CONF='
+ \ . ale#Escape(b:conf_rubocop)
+ \ . ' && haml-lint --config '
+ \ . ale#Escape(b:conf_hamllint)
+ \ . ' %t',
+ \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
+ else
+ " Unix uses 'var=... command'
+ AssertEqual
+ \ 'HAML_LINT_RUBOCOP_CONF='
+ \ . ale#Escape(b:conf_rubocop)
+ \ . ' haml-lint --config '
+ \ . ale#Escape(b:conf_hamllint)
+ \ . ' %t',
+ \ ale_linters#haml#hamllint#GetCommand(bufnr(''))
+ endif
diff --git a/test/command_callback/test_shellcheck_command_callback.vader b/test/command_callback/test_shellcheck_command_callback.vader
index 8e229056..13e9a2c1 100644
--- a/test/command_callback/test_shellcheck_command_callback.vader
+++ b/test/command_callback/test_shellcheck_command_callback.vader
@@ -9,6 +9,12 @@ Before:
runtime ale_linters/sh/shellcheck.vim
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#test#SetFilename('test.sh')
+
+ let b:prefix = 'cd ' . ale#Escape(ale#path#Winify(g:dir)) . ' && '
+ let b:suffix = ' -x -f gcc -'
+
After:
Restore
@@ -16,19 +22,22 @@ After:
unlet! b:ale_sh_shellcheck_executable
unlet! b:ale_sh_shellcheck_options
unlet! b:is_bash
+ unlet! b:prefix
+
+ call ale#test#RestoreDirectory()
call ale#linter#Reset()
Execute(The default shellcheck command should be correct):
AssertEqual
- \ 'shellcheck -f gcc -',
+ \ b:prefix . ale#Escape('shellcheck') . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''))
Execute(The shellcheck command should accept options):
let b:ale_sh_shellcheck_options = '--foobar'
AssertEqual
- \ 'shellcheck --foobar -f gcc -',
+ \ b:prefix . ale#Escape('shellcheck') . ' --foobar' . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''))
Execute(The shellcheck command should accept options and exclusions):
@@ -36,14 +45,14 @@ Execute(The shellcheck command should accept options and exclusions):
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
AssertEqual
- \ 'shellcheck --foobar -e foo,bar -f gcc -',
+ \ b:prefix . ale#Escape('shellcheck') . ' --foobar -e foo,bar' . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''))
Execute(The shellcheck command should include the dialect):
let b:is_bash = 1
AssertEqual
- \ 'shellcheck -s bash -f gcc -',
+ \ b:prefix . ale#Escape('shellcheck') . ' -s bash' . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''))
Execute(The shellcheck command should include the dialect before options and exclusions):
@@ -52,5 +61,8 @@ Execute(The shellcheck command should include the dialect before options and exc
let b:ale_sh_shellcheck_exclusions = 'foo,bar'
AssertEqual
- \ 'shellcheck -s bash --foobar -e foo,bar -f gcc -',
+ \ b:prefix
+ \ . ale#Escape('shellcheck')
+ \ . ' -s bash --foobar -e foo,bar'
+ \ . b:suffix,
\ ale_linters#sh#shellcheck#GetCommand(bufnr(''))
diff --git a/test/command_callback/test_write_good_command_callback.vader b/test/command_callback/test_write_good_command_callback.vader
new file mode 100644
index 00000000..d9f00495
--- /dev/null
+++ b/test/command_callback/test_write_good_command_callback.vader
@@ -0,0 +1,65 @@
+Before:
+ Save g:ale_writegood_options
+ Save g:ale_writegood_executable
+ Save g:ale_writegood_use_global
+
+ unlet! g:ale_writegood_options
+ unlet! g:ale_writegood_executable
+ unlet! g:ale_writegood_use_global
+
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#test#SetFilename('testfile.txt')
+
+ call ale#handlers#writegood#ResetOptions()
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The global executable should be used when the local one cannot be found):
+ AssertEqual 'write-good', ale#handlers#writegood#GetExecutable(bufnr(''))
+ AssertEqual
+ \ ale#Escape('write-good') . ' %t',
+ \ ale#handlers#writegood#GetCommand(bufnr(''))
+
+Execute(The options should be used in the command):
+ let g:ale_writegood_options = '--foo --bar'
+
+ AssertEqual
+ \ ale#Escape('write-good') . ' --foo --bar %t',
+ \ ale#handlers#writegood#GetCommand(bufnr(''))
+
+Execute(Should use the node_modules/.bin executable, if available):
+ call ale#test#SetFilename('write-good-node-modules/test.txt')
+
+ AssertEqual
+ \ ale#path#Winify(g:dir . '/write-good-node-modules/node_modules/.bin/write-good'),
+ \ ale#handlers#writegood#GetExecutable(bufnr(''))
+ AssertEqual
+ \ ale#Escape(ale#path#Winify(g:dir . '/write-good-node-modules/node_modules/.bin/write-good'))
+ \ . ' %t',
+ \ ale#handlers#writegood#GetCommand(bufnr(''))
+
+Execute(Should use the node_modules/write-good executable, if available):
+ call ale#test#SetFilename('write-good-node-modules-2/test.txt')
+
+ AssertEqual
+ \ ale#path#Winify(g:dir . '/write-good-node-modules-2/node_modules/write-good/bin/write-good.js'),
+ \ ale#handlers#writegood#GetExecutable(bufnr(''))
+ AssertEqual
+ \ (has('win32') ? 'node.exe ' : '')
+ \ . ale#Escape(ale#path#Winify(g:dir . '/write-good-node-modules-2/node_modules/write-good/bin/write-good.js'))
+ \ . ' %t',
+ \ ale#handlers#writegood#GetCommand(bufnr(''))
+
+Execute(Should let users configure a global executable and override local paths):
+ call ale#test#SetFilename('write-good-node-modules-2/test.txt')
+
+ let g:ale_writegood_executable = 'foo-bar'
+ let g:ale_writegood_use_global = 1
+
+ AssertEqual 'foo-bar', ale#handlers#writegood#GetExecutable(bufnr(''))
+ AssertEqual
+ \ ale#Escape('foo-bar') . ' %t',
+ \ ale#handlers#writegood#GetCommand(bufnr(''))
diff --git a/test/command_callback/write-good-node-modules-2/node_modules/write-good/bin/write-good.js b/test/command_callback/write-good-node-modules-2/node_modules/write-good/bin/write-good.js
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/write-good-node-modules-2/node_modules/write-good/bin/write-good.js
diff --git a/test/command_callback/write-good-node-modules/node_modules/.bin/write-good b/test/command_callback/write-good-node-modules/node_modules/.bin/write-good
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/command_callback/write-good-node-modules/node_modules/.bin/write-good
diff --git a/test/elixir-test-files/testfile.ex b/test/elixir-test-files/testfile.ex
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/elixir-test-files/testfile.ex
diff --git a/test/fixers/test_hfmt_fixer_callback.vader b/test/fixers/test_hfmt_fixer_callback.vader
new file mode 100644
index 00000000..69cd03f8
--- /dev/null
+++ b/test/fixers/test_hfmt_fixer_callback.vader
@@ -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(''))
diff --git a/test/fixers/test_mix_format_fixer_callback.vader b/test/fixers/test_mix_format_fixer_callback.vader
new file mode 100644
index 00000000..c6c97c57
--- /dev/null
+++ b/test/fixers/test_mix_format_fixer_callback.vader
@@ -0,0 +1,20 @@
+Before:
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+ Save g:ale_elixir_mix_executable
+
+ let g:ale_elixir_mix_executable = 'xxxinvalid'
+
+After:
+ call ale#test#RestoreDirectory()
+
+Execute(The mix_format callback should return the correct default values):
+ call ale#test#SetFilename('../elixir-test-files/testfile.ex')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' format %t',
+ \ },
+ \ ale#fixers#mix_format#Fix(bufnr(''))
+
diff --git a/test/fixers/test_prettier_fixer_callback.vader b/test/fixers/test_prettier_fixer_callback.vader
index cc7d34d0..471a8632 100644
--- a/test/fixers/test_prettier_fixer_callback.vader
+++ b/test/fixers/test_prettier_fixer_callback.vader
@@ -114,3 +114,17 @@ Execute(Append '--parser postcss' for filetype=css):
\ . ' --write',
\ },
\ ale#fixers#prettier#Fix(bufnr(''))
+
+Execute(Append '--parser postcss' for filetype=less):
+ set filetype=less
+ call ale#test#SetFilename('../prettier-test-files/testfile.less')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape(g:ale_javascript_prettier_executable)
+ \ . ' %t'
+ \ . ' --parser postcss'
+ \ . ' --write',
+ \ },
+ \ ale#fixers#prettier#Fix(bufnr(''))
diff --git a/test/fixers/test_rustfmt_fixer_callback.vader b/test/fixers/test_rustfmt_fixer_callback.vader
new file mode 100644
index 00000000..36dd58a1
--- /dev/null
+++ b/test/fixers/test_rustfmt_fixer_callback.vader
@@ -0,0 +1,38 @@
+Before:
+ Save g:ale_rust_rustfmt_executable
+ Save g:ale_rust_rustfmt_options
+
+ " Use an invalid global executable, so we don't match it.
+ let g:ale_rust_rustfmt_executable = 'xxxinvalid'
+ let g:ale_rust_rustfmt_options = ''
+
+ call ale#test#SetDirectory('/testplugin/test/fixers')
+
+After:
+ Restore
+
+ call ale#test#RestoreDirectory()
+
+Execute(The rustfmt callback should return the correct default values):
+ call ale#test#SetFilename('../rust_files/testfile.rs')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' %t',
+ \ },
+ \ ale#fixers#rustfmt#Fix(bufnr(''))
+
+Execute(The rustfmt callback should include custom rustfmt options):
+ let g:ale_rust_rustfmt_options = "--skip-children"
+ call ale#test#SetFilename('../rust_files/testfile.rs')
+
+ AssertEqual
+ \ {
+ \ 'read_temporary_file': 1,
+ \ 'command': ale#Escape('xxxinvalid')
+ \ . ' ' . g:ale_rust_rustfmt_options
+ \ . ' %t',
+ \ },
+ \ ale#fixers#rustfmt#Fix(bufnr(''))
diff --git a/test/hamllint-test-files/haml-lint-and-rubocop/.haml-lint.yml b/test/hamllint-test-files/haml-lint-and-rubocop/.haml-lint.yml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/hamllint-test-files/haml-lint-and-rubocop/.haml-lint.yml
diff --git a/test/hamllint-test-files/haml-lint-and-rubocop/.rubocop.yml b/test/hamllint-test-files/haml-lint-and-rubocop/.rubocop.yml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/hamllint-test-files/haml-lint-and-rubocop/.rubocop.yml
diff --git a/test/hamllint-test-files/haml-lint-and-rubocop/subdir/file.haml b/test/hamllint-test-files/haml-lint-and-rubocop/subdir/file.haml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/hamllint-test-files/haml-lint-and-rubocop/subdir/file.haml
diff --git a/test/hamllint-test-files/haml-lint-yml/.haml-lint.yml b/test/hamllint-test-files/haml-lint-yml/.haml-lint.yml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/hamllint-test-files/haml-lint-yml/.haml-lint.yml
diff --git a/test/hamllint-test-files/haml-lint-yml/subdir/file.haml b/test/hamllint-test-files/haml-lint-yml/subdir/file.haml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/hamllint-test-files/haml-lint-yml/subdir/file.haml
diff --git a/test/hamllint-test-files/rubocop-yml/.rubocop.yml b/test/hamllint-test-files/rubocop-yml/.rubocop.yml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/hamllint-test-files/rubocop-yml/.rubocop.yml
diff --git a/test/hamllint-test-files/rubocop-yml/subdir/file.haml b/test/hamllint-test-files/rubocop-yml/subdir/file.haml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/hamllint-test-files/rubocop-yml/subdir/file.haml
diff --git a/test/handler/test_checkmake_handler.vader b/test/handler/test_checkmake_handler.vader
new file mode 100644
index 00000000..61fe141a
--- /dev/null
+++ b/test/handler/test_checkmake_handler.vader
@@ -0,0 +1,19 @@
+Execute(Parsing checkmake errors should work):
+ runtime ale_linters/make/checkmake.vim
+ silent file Makefile
+
+ AssertEqual
+ \ [
+ \ {
+ \ 'bufnr': 42,
+ \ 'lnum': 1,
+ \ 'type': 'E',
+ \ 'text': 'woops: an error has occurred',
+ \ }
+ \ ],
+ \ ale_linters#make#checkmake#Handle(42, [
+ \ 'This shouldnt match',
+ \ '1:woops:an error has occurred',
+ \ ])
+After:
+ call ale#linter#Reset()
diff --git a/test/handler/test_clang_handler.vader b/test/handler/test_clang_handler.vader
index d28b9eb8..278737a8 100644
--- a/test/handler/test_clang_handler.vader
+++ b/test/handler/test_clang_handler.vader
@@ -2,15 +2,11 @@ Execute(clang errors from included files should be parsed correctly):
AssertEqual
\ [
\ {
- \ 'lnum': 3,
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'filename': './b.h',
\ 'type': 'E',
- \ 'text': 'Problems were found in the header (See :ALEDetail)',
- \ 'detail': join([
- \ './b.h:1:1: error: expected identifier or ''(''',
- \ '{{{',
- \ '^',
- \ '1 error generated.',
- \ ], "\n"),
+ \ 'text': 'expected identifier or ''(''',
\ },
\ ],
\ ale#handlers#gcc#HandleGCCFormat(347, [
diff --git a/test/handler/test_gcc_handler.vader b/test/handler/test_gcc_handler.vader
index 2f60390c..9324273e 100644
--- a/test/handler/test_gcc_handler.vader
+++ b/test/handler/test_gcc_handler.vader
@@ -1,15 +1,21 @@
+Execute(The GCC handler should ignore other lines of output):
+ AssertEqual
+ \ [],
+ \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ 'foo',
+ \ 'bar',
+ \ 'baz',
+ \ ])
+
Execute(GCC errors from included files should be parsed correctly):
AssertEqual
\ [
\ {
- \ 'lnum': 3,
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'filename': 'broken.h',
\ 'type': 'E',
- \ 'text': 'Problems were found in the header (See :ALEDetail)',
- \ 'detail': join([
- \ 'broken.h:1:1: error: expected identifier or ''('' before ''{'' token',
- \ ' {{{',
- \ ' ^',
- \ ], "\n"),
+ \ 'text': 'expected identifier or ''('' before ''{'' token',
\ },
\ ],
\ ale#handlers#gcc#HandleGCCFormat(347, [
@@ -22,14 +28,11 @@ Execute(GCC errors from included files should be parsed correctly):
AssertEqual
\ [
\ {
- \ 'lnum': 3,
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'filename': 'b.h',
\ 'type': 'E',
- \ 'text': 'Problems were found in the header (See :ALEDetail)',
- \ 'detail': join([
- \ 'b.h:1:1: error: expected identifier or ''('' before ''{'' token',
- \ ' {{{',
- \ ' ^',
- \ ], "\n"),
+ \ 'text': 'expected identifier or ''('' before ''{'' token',
\ },
\ ],
\ ale#handlers#gcc#HandleGCCFormat(347, [
@@ -43,17 +46,18 @@ Execute(GCC errors from included files should be parsed correctly):
AssertEqual
\ [
\ {
- \ 'lnum': 3,
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'filename': 'b.h',
+ \ 'type': 'E',
+ \ 'text': 'unknown type name ''bad_type''',
+ \ },
+ \ {
+ \ 'lnum': 2,
+ \ 'col': 1,
+ \ 'filename': 'b.h',
\ 'type': 'E',
- \ 'text': 'Problems were found in the header (See :ALEDetail)',
- \ 'detail': join([
- \ 'b.h:1:1: error: unknown type name ‘bad_type’',
- \ ' bad_type x;',
- \ ' ^',
- \ 'b.h:2:1: error: unknown type name ‘other_bad_type’',
- \ ' other_bad_type y;',
- \ ' ^',
- \ ], "\n"),
+ \ 'text': 'unknown type name ''other_bad_type''',
\ },
\ ],
\ ale#handlers#gcc#HandleGCCFormat(347, [
@@ -133,3 +137,25 @@ Execute(The GCC handler should handle syntax errors):
\ '<stdin>:4: error: ''cat'' was not declared in this scope',
\ '<stdin>:12: error: expected `;'' before ''o''',
\ ])
+
+Execute(The GCC handler should handle notes with no previous message):
+ AssertEqual
+ \ [],
+ \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ '<stdin>:1:1: note: x',
+ \ '<stdin>:1:1: note: x',
+ \ ])
+
+Execute(The GCC handler should interpret - as being the current file):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 6,
+ \ 'col': 12,
+ \ 'type': 'E',
+ \ 'text': 'Some error',
+ \ },
+ \ ],
+ \ ale#handlers#gcc#HandleGCCFormat(347, [
+ \ '-:6:12: error: Some error',
+ \ ])
diff --git a/test/handler/test_php_phan_handler.vader b/test/handler/test_php_phan_handler.vader
new file mode 100644
index 00000000..68ed6d06
--- /dev/null
+++ b/test/handler/test_php_phan_handler.vader
@@ -0,0 +1,24 @@
+Before:
+ runtime ale_linters/php/phan.vim
+
+Execute(The php static analyzer handler should parse errors from phan):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 25,
+ \ 'type': 'W',
+ \ 'text': 'Return type of getValidator is undeclared type \Respect\Validation\Validator',
+ \ },
+ \ {
+ \ 'lnum': 66,
+ \ 'type': 'W',
+ \ 'text': 'Call to method string from undeclared class \Respect\Validation\Validator',
+ \ },
+ \ ],
+ \ ale_linters#php#phan#Handle(347, [
+ \ "example.php:25 PhanUndeclaredTypeReturnType Return type of getValidator is undeclared type \\Respect\\Validation\\Validator",
+ \ "example.php:66 PhanUndeclaredClassMethod Call to method string from undeclared class \\Respect\\Validation\\Validator",
+ \ ])
+
+After:
+ call ale#linter#Reset()
diff --git a/test/handler/test_php_phpmd_handler.vader b/test/handler/test_php_phpmd_handler.vader
new file mode 100644
index 00000000..be36f3db
--- /dev/null
+++ b/test/handler/test_php_phpmd_handler.vader
@@ -0,0 +1,24 @@
+Before:
+ runtime ale_linters/php/phpmd.vim
+
+Execute(The php static analyzer handler should parse errors from phpmd):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 22,
+ \ 'type': 'W',
+ \ 'text': "Avoid unused local variables such as '$response'.",
+ \ },
+ \ {
+ \ 'lnum': 14,
+ \ 'type': 'W',
+ \ 'text': "The method test uses an else expression. Else is never necessary and you can simplify the code to work without else.",
+ \ },
+ \ ],
+ \ ale_linters#php#phpmd#Handle(347, [
+ \ "example.php:22 Avoid unused local variables such as '$response'.",
+ \ "example.php:14 The method test uses an else expression. Else is never necessary and you can simplify the code to work without else.",
+ \ ])
+
+After:
+ call ale#linter#Reset()
diff --git a/test/handler/test_remark_lint_handler.vader b/test/handler/test_remark_lint_handler.vader
new file mode 100644
index 00000000..f63e0c5b
--- /dev/null
+++ b/test/handler/test_remark_lint_handler.vader
@@ -0,0 +1,27 @@
+Before:
+ runtime ale_linters/markdown/remark_lint.vim
+
+Execute(Warning and error messages should be handled correctly):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 4,
+ \ 'type': 'W',
+ \ 'text': 'Incorrect list-item indent: add 1 space list-item-indent remark-lint',
+ \ },
+ \ {
+ \ 'lnum': 3,
+ \ 'col': 5,
+ \ 'type': 'E',
+ \ 'text': 'Incorrect list-item indent: remove 1 space list-item-indent remark-lint',
+ \ },
+ \ ],
+ \ ale_linters#markdown#remark_lint#Handle(1, [
+ \ 'foo.md',
+ \ ' 1:4 warning Incorrect list-item indent: add 1 space list-item-indent remark-lint',
+ \ ' 3:5 error Incorrect list-item indent: remove 1 space list-item-indent remark-lint',
+ \ '',
+ \ '⚠ 1 warnings',
+ \ '✘ 1 errors',
+ \])
diff --git a/test/handler/test_vint_handler.vader b/test/handler/test_vint_handler.vader
index 8747979c..c542b4ea 100644
--- a/test/handler/test_vint_handler.vader
+++ b/test/handler/test_vint_handler.vader
@@ -10,12 +10,14 @@ Execute(The vint handler should parse error messages correctly):
\ {
\ 'lnum': 1,
\ 'col': 1,
+ \ 'filename': 'gcc.vim',
\ 'text': 'Use scriptencoding when multibyte char exists (see :help :script encoding)',
\ 'type': 'W',
\ },
\ {
\ 'lnum': 3,
\ 'col': 17,
+ \ 'filename': 'gcc.vim',
\ 'end_col': 18,
\ 'text': 'Use robust operators ''==#'' or ''==?'' instead of ''=='' (see Google VimScript Style Guide (Matching))',
\ 'type': 'W',
@@ -23,6 +25,7 @@ Execute(The vint handler should parse error messages correctly):
\ {
\ 'lnum': 3,
\ 'col': 8,
+ \ 'filename': 'gcc.vim',
\ 'end_col': 15,
\ 'text': 'Make the scope explicit like ''l:filename'' (see Anti-pattern of vimrc (Scope of identifier))',
\ 'type': 'W',
@@ -30,6 +33,7 @@ Execute(The vint handler should parse error messages correctly):
\ {
\ 'lnum': 7,
\ 'col': 8,
+ \ 'filename': 'gcc.vim',
\ 'end_col': 15,
\ 'text': 'Undefined variable: filename (see :help E738)',
\ 'type': 'W',
@@ -37,6 +41,7 @@ Execute(The vint handler should parse error messages correctly):
\ {
\ 'lnum': 8,
\ 'col': 11,
+ \ 'filename': 'gcc.vim',
\ 'end_col': 16,
\ 'text': 'E128: Function name must start with a capital or contain a colon: foobar (see ynkdir/vim-vimlparser)',
\ 'type': 'E',
@@ -44,6 +49,7 @@ Execute(The vint handler should parse error messages correctly):
\ {
\ 'lnum': 9,
\ 'col': 12,
+ \ 'filename': 'gcc.vim',
\ 'end_col': 13,
\ 'text': 'Use robust operators ''=~#'' or ''=~?'' instead of ''=~'' (see Google VimScript Style Guide (Matching))',
\ 'type': 'W',
diff --git a/test/handler/test_write_good_handler.vader b/test/handler/test_write_good_handler.vader
new file mode 100644
index 00000000..8bf4b223
--- /dev/null
+++ b/test/handler/test_write_good_handler.vader
@@ -0,0 +1,37 @@
+Execute(The write-good handler should handle the example from the write-good README):
+ AssertEqual
+ \ [
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 1,
+ \ 'end_col': 2,
+ \ 'type': 'W',
+ \ 'text': '"So" adds no meaning',
+ \ },
+ \ {
+ \ 'lnum': 1,
+ \ 'col': 12,
+ \ 'end_col': 21,
+ \ 'type': 'W',
+ \ 'text': '"was stolen" may be passive voice',
+ \ },
+ \ {
+ \ 'lnum': 6,
+ \ 'col': 2,
+ \ 'end_col': 2,
+ \ 'type': 'W',
+ \ 'text': '"foo bar" bla',
+ \ },
+ \ ],
+ \ ale#handlers#writegood#Handle(bufnr(''), [
+ \ 'In /tmp/vBYivbZ/6/test.md',
+ \ '=============',
+ \ 'So the cat was stolen.',
+ \ '^^',
+ \ '"So" adds no meaning on line 1 at column 0',
+ \ '-------------',
+ \ 'So the cat was stolen.',
+ \ ' ^^^^^^^^^^',
+ \ '"was stolen" may be passive voice on line 1 at column 11',
+ \ '"foo bar" bla on line 6 at column 1',
+ \ ])
diff --git a/test/rust_files/testfile.rs b/test/rust_files/testfile.rs
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/test/rust_files/testfile.rs
diff --git a/test/script/check-supported-tools-tables b/test/script/check-supported-tools-tables
index 1d0fec53..32cebb2d 100755
--- a/test/script/check-supported-tools-tables
+++ b/test/script/check-supported-tools-tables
@@ -30,30 +30,30 @@ readme_section_size="$( \
# shellcheck disable=SC2003
readme_end_line="$(expr "$readme_start_line" + "$readme_section_size")"
-doc_file="$(mktemp)"
-readme_file="$(mktemp)"
+doc_file="$(mktemp -t doc.XXXXXXXX)"
+readme_file="$(mktemp -t readme.XXXXXXXX)"
sed -n "$ale_help_start_line,$ale_help_end_line"p doc/ale.txt \
| grep '\* .*: ' \
| sed 's/^*//' \
- | sed 's/[`!^]\|([^)]*)//g' \
+ | sed 's/[`!^]//g;s/([^)]*)//g' \
| sed 's/ *\([,:]\)/\1/g' \
| sed 's/ */ /g' \
- | sed 's/^ *\| *$//g' \
+ | sed 's/^ *//;s/ *$//' \
| sed 's/^/ /' \
> "$doc_file"
sed -n "$readme_start_line,$readme_end_line"p README.md \
| grep '| .* |' \
- | sed '/^| Language\|^| ---/d' \
+ | sed '/^| Language/d;/^| ---/d' \
| sed 's/^|//' \
- | sed 's/ \?|/:/' \
- | sed 's/[`!^|]\|([^)]*)//g' \
- | sed 's/\[\|\]//g' \
- | sed 's/see[^,]*\(,\|$\)/\1/g' \
+ | sed 's/ \{0,1\}|/:/' \
+ | sed 's/[`!^|]//g;s/([^)]*)//g' \
+ | sed 's/\[//g;s/\]//g' \
+ | sed 's/see[^,]*//g' \
| sed 's/ *\([,:]\)/\1/g' \
| sed 's/ */ /g' \
- | sed 's/^ *\| *$//g' \
+ | sed 's/^ *//;s/ *$//' \
| sed 's/^/ /' \
| sed 's/ *-n flag//g' \
> "$readme_file"
diff --git a/test/script/check-toc b/test/script/check-toc
index c4512b08..cc2d2b9c 100755
--- a/test/script/check-toc
+++ b/test/script/check-toc
@@ -23,18 +23,19 @@ tagged_toc_file="$(mktemp -t ale.txt.XXXXXXXX)"
sorted_toc_file="$(mktemp -t sorted-ale.txt.XXXXXXXX)"
sed -n "$toc_start_line,$toc_end_line"p doc/ale.txt \
- | sed 's/^ \( *[^.]\+\)\.\+|\(.\+\)|/\1, \2/' \
+ | sed 's/^ \( *[^.][^.]*\)\.\.*|\(..*\)|/\1, \2/' \
> "$toc_file"
# Get all of the doc files in a natural sorted order.
-doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ')"
+doc_files="$(/bin/ls -1v doc | grep ^ale- | sed 's/^/doc\//' | paste -sd ' ' -)"
# shellcheck disable=SC2086
-grep -h 'ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \
+grep -h '\*ale-.*-options\|^[a-z].*\*ale-.*\*$' $doc_files \
| sed 's/^/ /' \
| sed 's/ALE Shell Integration/ALE sh Integration/' \
- | sed 's/ ALE \(.*\) Integration/\L\1/' \
- | sed 's/ *\*\(.\+\)\*$/, \1/' \
+ | sed 's/ ALE \(.*\) Integration/\1/' \
+ | sed 's/ *\*\(..*\)\*$/, \1/' \
+ | tr '[:upper:]' '[:lower:]' \
| sed 's/objective-c/objc/' \
| sed 's/c++/cpp/' \
> "$heading_file"
@@ -62,7 +63,7 @@ while read -r; do
done < "$toc_file"
# Sort the sections and sub-sections and remove the tags.
-sort -h "$tagged_toc_file" | sed 's/[0-9]\+ //' > "$sorted_toc_file"
+sort -sn "$tagged_toc_file" | sed 's/[0-9][0-9]* //' > "$sorted_toc_file"
echo 'Check for bad ToC sorting:'
echo
diff --git a/test/sign/test_linting_sets_signs.vader b/test/sign/test_linting_sets_signs.vader
index c2cc0db9..c23b4002 100644
--- a/test/sign/test_linting_sets_signs.vader
+++ b/test/sign/test_linting_sets_signs.vader
@@ -20,7 +20,7 @@ Before:
let l:actual_sign_list = []
for l:line in split(l:output, "\n")
- let l:match = matchlist(l:line, 'line=\(\d\+\).*name=\(ALE[a-zA-Z]\+\)')
+ let l:match = matchlist(l:line, '\v^.*\=(\d+).*\=\d+.*\=(ALE[a-zA-Z]+Sign)')
if len(l:match) > 0
call add(l:actual_sign_list, [l:match[1], l:match[2]])
@@ -34,7 +34,7 @@ Before:
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
\ 'executable': has('win32') ? 'cmd' : 'echo',
- \ 'command': 'echo foo bar',
+ \ 'command': has('win32') ? 'echo foo bar' : '/bin/sh -c ''echo foo bar''',
\})
diff --git a/test/test_ale_fix.vader b/test/test_ale_fix.vader
index b5c16724..9968c4a5 100644
--- a/test/test_ale_fix.vader
+++ b/test/test_ale_fix.vader
@@ -11,11 +11,18 @@ Before:
let g:ale_enabled = 0
let g:ale_echo_cursor = 0
let g:ale_run_synchronously = 1
+ let g:ale_set_lists_synchronously = 1
let g:ale_fix_buffer_data = {}
let g:ale_fixers = {
\ 'testft': [],
\}
- let &shell = '/bin/bash'
+
+ if !has('win32')
+ let &shell = '/bin/bash'
+ endif
+
+ call ale#test#SetDirectory('/testplugin/test')
+ call ale#test#SetFilename('test.txt')
function AddCarets(buffer, lines) abort
" map() is applied to the original lines here.
@@ -67,6 +74,7 @@ Before:
After:
Restore
unlet! g:ale_run_synchronously
+ unlet! g:ale_set_lists_synchronously
unlet! g:ale_emulate_job_failure
unlet! b:ale_fixers
delfunction AddCarets
@@ -79,6 +87,9 @@ After:
delfunction RemoveLastLineOneArg
delfunction TestCallback
delfunction SetUpLinters
+
+ call ale#test#RestoreDirectory()
+
call ale#fix#registry#ResetToDefaults()
call ale#linter#Reset()
@@ -129,8 +140,13 @@ Expect(Only the second function should be applied):
$c
Execute(ALEFix should allow commands to be run):
- let g:ale_fixers.testft = ['CatLine']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['a', 'b', 'c', 'd'])
+ else
+ let g:ale_fixers.testft = ['CatLine']
+ ALEFix
+ endif
Expect(An extra line should be added):
a
@@ -139,22 +155,39 @@ Expect(An extra line should be added):
d
Execute(ALEFix should allow temporary files to be read):
- let g:ale_fixers.testft = ['ReplaceWithTempFile']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['x'])
+ 2,3d
+ else
+ let g:ale_fixers.testft = ['ReplaceWithTempFile']
+ ALEFix
+ endif
Expect(The line we wrote to the temporary file should be used here):
x
Execute(ALEFix should allow jobs and simple functions to be combined):
- let g:ale_fixers.testft = ['ReplaceWithTempFile', 'AddDollars']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['$x'])
+ 2,3d
+ else
+ let g:ale_fixers.testft = ['ReplaceWithTempFile', 'AddDollars']
+ ALEFix
+ endif
Expect(The lines from the temporary file should be modified):
$x
Execute(ALEFix should send lines modified by functions to jobs):
- let g:ale_fixers.testft = ['AddDollars', 'CatLine']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['$a', '$b', '$c', 'd'])
+ else
+ let g:ale_fixers.testft = ['AddDollars', 'CatLine']
+ ALEFix
+ endif
Expect(The lines should first be modified by the function, then the job):
$a
@@ -257,18 +290,20 @@ Execute(ALEFix should save files on the save event):
AssertEqual ['$a', '$b', '$c'], readfile('fix_test_file')
Assert !&modified, 'The was marked as ''modified'''
- " We have run the linter.
- AssertEqual [{
- \ 'bufnr': bufnr('%'),
- \ 'lnum': 1,
- \ 'vcol': 0,
- \ 'col': 1,
- \ 'text': 'xxx',
- \ 'type': 'E',
- \ 'nr': -1,
- \ 'pattern': '',
- \ 'valid': 1,
- \}], getloclist(0)
+ if !has('win32')
+ " We should have run the linter.
+ AssertEqual [{
+ \ 'bufnr': bufnr('%'),
+ \ 'lnum': 1,
+ \ 'vcol': 0,
+ \ 'col': 1,
+ \ 'text': 'xxx',
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'pattern': '',
+ \ 'valid': 1,
+ \}], getloclist(0)
+ endif
Expect(The buffer should be modified):
$a
@@ -294,18 +329,20 @@ Execute(ALEFix should still lint with no linters to be applied):
Assert !filereadable('fix_test_file'), 'The file should not have been saved'
- " We have run the linter.
- AssertEqual [{
- \ 'bufnr': bufnr('%'),
- \ 'lnum': 1,
- \ 'vcol': 0,
- \ 'col': 1,
- \ 'text': 'xxx',
- \ 'type': 'E',
- \ 'nr': -1,
- \ 'pattern': '',
- \ 'valid': 1,
- \}], getloclist(0)
+ if !has('win32')
+ " We have run the linter.
+ AssertEqual [{
+ \ 'bufnr': bufnr('%'),
+ \ 'lnum': 1,
+ \ 'vcol': 0,
+ \ 'col': 1,
+ \ 'text': 'xxx',
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'pattern': '',
+ \ 'valid': 1,
+ \}], getloclist(0)
+ endif
Expect(The buffer should be the same):
a
@@ -326,18 +363,20 @@ Execute(ALEFix should still lint when nothing was fixed on save):
Assert !filereadable('fix_test_file'), 'The file should not have been saved'
- " We have run the linter.
- AssertEqual [{
- \ 'bufnr': bufnr('%'),
- \ 'lnum': 1,
- \ 'vcol': 0,
- \ 'col': 1,
- \ 'text': 'xxx',
- \ 'type': 'E',
- \ 'nr': -1,
- \ 'pattern': '',
- \ 'valid': 1,
- \}], getloclist(0)
+ if !has('win32')
+ " We should have run the linter.
+ AssertEqual [{
+ \ 'bufnr': bufnr('%'),
+ \ 'lnum': 1,
+ \ 'vcol': 0,
+ \ 'col': 1,
+ \ 'text': 'xxx',
+ \ 'type': 'E',
+ \ 'nr': -1,
+ \ 'pattern': '',
+ \ 'valid': 1,
+ \}], getloclist(0)
+ endif
Expect(The buffer should be the same):
a
@@ -358,7 +397,7 @@ Execute(ale#fix#InitBufferData() should set up the correct data):
\ bufnr(''): {
\ 'temporary_directory_list': [],
\ 'vars': b:,
- \ 'filename': simplify(getcwd() . '/fix_test_file'),
+ \ 'filename': ale#path#Winify(getcwd() . '/fix_test_file'),
\ 'done': 0,
\ 'lines_before': ['a', 'b', 'c'],
\ 'should_save': 1,
@@ -374,8 +413,13 @@ Expect(There should be only two lines):
b
Execute(ALEFix functions returning jobs should be able to accept one argument):
- let g:ale_fixers.testft = ['CatLine']
- ALEFix
+ if has('win32')
+ " Just skip this test on Windows, we can't run it.
+ call setline(1, ['a', 'b', 'c', 'd'])
+ else
+ let g:ale_fixers.testft = ['CatLine']
+ ALEFix
+ endif
Expect(An extra line should be added):
a
diff --git a/test/test_ale_info.vader b/test/test_ale_info.vader
index 8ab5ad54..ceb65af6 100644
--- a/test/test_ale_info.vader
+++ b/test/test_ale_info.vader
@@ -354,7 +354,7 @@ Execute (ALEInfo command history should print command output if logging is on):
Execute (ALEInfo should include executable checks in the history):
call ale#linter#Define('testft', g:testlinter1)
- call ale#engine#IsExecutable(bufnr(''), 'echo')
+ call ale#engine#IsExecutable(bufnr(''), has('win32') ? 'cmd' : 'echo')
call ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
call CheckInfo([
@@ -365,6 +365,6 @@ Execute (ALEInfo should include executable checks in the history):
\ '',
\] + g:globals_lines + g:command_header + [
\ '',
- \ '(executable check - success) echo',
+ \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'),
\ '(executable check - failure) TheresNoWayThisIsExecutable',
\])
diff --git a/test/test_ale_lint_command.vader b/test/test_ale_lint_command.vader
index 42554ec1..d36b2177 100644
--- a/test/test_ale_lint_command.vader
+++ b/test/test_ale_lint_command.vader
@@ -28,7 +28,7 @@ Before:
\ 'lnum': 2,
\ 'vcol': 0,
\ 'col': 3,
- \ 'text': a:output[0],
+ \ 'text': join(split(a:output[0])),
\ 'type': 'E',
\ 'nr': -1,
\}]
@@ -37,7 +37,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'ToggleTestCallback',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo foo bar',
\})
@@ -63,5 +63,11 @@ Execute(ALELint should run the linters):
ALELint
call ale#engine#WaitForJobs(2000)
+ if !has('nvim')
+ " Sleep so the delayed list function can run.
+ " This breaks the tests in NeoVim for some reason.
+ sleep 1ms
+ endif
+
" Check the loclist
AssertEqual g:expected_loclist, getloclist(0)
diff --git a/test/test_ale_toggle.vader b/test/test_ale_toggle.vader
index f5d8599f..f3dbf102 100644
--- a/test/test_ale_toggle.vader
+++ b/test/test_ale_toggle.vader
@@ -67,7 +67,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'ToggleTestCallback',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo',
\ 'read_buffer': 0,
\})
diff --git a/test/test_c_import_paths.vader b/test/test_c_import_paths.vader
index dac73f08..af185eae 100644
--- a/test/test_c_import_paths.vader
+++ b/test/test_c_import_paths.vader
@@ -39,8 +39,8 @@ Execute(The C GCC handler should include 'include' directories for projects with
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
@@ -52,8 +52,8 @@ Execute(The C GCC handler should include 'include' directories for projects with
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
@@ -65,8 +65,8 @@ Execute(The C GCC handler should include root directories for projects with .h f
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
@@ -78,8 +78,8 @@ Execute(The C GCC handler should include root directories for projects with .hpp
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr(''))
@@ -91,8 +91,8 @@ Execute(The C Clang handler should include 'include' directories for projects wi
AssertEqual
\ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr(''))
@@ -104,8 +104,8 @@ Execute(The C Clang handler should include 'include' directories for projects wi
AssertEqual
\ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr(''))
@@ -117,8 +117,8 @@ Execute(The C Clang handler should include root directories for projects with .h
AssertEqual
\ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr(''))
@@ -130,8 +130,8 @@ Execute(The C Clang handler should include root directories for projects with .h
AssertEqual
\ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr(''))
@@ -143,8 +143,8 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@@ -156,8 +156,8 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@@ -169,8 +169,8 @@ Execute(The C++ GCC handler should include root directories for projects with .h
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@@ -182,8 +182,8 @@ Execute(The C++ GCC handler should include root directories for projects with .h
AssertEqual
\ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@@ -195,8 +195,8 @@ Execute(The C++ Clang handler should include 'include' directories for projects
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -208,8 +208,8 @@ Execute(The C++ Clang handler should include 'include' directories for projects
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -221,8 +221,8 @@ Execute(The C++ Clang handler should include root directories for projects with
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -234,8 +234,8 @@ Execute(The C++ Clang handler should include root directories for projects with
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -255,8 +255,8 @@ Execute(The C++ Clang handler shoud use the include directory based on the .git
AssertEqual
\ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only '
- \ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/git_and_nested_makefiles/src') . ' '
- \ . ' -I' . ale#Escape(g:dir . '/test_c_projects/git_and_nested_makefiles/include') . ' '
+ \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles/src')) . ' '
+ \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles') . '/include') . ' '
\ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@@ -267,8 +267,8 @@ Execute(The C++ ClangTidy handler should include json folders for projects with
AssertEqual
\ ale#Escape('clang-tidy')
- \ . ' -checks=''*'' %s '
- \ . '-p ' . ale#Escape(g:dir . '/test_c_projects/json_project/build')
+ \ . ' -checks=' . ale#Escape('*') . ' %s '
+ \ . '-p ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/json_project') . '/build')
\ , ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(Move .git/HEAD back):
diff --git a/test/test_command_chain.vader b/test/test_command_chain.vader
index 16472041..9059d630 100644
--- a/test/test_command_chain.vader
+++ b/test/test_command_chain.vader
@@ -1,7 +1,11 @@
Before:
Save &shell, g:ale_run_synchronously
let g:ale_run_synchronously = 1
- set shell=/bin/sh
+
+ if !has('win32')
+ set shell=/bin/sh
+ endif
+
let g:linter_output = []
let g:first_echo_called = 0
let g:second_echo_called = 0
@@ -9,7 +13,7 @@ Before:
function! CollectResults(buffer, output)
let g:final_callback_called = 1
- let g:linter_output = a:output
+ let g:linter_output = map(copy(a:output), 'join(split(v:val))')
return []
endfunction
function! RunFirstEcho(buffer)
@@ -26,7 +30,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'CollectResults',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command_chain': [
\ {
\ 'callback': 'RunFirstEcho',
diff --git a/test/test_csslint_config_detection.vader b/test/test_csslint_config_detection.vader
index b4707dc0..d84a00f9 100644
--- a/test/test_csslint_config_detection.vader
+++ b/test/test_csslint_config_detection.vader
@@ -13,7 +13,7 @@ Execute(--config should be set when the .csslintrc file is found):
AssertEqual
\ (
\ 'csslint --format=compact '
- \ . '--config=' . shellescape(g:dir . '/csslint-test-files/some-app/.csslintrc')
+ \ . '--config=' . ale#Escape(ale#path#Winify(g:dir . '/csslint-test-files/some-app/.csslintrc'))
\ . ' %t'
\ ),
\ ale_linters#css#csslint#GetCommand(bufnr(''))
diff --git a/test/test_elm_executable_detection.vader b/test/test_elm_executable_detection.vader
index 7b758fc2..cca8a6e4 100644
--- a/test/test_elm_executable_detection.vader
+++ b/test/test_elm_executable_detection.vader
@@ -12,7 +12,7 @@ Execute(should get valid executable with default params):
call ale#test#SetFilename('elm-test-files/app/testfile.elm')
AssertEqual
- \ g:dir . '/elm-test-files/app/node_modules/.bin/elm-make',
+ \ ale#path#Winify(g:dir . '/elm-test-files/app/node_modules/.bin/elm-make'),
\ ale_linters#elm#make#GetExecutable(bufnr(''))
Execute(should get valid executable with 'use_global' params):
diff --git a/test/test_errors_removed_after_filetype_changed.vader b/test/test_errors_removed_after_filetype_changed.vader
index 0498a501..92d248d0 100644
--- a/test/test_errors_removed_after_filetype_changed.vader
+++ b/test/test_errors_removed_after_filetype_changed.vader
@@ -13,7 +13,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'buffer_linter',
\ 'callback': 'TestCallback',
- \ 'executable': 'true',
+ \ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true',
\ 'read_buffer': 0,
\})
@@ -21,7 +21,7 @@ Before:
call ale#linter#Define('foobar2', {
\ 'name': 'buffer_linter',
\ 'callback': 'TestCallback',
- \ 'executable': 'true',
+ \ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true',
\ 'read_buffer': 0,
\})
@@ -41,12 +41,14 @@ After:
Execute(Error should be removed when the filetype changes to something else we cannot check):
call ale#Queue(0)
+ sleep 1ms
AssertEqual 1, len(getloclist(0))
noautocmd let &filetype = 'foobar2'
call ale#Queue(0)
+ sleep 1ms
" We should get some items from the second filetype.
AssertEqual 1, len(getloclist(0))
@@ -54,5 +56,6 @@ Execute(Error should be removed when the filetype changes to something else we c
noautocmd let &filetype = 'xxx'
call ale#Queue(0)
+ sleep 1ms
AssertEqual 0, len(getloclist(0))
diff --git a/test/test_eslint_executable_detection.vader b/test/test_eslint_executable_detection.vader
index 411fa134..ee792421 100644
--- a/test/test_eslint_executable_detection.vader
+++ b/test/test_eslint_executable_detection.vader
@@ -17,7 +17,7 @@ Execute(create-react-app directories should be detected correctly):
call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
AssertEqual
- \ g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js',
+ \ ale#path#Winify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'),
\ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(use-global should override create-react-app detection):
@@ -33,7 +33,7 @@ Execute(other app directories should be detected correctly):
call ale#test#SetFilename('eslint-test-files/other-app/subdir/testfile.js')
AssertEqual
- \ g:dir . '/eslint-test-files/node_modules/.bin/eslint',
+ \ ale#path#Winify(g:dir . '/eslint-test-files/node_modules/.bin/eslint'),
\ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(use-global should override other app directories):
@@ -49,7 +49,7 @@ Execute(eslint_d should be detected correctly):
call ale#test#SetFilename('eslint-test-files/app-with-eslint-d/testfile.js')
AssertEqual
- \ g:dir . '/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d',
+ \ ale#path#Winify(g:dir . '/eslint-test-files/app-with-eslint-d/node_modules/.bin/eslint_d'),
\ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(eslint.js executables should be run with node on Windows):
@@ -59,6 +59,6 @@ Execute(eslint.js executables should be run with node on Windows):
" We have to execute the file with node.
AssertEqual
\ ale#Escape('node.exe') . ' '
- \ . ale#Escape(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js')
+ \ . ale#Escape(ale#path#Winify(g:dir . '/eslint-test-files/react-app/node_modules/eslint/bin/eslint.js'))
\ . ' -f unix --stdin --stdin-filename %s',
\ ale#handlers#eslint#GetCommand(bufnr(''))
diff --git a/test/test_find_nearest_directory.vader b/test/test_find_nearest_directory.vader
index 03d38862..1442c8fc 100644
--- a/test/test_find_nearest_directory.vader
+++ b/test/test_find_nearest_directory.vader
@@ -8,7 +8,7 @@ Execute(We should be able to find a directory some directory down):
call ale#test#SetFilename('top/middle/bottom/dummy.txt')
AssertEqual
- \ expand('%:p:h:h:h:h') . '/top/ale-special-directory-name-dont-use-this-please/',
+ \ ale#path#Winify(expand('%:p:h:h:h:h') . '/top/ale-special-directory-name-dont-use-this-please/'),
\ ale#path#FindNearestDirectory(bufnr('%'), 'ale-special-directory-name-dont-use-this-please')
Execute(We shouldn't find anything for files which don't match):
diff --git a/test/test_flow_command.vader b/test/test_flow_command.vader
index d9842869..32ceb57c 100644
--- a/test/test_flow_command.vader
+++ b/test/test_flow_command.vader
@@ -9,13 +9,17 @@ After:
Execute(flow should return a command to run if a .flowconfig file exists):
call ale#test#SetFilename('flow/a/sub/dummy')
- AssertEqual '''flow'' check-contents --respect-pragma --json --from ale %s', ale_linters#javascript#flow#GetCommand(bufnr('%'), [])
+ AssertEqual
+ \ ale#Escape('flow')
+ \ . ' check-contents --respect-pragma --json --from ale %s',
+ \ ale_linters#javascript#flow#GetCommand(bufnr('%'), [])
Execute(flow should should not use --respect-pragma for old versions):
call ale#test#SetFilename('flow/a/sub/dummy')
AssertEqual
- \ '''flow'' check-contents --json --from ale %s',
+ \ ale#Escape('flow')
+ \ . ' check-contents --json --from ale %s',
\ ale_linters#javascript#flow#GetCommand(bufnr('%'), [
\ 'Warning: `flow --version` is deprecated in favor of `flow version`',
\ 'Flow, a static type checker for JavaScript, version 0.27.0',
diff --git a/test/test_format_command.vader b/test/test_format_command.vader
index 156ced9b..f6143a5a 100644
--- a/test/test_format_command.vader
+++ b/test/test_format_command.vader
@@ -2,10 +2,18 @@ Before:
silent! cd /testplugin/test
silent file top/middle/bottom/dummy.txt
+ function! CheckTempFile(filename) abort
+ " Check every part of the temporary filename, except the random part.
+ AssertEqual fnamemodify(tempname(), ':h'), fnamemodify(a:filename, ':h:h')
+ AssertEqual 'dummy.txt', fnamemodify(a:filename, ':t')
+ endfunction
+
After:
unlet! g:result
unlet! g:match
+ delfunction CheckTempFile
+
Execute(FormatCommand should do nothing to basic command strings):
AssertEqual ['', 'awesome-linter do something'], ale#command#FormatCommand(bufnr('%'), 'awesome-linter do something', 0)
@@ -13,40 +21,57 @@ Execute(FormatCommand should handle %%, and ignore other percents):
AssertEqual ['', '% %%d %%f %x %'], ale#command#FormatCommand(bufnr('%'), '%% %%%d %%%f %x %', 0)
Execute(FormatCommand should convert %s to the current filename):
- AssertEqual ['', 'foo ' . shellescape(expand('%:p')) . ' bar ' . shellescape(expand('%:p'))], ale#command#FormatCommand(bufnr('%'), 'foo %s bar %s', 0)
+ AssertEqual
+ \ [
+ \ '',
+ \ 'foo ' . ale#Escape(expand('%:p')) . ' bar ' . ale#Escape(expand('%:p'))
+ \ ],
+ \ ale#command#FormatCommand(bufnr('%'), 'foo %s bar %s', 0)
Execute(FormatCommand should convert %t to a new temporary filename):
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo %t bar %t', 0)
- let g:match = matchlist(g:result[1], '\v^foo (''/tmp/[^'']*/dummy.txt'') bar (''/tmp/[^'']*/dummy.txt'')$')
+
+ call CheckTempFile(g:result[0])
+
+ let g:match = matchlist(g:result[1], '\v^foo (.*) bar (.*)$')
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
" The first item of the result should be a temporary filename, and it should
" be the same as the escaped name in the command string.
- AssertEqual shellescape(g:result[0]), g:match[1]
+ AssertEqual ale#Escape(g:result[0]), g:match[1]
" The two temporary filenames formatted in should be the same.
AssertEqual g:match[1], g:match[2]
Execute(FormatCommand should let you combine %s and %t):
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo %t bar %s', 0)
- let g:match = matchlist(g:result[1], '\v^foo (''/tmp/.*/dummy.txt'') bar (''.*/dummy.txt'')$')
+
+ call CheckTempFile(g:result[0])
+
+ let g:match = matchlist(g:result[1], '\v^foo (.*) bar (.*)$')
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
" The first item of the result should be a temporary filename, and it should
" be the same as the escaped name in the command string.
- AssertEqual shellescape(g:result[0]), g:match[1]
+ AssertEqual ale#Escape(g:result[0]), g:match[1]
" The second item should be equal to the original filename.
- AssertEqual shellescape(expand('%:p')), g:match[2]
+ AssertEqual ale#Escape(expand('%:p')), g:match[2]
Execute(EscapeCommandPart should escape all percent signs):
AssertEqual '%%s %%t %%%% %%s %%t %%%%', ale#engine#EscapeCommandPart('%s %t %% %s %t %%')
Execute(EscapeCommandPart should pipe in temporary files appropriately):
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo bar', 1)
- let g:match = matchlist(g:result[1], '\v^foo bar \< (''/tmp/[^'']*/dummy.txt'')$')
+
+ call CheckTempFile(g:result[0])
+
+ let g:match = matchlist(g:result[1], '\v^foo bar \< (.*)$')
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
- AssertEqual shellescape(g:result[0]), g:match[1]
+ AssertEqual ale#Escape(g:result[0]), g:match[1]
let g:result = ale#command#FormatCommand(bufnr('%'), 'foo bar %t', 1)
- let g:match = matchlist(g:result[1], '\v^foo bar (''/tmp/[^'']*/dummy.txt'')$')
+
+ call CheckTempFile(g:result[0])
+
+ let g:match = matchlist(g:result[1], '\v^foo bar (.*)$')
Assert !empty(g:match), 'No match found! Result was: ' . g:result[1]
- AssertEqual shellescape(g:result[0]), g:match[1]
+ AssertEqual ale#Escape(g:result[0]), g:match[1]
diff --git a/test/test_format_temporary_file_creation.vader b/test/test_format_temporary_file_creation.vader
index 0639c593..1afaba30 100644
--- a/test/test_format_temporary_file_creation.vader
+++ b/test/test_format_temporary_file_creation.vader
@@ -10,8 +10,8 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
- \ 'executable': 'cat',
- \ 'command': 'cat %t',
+ \ 'executable': has('win32') ? 'cmd' : 'cat',
+ \ 'command': has('win32') ? 'type %t' : 'cat %t',
\})
After:
diff --git a/test/test_get_abspath.vader b/test/test_get_abspath.vader
index 2def3773..5f813804 100644
--- a/test/test_get_abspath.vader
+++ b/test/test_get_abspath.vader
@@ -3,10 +3,10 @@ Execute(Relative paths should be resolved correctly):
\ '/foo/bar/baz/whatever.txt',
\ ale#path#GetAbsPath('/foo/bar/xyz', '../baz/whatever.txt')
AssertEqual
- \ '/foo/bar/xyz/whatever.txt',
+ \ has('win32') ? '/foo/bar/xyz\whatever.txt' : '/foo/bar/xyz/whatever.txt',
\ ale#path#GetAbsPath('/foo/bar/xyz', './whatever.txt')
AssertEqual
- \ '/foo/bar/xyz/whatever.txt',
+ \ has('win32') ? '/foo/bar/xyz\whatever.txt' : '/foo/bar/xyz/whatever.txt',
\ ale#path#GetAbsPath('/foo/bar/xyz', 'whatever.txt')
Execute(Absolute paths should be resolved correctly):
diff --git a/test/test_gradle_build_classpath_command.vader b/test/test_gradle_build_classpath_command.vader
index 84135268..c31dc698 100644
--- a/test/test_gradle_build_classpath_command.vader
+++ b/test/test_gradle_build_classpath_command.vader
@@ -1,37 +1,44 @@
Before:
+ Save $PATH
+ Save $PATHEXT
+
+ let $PATHEXT = '.'
+
call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/kotlin/kotlinc.vim
- let g:ale_gradle_path = $PATH
+
+ let g:command_tail = ' -I ' . ale#Escape(ale#gradle#GetInitPath())
+ \ . ' -q printClasspath'
+
+ let g:gradle_init_path = ale#path#Winify(g:dir . '../../autoload/ale/gradle/init.gradle')
After:
+ Restore
+
+ unlet! g:gradle_init_path
+ unlet! g:command_tail
+
call ale#test#RestoreDirectory()
call ale#linter#Reset()
- let $PATH = g:ale_gradle_path
Execute(Should return 'gradlew' command if project includes gradle wapper):
call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt')
- let g:project_root = '/testplugin/test/gradle-test-files/wrapped-project'
- let g:gradle_executable = '/testplugin/test/gradle-test-files/wrapped-project/gradlew'
- let g:gradle_init_path = '/testplugin/autoload/ale/gradle/init.gradle'
- let g:gradle_options = '-I ' . g:gradle_init_path . ' -q printClasspath'
-
-
AssertEqual
- \ "cd '" . g:project_root . "' && " . g:gradle_executable . " " . g:gradle_options,
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/gradle-test-files/wrapped-project'))
+ \ . ' && ' . ale#Escape(ale#path#Winify(g:dir . '/gradle-test-files/wrapped-project/gradlew'))
+ \ . g:command_tail,
\ ale#gradle#BuildClasspathCommand(bufnr(''))
Execute(Should return 'gradle' command if project does not include gradle wapper):
call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt')
- let $PATH .= ':' . g:dir . '/gradle-test-files'
-
- let g:project_root = '/testplugin/test/gradle-test-files/unwrapped-project'
- let g:gradle_executable = 'gradle'
- let g:gradle_init_path = '/testplugin/autoload/ale/gradle/init.gradle'
- let g:gradle_options = '-I ' . g:gradle_init_path . ' -q printClasspath'
+ let $PATH .= (has('win32') ? ';' : ':')
+ \ . ale#path#Winify(g:dir . '/gradle-test-files')
AssertEqual
- \ "cd '" . g:project_root . "' && " . g:gradle_executable . " " . g:gradle_options,
+ \ 'cd ' . ale#Escape(ale#path#Winify(g:dir . '/gradle-test-files/unwrapped-project'))
+ \ . ' && ' . ale#Escape('gradle')
+ \ . g:command_tail,
\ ale#gradle#BuildClasspathCommand(bufnr(''))
Execute(Should return empty string if gradle cannot be executed):
diff --git a/test/test_gradle_find_executable.vader b/test/test_gradle_find_executable.vader
index 2ae2b464..054c21a8 100644
--- a/test/test_gradle_find_executable.vader
+++ b/test/test_gradle_find_executable.vader
@@ -1,31 +1,37 @@
Before:
+ Save $PATH
+ Save $PATHEXT
+
+ " Count the gradle executable without .exe as executable on Windows
+ let $PATHEXT = '.'
+
call ale#test#SetDirectory('/testplugin/test')
runtime ale_linters/kotlin/kotlinc.vim
- let g:ale_gradle_path = $PATH
After:
+ Restore
+
call ale#test#RestoreDirectory()
call ale#linter#Reset()
- let $PATH = g:ale_gradle_path
-
+
Execute(Should return 'gradlew' if found in parent directory):
call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt')
AssertEqual
- \ g:dir . '/gradle-test-files/wrapped-project/gradlew',
+ \ ale#path#Winify(g:dir . '/gradle-test-files/wrapped-project/gradlew'),
\ ale#gradle#FindExecutable(bufnr(''))
Execute(Should return 'gradle' if 'gradlew' not found in parent directory):
call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt')
- let $PATH .= ':' . g:dir . '/gradle-test-files'
-
+ let $PATH .= (has('win32') ? ';': ':') . ale#path#Winify(g:dir . '/gradle-test-files')
+
AssertEqual
- \ 'gradle',
+ \ 'gradle',
\ ale#gradle#FindExecutable(bufnr(''))
Execute(Should return empty string if 'gradlew' not in parent directory and gradle not in path):
call ale#test#SetFilename('gradle-test-files/unwrapped-project/src/main/kotlin/dummy.kt')
-
+
AssertEqual
- \ '',
+ \ '',
\ ale#gradle#FindExecutable(bufnr(''))
diff --git a/test/test_gradle_find_project_root.vader b/test/test_gradle_find_project_root.vader
index bd1b8d7d..87af1109 100644
--- a/test/test_gradle_find_project_root.vader
+++ b/test/test_gradle_find_project_root.vader
@@ -10,21 +10,21 @@ Execute(Should return directory for 'gradlew' if found in parent directory):
call ale#test#SetFilename('gradle-test-files/wrapped-project/src/main/kotlin/dummy.kt')
AssertEqual
- \ g:dir . '/gradle-test-files/wrapped-project',
+ \ ale#path#Winify(g:dir . '/gradle-test-files/wrapped-project'),
\ ale#gradle#FindProjectRoot(bufnr(''))
Execute(Should return directory for 'settings.gradle' if found in parent directory):
call ale#test#SetFilename('gradle-test-files/settings-gradle-project/src/main/kotlin/dummy.kt')
AssertEqual
- \ g:dir . '/gradle-test-files/settings-gradle-project',
+ \ ale#path#Winify(g:dir . '/gradle-test-files/settings-gradle-project'),
\ ale#gradle#FindProjectRoot(bufnr(''))
Execute(Should return directory for 'build.gradle' if found in parent directory):
call ale#test#SetFilename('gradle-test-files/build-gradle-project/src/main/kotlin/dummy.kt')
AssertEqual
- \ g:dir . '/gradle-test-files/build-gradle-project',
+ \ ale#path#Winify(g:dir . '/gradle-test-files/build-gradle-project'),
\ ale#gradle#FindProjectRoot(bufnr(''))
Execute(Should return empty string if gradle files are not found in parent directory):
diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader
index c1909c4f..2d87b771 100644
--- a/test/test_highlight_placement.vader
+++ b/test/test_highlight_placement.vader
@@ -36,8 +36,8 @@ Before:
call ale#linter#Define('testft', {
\ 'name': 'x',
- \ 'executable': 'echo',
- \ 'command': 'echo',
+ \ 'executable': has('win32') ? 'cmd': 'echo',
+ \ 'command': has('win32') ? 'echo' : '/bin/sh -c ''echo''',
\ 'callback': 'GenerateResults',
\})
highlight link SomeOtherGroup SpellBad
diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader
index dc7ce0d7..020ceb53 100644
--- a/test/test_history_saving.vader
+++ b/test/test_history_saving.vader
@@ -67,7 +67,10 @@ Execute(History should be set when commands are run):
call ale#Lint()
call ale#engine#WaitForJobs(2000)
- let g:history = ale#history#Get(bufnr(''))
+ let g:history = filter(
+ \ copy(ale#history#Get(bufnr(''))),
+ \ 'v:val.job_id isnot# ''executable''',
+ \)
AssertEqual 1, len(g:history)
AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
diff --git a/test/test_lint_on_enter_when_file_changed.vader b/test/test_lint_on_enter_when_file_changed.vader
index 4d4f19cc..d2b38e04 100644
--- a/test/test_lint_on_enter_when_file_changed.vader
+++ b/test/test_lint_on_enter_when_file_changed.vader
@@ -2,9 +2,12 @@ Before:
Save &filetype
Save g:ale_buffer_info
Save g:ale_lint_on_enter
+ Save g:ale_set_lists_synchronously
+
let g:buf = bufnr('')
let g:ale_lint_on_enter = 1
let g:ale_run_synchronously = 1
+ let g:ale_set_lists_synchronously = 1
function! TestCallback(buffer, output)
return [{
@@ -17,8 +20,8 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
- \ 'executable': 'true',
- \ 'command': 'true',
+ \ 'executable': has('win32') ? 'cmd' : 'true',
+ \ 'command': has('win32') ? 'echo' : 'true',
\})
After: