summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-09-11 00:47:27 +0100
committerw0rp <devw0rp@gmail.com>2017-09-11 00:47:27 +0100
commitb6a487ccf9318e449a85bd5b43d7a81b9d17d2be (patch)
tree3fc370f84a5295994d38b54d2eef2468a1a0a9e2
parentcb8a140141d6365f48e66dfaaaa8f9957f0dc832 (diff)
downloadale-b6a487ccf9318e449a85bd5b43d7a81b9d17d2be.zip
Fix some random test issues for Windows
-rw-r--r--test/command_callback/test_perlcritic_command_callback.vader59
-rw-r--r--test/test_history_saving.vader29
-rw-r--r--test/test_lint_file_linters.vader6
-rw-r--r--test/test_linting_updates_loclist.vader2
-rw-r--r--test/test_list_titles.vader14
-rw-r--r--test/test_nearest_file_search.vader4
-rw-r--r--test/test_path_equality.vader38
-rw-r--r--test/test_path_upwards.vader2
-rw-r--r--test/test_perlcritic_linter.vader62
-rw-r--r--test/test_phpcs_executable_detection.vader2
-rw-r--r--test/test_prepare_command.vader3
-rw-r--r--test/test_resolve_local_path.vader6
-rw-r--r--test/test_results_not_cleared_when_opening_loclist.vader7
13 files changed, 141 insertions, 93 deletions
diff --git a/test/command_callback/test_perlcritic_command_callback.vader b/test/command_callback/test_perlcritic_command_callback.vader
new file mode 100644
index 00000000..8f339d31
--- /dev/null
+++ b/test/command_callback/test_perlcritic_command_callback.vader
@@ -0,0 +1,59 @@
+Before:
+ Save g:ale_perl_perlcritic_profile
+ Save g:ale_perl_perlcritic_options
+ Save g:ale_perl_perlcritic_executable
+ Save g:ale_perl_perlcritic_showrules
+
+ unlet! g:ale_perl_perlcritic_options
+ unlet! g:ale_perl_perlcritic_executable
+ unlet! g:ale_perl_perlcritic_showrules
+ let g:ale_perl_perlcritic_profile = ''
+
+ runtime ale_linters/perl/perlcritic.vim
+
+ call ale#test#SetDirectory('/testplugin/test/command_callback')
+ call ale#test#SetFilename('test.pl')
+
+After:
+ Restore
+
+ unlet! b:ale_perl_perlcritic_profile
+ unlet! b:ale_perl_perlcritic_options
+ unlet! b:ale_perl_perlcritic_executable
+ unlet! b:ale_perl_perlcritic_showrules
+ unlet! b:readme_path
+
+ call ale#test#RestoreDirectory()
+ call ale#linter#Reset()
+
+Execute(The command should be correct with g:ale_perl_perlcritic_showrules off):
+ let b:ale_perl_perlcritic_showrules = 0
+
+ AssertEqual
+ \ ale#Escape('perlcritic') . ' --verbose ''%l:%c %m\n'' --nocolor',
+ \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
+
+Execute(The command should be correct with g:ale_perl_perlcritic_showrules on):
+ let b:ale_perl_perlcritic_showrules = 1
+
+ AssertEqual
+ \ ale#Escape('perlcritic') . ' --verbose ''%l:%c %m [%p]\n'' --nocolor',
+ \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
+
+Execute(The command search for the profile file when set):
+ let b:ale_perl_perlcritic_profile = 'README.md'
+
+ let b:readme_path = ale#path#Winify(expand('%:p:h:h:h') . '/README.md')
+
+ AssertEqual
+ \ ale#Escape('perlcritic') . ' --verbose ''%l:%c %m\n'' --nocolor'
+ \ . ' --profile ' . ale#Escape(b:readme_path),
+ \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
+
+Execute(Extra options should be set appropriately):
+ let b:ale_perl_perlcritic_options = 'beep boop'
+
+ AssertEqual
+ \ ale#Escape('perlcritic') . ' --verbose ''%l:%c %m\n'' --nocolor'
+ \ . ' beep boop',
+ \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
diff --git a/test/test_history_saving.vader b/test/test_history_saving.vader
index 3ccc1691..dc7ce0d7 100644
--- a/test/test_history_saving.vader
+++ b/test/test_history_saving.vader
@@ -10,7 +10,11 @@ Before:
" Temporarily set the shell to /bin/sh, if it isn't already set that way.
" This will make it so the test works when running it directly.
let g:current_shell = &shell
- let &shell = '/bin/sh'
+
+ if !has('win32')
+ let &shell = '/bin/sh'
+ endif
+
let g:history = []
let g:ale_buffer_info = {}
let g:ale_max_buffer_history_size = 20
@@ -27,8 +31,10 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'CollectResults',
- \ 'executable': 'echo',
- \ 'command': '/bin/sh -c ''echo command history test''',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
+ \ 'command': has('win32')
+ \ ? 'echo command history test'
+ \ : '/bin/sh -c ''echo command history test''',
\ 'read_buffer': 0,
\})
@@ -65,7 +71,13 @@ Execute(History should be set when commands are run):
AssertEqual 1, len(g:history)
AssertEqual sort(['status', 'exit_code', 'job_id', 'command']), sort(keys(g:history[0]))
- AssertEqual ['/bin/sh', '-c', '/bin/sh -c ''echo command history test'''], g:history[0].command
+
+ if has('win32')
+ AssertEqual 'cmd /c echo command history test', g:history[0].command
+ else
+ AssertEqual ['/bin/sh', '-c', '/bin/sh -c ''echo command history test'''], g:history[0].command
+ endif
+
AssertEqual 'finished', g:history[0].status
AssertEqual 0, g:history[0].exit_code
" The Job ID will change each time, but we can check the type.
@@ -125,6 +137,8 @@ Given foobar(Some file with an imaginary filetype):
c
Execute(The history should be updated when fixers are run):
+ call ale#test#SetFilename('dummy.txt')
+
let b:ale_fixers = {'foobar': ['TestFixer']}
let b:ale_enabled = 0
let g:ale_run_synchronously = 1
@@ -132,4 +146,9 @@ Execute(The history should be updated when fixers are run):
ALEFix
AssertEqual ['finished'], map(copy(b:ale_history), 'v:val.status')
- AssertEqual '/bin/sh -c echo foo ', split(join(b:ale_history[0].command), '<')[0]
+
+ if has('win32')
+ AssertEqual 'cmd /c echo foo ', split(b:ale_history[0].command, '<')[0]
+ else
+ AssertEqual '/bin/sh -c echo foo ', split(join(b:ale_history[0].command), '<')[0]
+ endif
diff --git a/test/test_lint_file_linters.vader b/test/test_lint_file_linters.vader
index cb859790..bea8c3f0 100644
--- a/test/test_lint_file_linters.vader
+++ b/test/test_lint_file_linters.vader
@@ -1,10 +1,12 @@
Before:
Save g:ale_run_synchronously
+ Save g:ale_set_lists_synchronously
Save g:ale_buffer_info
Save g:ale_linters
let g:ale_buffer_info = {}
let g:ale_run_synchronously = 1
+ let g:ale_set_lists_synchronously = 1
call ale#ResetLintFileMarkers()
let g:buffer_result = [
@@ -61,7 +63,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'lint_file_linter',
\ 'callback': 'LintFileCallback',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo',
\ 'lint_file': 1,
\})
@@ -69,7 +71,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'buffer_linter',
\ 'callback': 'BufferCallback',
- \ 'executable': 'echo',
+ \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo',
\ 'read_buffer': 0,
\})
diff --git a/test/test_linting_updates_loclist.vader b/test/test_linting_updates_loclist.vader
index a1daf28d..29ca05d4 100644
--- a/test/test_linting_updates_loclist.vader
+++ b/test/test_linting_updates_loclist.vader
@@ -47,7 +47,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
- \ 'executable': 'true',
+ \ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true',
\ 'read_buffer': 0,
\})
diff --git a/test/test_list_titles.vader b/test/test_list_titles.vader
index 74cb4bcc..e7295414 100644
--- a/test/test_list_titles.vader
+++ b/test/test_list_titles.vader
@@ -2,12 +2,14 @@ Before:
Save g:ale_set_loclist
Save g:ale_set_quickfix
Save g:ale_buffer_info
+ Save g:ale_set_lists_synchronously
let g:ale_buffer_info = {}
let g:ale_set_loclist = 0
let g:ale_set_quickfix = 0
+ let g:ale_set_lists_synchronously = 1
- silent! cd /testplugin/test
+ call ale#test#SetDirectory('/testplugin/test')
After:
Restore
@@ -15,6 +17,8 @@ After:
call setloclist(0, [])
call setqflist([])
+ call ale#test#RestoreDirectory()
+
Execute(The loclist titles should be set appropriately):
silent noautocmd file foo
@@ -37,7 +41,9 @@ Execute(The loclist titles should be set appropriately):
\}], getloclist(0)
if !has('nvim')
- AssertEqual {'title': getcwd() . '/foo'}, getloclist(0, {'title': ''})
+ AssertEqual
+ \ {'title': ale#path#Winify(getcwd() . '/foo')},
+ \ getloclist(0, {'title': ''})
endif
Execute(The quickfix titles should be set appropriately):
@@ -65,5 +71,7 @@ Execute(The quickfix titles should be set appropriately):
\}], getqflist()
if !has('nvim')
- AssertEqual {'title': getcwd() . '/foo'}, getqflist({'title': ''})
+ AssertEqual
+ \ {'title': ale#path#Winify(getcwd() . '/foo')},
+ \ getqflist({'title': ''})
endif
diff --git a/test/test_nearest_file_search.vader b/test/test_nearest_file_search.vader
index 71b7d109..63e82da8 100644
--- a/test/test_nearest_file_search.vader
+++ b/test/test_nearest_file_search.vader
@@ -7,7 +7,9 @@ After:
Execute(We should be able to find a configuration file further up):
call ale#test#SetFilename('top/middle/bottom/dummy.txt')
- AssertEqual expand('%:p:h:h:h:h') . '/top/example.ini', ale#path#FindNearestFile(bufnr('%'), 'example.ini')
+ AssertEqual
+ \ ale#path#Winify(expand('%:p:h:h:h:h') . '/top/example.ini'),
+ \ ale#path#FindNearestFile(bufnr('%'), 'example.ini')
Execute(We shouldn't find anything for files which don't match):
AssertEqual '', ale#path#FindNearestFile(bufnr('%'), 'cantfindthis')
diff --git a/test/test_path_equality.vader b/test/test_path_equality.vader
index 54d9bf9a..c17f0010 100644
--- a/test/test_path_equality.vader
+++ b/test/test_path_equality.vader
@@ -1,34 +1,47 @@
+Before:
+ function! CheckPath(path) abort
+ return ale#path#IsBufferPath(bufnr(''), ale#path#Winify(a:path))
+ endfunction
+
+After:
+ delfunction CheckPath
+
Execute(ale#path#IsBufferPath should match simple relative paths):
call ale#test#SetFilename('app/foo.txt')
- Assert ale#path#IsBufferPath(bufnr(''), 'app/foo.txt'), 'No match for foo.txt'
- Assert !ale#path#IsBufferPath(bufnr(''), 'app/bar.txt'), 'Bad match for bar.txt'
+ Assert CheckPath('app/foo.txt'), 'No match for foo.txt'
+ Assert !CheckPath('app/bar.txt'), 'Bad match for bar.txt'
Execute(ale#path#IsBufferPath should match relative paths with dots):
call ale#test#SetFilename('app/foo.txt')
- Assert ale#path#IsBufferPath(bufnr(''), '../../app/foo.txt'), 'No match for ../../app/foo.txt'
+ " Skip these checks on Windows.
+ if !has('win32')
+ Assert CheckPath('../../app/foo.txt'), 'No match for ../../app/foo.txt'
+ endif
Execute(ale#path#IsBufferPath should match absolute paths):
silent file! foo.txt
- Assert ale#path#IsBufferPath(bufnr(''), getcwd() . '/foo.txt'), 'No match for foo.txt'
- Assert !ale#path#IsBufferPath(bufnr(''), getcwd() . '/bar.txt'), 'Bad match for bar.txt'
+ Assert CheckPath(getcwd() . '/foo.txt'), 'No match for foo.txt'
+ Assert !CheckPath(getcwd() . '/bar.txt'), 'Bad match for bar.txt'
Execute(ale#path#IsBufferPath should match paths beginning with ./):
silent file! foo.txt
- Assert ale#path#IsBufferPath(bufnr(''), './foo.txt'), 'No match for ./foo.txt'
+ if !has('win32')
+ Assert ale#path#IsBufferPath(bufnr(''), './foo.txt'), 'No match for ./foo.txt'
+ endif
Execute(ale#path#IsBufferPath should match if our path ends with the test path):
silent file! foo/bar/baz.txt
- Assert ale#path#IsBufferPath(bufnr(''), 'bar/baz.txt'), 'No match for bar/baz.txt'
+ Assert CheckPath('bar/baz.txt'), 'No match for bar/baz.txt'
Execute(ale#path#IsBufferPath should match paths with redundant slashes):
silent file! foo.txt
- Assert ale#path#IsBufferPath(bufnr(''), getcwd() . '////foo.txt'), 'No match for foo.txt'
+ Assert CheckPath(getcwd() . '////foo.txt'), 'No match for foo.txt'
Execute(ale#path#IsBufferPath should accept various names for stdin):
Assert ale#path#IsBufferPath(bufnr(''), '-')
@@ -39,6 +52,9 @@ Execute(ale#path#IsBufferPath should accept various names for stdin):
Execute(ale#path#IsBufferPath should match files in /tmp):
call ale#test#SetFilename('app/test.ts')
- Assert ale#path#IsBufferPath(bufnr(''), '../../../../../../../../tmp/vG0hKyD/1/test.ts')
- Assert ale#path#IsBufferPath(bufnr(''), '/tmp/vG0hKyD/1/test.ts')
- Assert ale#path#IsBufferPath(bufnr(''), '/run/user/1000/vG0hKyD/1/test.ts')
+ " Skip these checks on Windows.
+ if !has('win32')
+ Assert ale#path#IsBufferPath(bufnr(''), '../../../../../../../../tmp/vG0hKyD/1/test.ts')
+ Assert ale#path#IsBufferPath(bufnr(''), '/tmp/vG0hKyD/1/test.ts')
+ Assert ale#path#IsBufferPath(bufnr(''), '/run/user/1000/vG0hKyD/1/test.ts')
+ endif
diff --git a/test/test_path_upwards.vader b/test/test_path_upwards.vader
index 5e7d576e..8b81a109 100644
--- a/test/test_path_upwards.vader
+++ b/test/test_path_upwards.vader
@@ -2,6 +2,8 @@ After:
let g:ale_has_override = {}
Execute(ale#path#Upwards should return the correct path components for Unix):
+ let g:ale_has_override = {'win32': 0}
+
" Absolute paths should include / on the end.
AssertEqual
\ ['/foo/bar/baz', '/foo/bar', '/foo', '/'],
diff --git a/test/test_perlcritic_linter.vader b/test/test_perlcritic_linter.vader
deleted file mode 100644
index 8b7cf1a4..00000000
--- a/test/test_perlcritic_linter.vader
+++ /dev/null
@@ -1,62 +0,0 @@
-" NOTE: We use the 'b:' forms below to ensure that we're properly using
-" ale#Var()
-
-Given perl:
- #!/usr/bin/env perl
- use v5.10;
- say 'Hi there!';
-
-
-Before:
- Save g:ale_perl_perlcritic_profile
- Save g:ale_perl_perlcritic_options
- Save g:ale_perl_perlcritic_executable
- Save g:ale_perl_perlcritic_showrules
- silent! unlet g:ale_perl_perlcritic_options
- silent! unlet g:ale_perl_perlcritic_executable
- silent! unlet g:ale_perl_perlcritic_showrules
- let g:ale_perl_perlcritic_profile = ''
-
- " enable loading inside test container
- silent! cd /testplugin
- source ale_linters/perl/perlcritic.vim
-
-
-After:
- Restore
- silent! unlet b:ale_perl_perlcritic_profile
- silent! unlet b:ale_perl_perlcritic_options
- silent! unlet b:ale_perl_perlcritic_executable
- silent! unlet b:ale_perl_perlcritic_showrules
-
-
-Execute(no g:ale_perl_perlcritic_showrules):
- let b:ale_perl_perlcritic_showrules = 0
-
- AssertEqual
- \ "'perlcritic' --verbose '". '%l:%c %m\n' . "' --nocolor",
- \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
-
-
-Execute(yes g:ale_perl_perlcritic_showrules):
- let b:ale_perl_perlcritic_showrules = 1
-
- AssertEqual
- \ "'perlcritic' --verbose '". '%l:%c %m [%p]\n' . "' --nocolor",
- \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
-
-
-Execute(set g:ale_perl_perlcritic_profile):
- let b:ale_perl_perlcritic_profile = 'README.md'
-
- Assert
- \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
- \ =~# "--profile '.*/README.md'"
-
-
-Execute(g:ale_perl_perlcritic_options):
- let b:ale_perl_perlcritic_options = 'beep boop'
-
- AssertEqual
- \ "'perlcritic' --verbose '". '%l:%c %m\n' . "' --nocolor beep boop",
- \ ale_linters#perl#perlcritic#GetCommand(bufnr(''))
diff --git a/test/test_phpcs_executable_detection.vader b/test/test_phpcs_executable_detection.vader
index 786d3249..f51ba9f7 100644
--- a/test/test_phpcs_executable_detection.vader
+++ b/test/test_phpcs_executable_detection.vader
@@ -19,7 +19,7 @@ Execute(project with phpcs should use local by default):
call ale#test#SetFilename('phpcs-test-files/project-with-phpcs/foo/test.php')
AssertEqual
- \ g:dir . '/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs',
+ \ ale#path#Winify(g:dir . '/phpcs-test-files/project-with-phpcs/vendor/bin/phpcs'),
\ ale_linters#php#phpcs#GetExecutable(bufnr(''))
Execute(use-global should override local detection):
diff --git a/test/test_prepare_command.vader b/test/test_prepare_command.vader
index 5707be72..ebb9998d 100644
--- a/test/test_prepare_command.vader
+++ b/test/test_prepare_command.vader
@@ -9,6 +9,7 @@ After:
Execute(sh should be used when the shell is fish):
" Set something else, so we will replace that too.
let &shellcmdflag = '-f'
+ let g:ale_has_override = {'win32': 0}
let &shell = 'fish'
@@ -25,13 +26,13 @@ Execute(sh should be used when the shell is fish):
Execute(Other shells should be used when set):
let &shell = '/bin/bash'
let &shellcmdflag = '-c'
+ let g:ale_has_override = {'win32': 0}
AssertEqual ['/bin/bash', '-c', 'foobar'], ale#job#PrepareCommand('foobar')
Execute(cmd /c as a string should be used on Windows):
let &shell = 'who cares'
let &shellcmdflag = 'whatever'
-
let g:ale_has_override = {'win32': 1}
AssertEqual 'cmd /c foobar', ale#job#PrepareCommand('foobar')
diff --git a/test/test_resolve_local_path.vader b/test/test_resolve_local_path.vader
index ed1549a2..125ae2ff 100644
--- a/test/test_resolve_local_path.vader
+++ b/test/test_resolve_local_path.vader
@@ -8,10 +8,10 @@ Execute(We should be able to find the local version of a file):
call ale#test#SetFilename('top/middle/bottom/dummy.txt')
AssertEqual
- \ expand('%:p:h:h:h:h') . '/top/example.ini',
- \ ale#path#ResolveLocalPath(bufnr('%'), 'example.ini', '/global/config.ini')
+ \ ale#path#Winify(expand('%:p:h:h:h:h') . '/top/example.ini'),
+ \ ale#path#ResolveLocalPath(bufnr('%'), 'example.ini', '/global/config.ini')
Execute(We shouldn't find anything for files which don't match):
AssertEqual
\ '/global/config.ini',
- \ ale#path#ResolveLocalPath(bufnr('%'), 'missing.ini', '/global/config.ini')
+ \ ale#path#ResolveLocalPath(bufnr('%'), 'missing.ini', '/global/config.ini')
diff --git a/test/test_results_not_cleared_when_opening_loclist.vader b/test/test_results_not_cleared_when_opening_loclist.vader
index 0c053b85..c983a89f 100644
--- a/test/test_results_not_cleared_when_opening_loclist.vader
+++ b/test/test_results_not_cleared_when_opening_loclist.vader
@@ -15,7 +15,7 @@ Before:
call ale#linter#Define('foobar', {
\ 'name': 'testlinter',
\ 'callback': 'TestCallback',
- \ 'executable': 'true',
+ \ 'executable': has('win32') ? 'cmd' : 'true',
\ 'command': 'true',
\ 'read_buffer': 0,
\})
@@ -35,8 +35,9 @@ Given foobar (Some file):
Execute(The loclist shouldn't be cleared when opening the loclist):
call ale#Lint()
+ sleep 1ms
- AssertEqual 1, len(getloclist(0))
+ AssertEqual 1, len(getloclist(0)), 'The loclist was never set'
" The cleanup function is called when the loclist window is closed.
" If some cleanup is done for this buffer, for which nothing is wrong,
@@ -45,4 +46,4 @@ Execute(The loclist shouldn't be cleared when opening the loclist):
:lopen
:q
- AssertEqual 1, len(getloclist(0))
+ AssertEqual 1, len(getloclist(0)), 'The loclist was cleared'