Get all tests to pass on Windows

This commit is contained in:
w0rp 2017-10-23 23:09:40 +01:00
parent 231398dddc
commit b952dda386
14 changed files with 168 additions and 106 deletions

View File

@ -36,4 +36,5 @@ install:
test_script: test_script:
- cd C:\testplugin - cd C:\testplugin
- 'C:\vim\vim\vim80\vim.exe -u test\vimrc "+Vader! test/test_path_uri.vader"' - 'C:\vim\vim\vim80\vim.exe -u test\vimrc "+Vader!
test/*.vader test/*/*.vader test/*/*/*.vader test/*/*/*.vader"'

View File

@ -841,7 +841,7 @@ function! ale#engine#WaitForJobs(deadline) abort
" Gather all of the jobs from every buffer. " Gather all of the jobs from every buffer.
for l:info in values(g:ale_buffer_info) for l:info in values(g:ale_buffer_info)
call extend(l:job_list, l:info.job_list) call extend(l:job_list, get(l:info, 'job_list', []))
endfor endfor
" NeoVim has a built-in API for this, so use that. " NeoVim has a built-in API for this, so use that.
@ -889,7 +889,7 @@ function! ale#engine#WaitForJobs(deadline) abort
" Check again to see if any jobs are running. " Check again to see if any jobs are running.
for l:info in values(g:ale_buffer_info) for l:info in values(g:ale_buffer_info)
for l:job_id in l:info.job_list for l:job_id in get(l:info, 'job_list', [])
if ale#job#IsRunning(l:job_id) if ale#job#IsRunning(l:job_id)
let l:has_new_jobs = 1 let l:has_new_jobs = 1
break break

View File

@ -11,11 +11,18 @@ Before:
let g:ale_enabled = 0 let g:ale_enabled = 0
let g:ale_echo_cursor = 0 let g:ale_echo_cursor = 0
let g:ale_run_synchronously = 1 let g:ale_run_synchronously = 1
let g:ale_set_lists_synchronously = 1
let g:ale_fix_buffer_data = {} let g:ale_fix_buffer_data = {}
let g:ale_fixers = { let g:ale_fixers = {
\ 'testft': [], \ 'testft': [],
\} \}
if !has('win32')
let &shell = '/bin/bash' let &shell = '/bin/bash'
endif
call ale#test#SetDirectory('/testplugin/test')
call ale#test#SetFilename('test.txt')
function AddCarets(buffer, lines) abort function AddCarets(buffer, lines) abort
" map() is applied to the original lines here. " map() is applied to the original lines here.
@ -67,6 +74,7 @@ Before:
After: After:
Restore Restore
unlet! g:ale_run_synchronously unlet! g:ale_run_synchronously
unlet! g:ale_set_lists_synchronously
unlet! g:ale_emulate_job_failure unlet! g:ale_emulate_job_failure
unlet! b:ale_fixers unlet! b:ale_fixers
delfunction AddCarets delfunction AddCarets
@ -79,6 +87,9 @@ After:
delfunction RemoveLastLineOneArg delfunction RemoveLastLineOneArg
delfunction TestCallback delfunction TestCallback
delfunction SetUpLinters delfunction SetUpLinters
call ale#test#RestoreDirectory()
call ale#fix#registry#ResetToDefaults() call ale#fix#registry#ResetToDefaults()
call ale#linter#Reset() call ale#linter#Reset()
@ -129,8 +140,13 @@ Expect(Only the second function should be applied):
$c $c
Execute(ALEFix should allow commands to be run): Execute(ALEFix should allow commands to be run):
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'] let g:ale_fixers.testft = ['CatLine']
ALEFix ALEFix
endif
Expect(An extra line should be added): Expect(An extra line should be added):
a a
@ -139,22 +155,39 @@ Expect(An extra line should be added):
d d
Execute(ALEFix should allow temporary files to be read): Execute(ALEFix should allow temporary files to be read):
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'] let g:ale_fixers.testft = ['ReplaceWithTempFile']
ALEFix ALEFix
endif
Expect(The line we wrote to the temporary file should be used here): Expect(The line we wrote to the temporary file should be used here):
x x
Execute(ALEFix should allow jobs and simple functions to be combined): Execute(ALEFix should allow jobs and simple functions to be combined):
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'] let g:ale_fixers.testft = ['ReplaceWithTempFile', 'AddDollars']
ALEFix ALEFix
endif
Expect(The lines from the temporary file should be modified): Expect(The lines from the temporary file should be modified):
$x $x
Execute(ALEFix should send lines modified by functions to jobs): Execute(ALEFix should send lines modified by functions to jobs):
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'] let g:ale_fixers.testft = ['AddDollars', 'CatLine']
ALEFix ALEFix
endif
Expect(The lines should first be modified by the function, then the job): Expect(The lines should first be modified by the function, then the job):
$a $a
@ -257,7 +290,8 @@ Execute(ALEFix should save files on the save event):
AssertEqual ['$a', '$b', '$c'], readfile('fix_test_file') AssertEqual ['$a', '$b', '$c'], readfile('fix_test_file')
Assert !&modified, 'The was marked as ''modified''' Assert !&modified, 'The was marked as ''modified'''
" We have run the linter. if !has('win32')
" We should have run the linter.
AssertEqual [{ AssertEqual [{
\ 'bufnr': bufnr('%'), \ 'bufnr': bufnr('%'),
\ 'lnum': 1, \ 'lnum': 1,
@ -269,6 +303,7 @@ Execute(ALEFix should save files on the save event):
\ 'pattern': '', \ 'pattern': '',
\ 'valid': 1, \ 'valid': 1,
\}], getloclist(0) \}], getloclist(0)
endif
Expect(The buffer should be modified): Expect(The buffer should be modified):
$a $a
@ -294,6 +329,7 @@ Execute(ALEFix should still lint with no linters to be applied):
Assert !filereadable('fix_test_file'), 'The file should not have been saved' Assert !filereadable('fix_test_file'), 'The file should not have been saved'
if !has('win32')
" We have run the linter. " We have run the linter.
AssertEqual [{ AssertEqual [{
\ 'bufnr': bufnr('%'), \ 'bufnr': bufnr('%'),
@ -306,6 +342,7 @@ Execute(ALEFix should still lint with no linters to be applied):
\ 'pattern': '', \ 'pattern': '',
\ 'valid': 1, \ 'valid': 1,
\}], getloclist(0) \}], getloclist(0)
endif
Expect(The buffer should be the same): Expect(The buffer should be the same):
a a
@ -326,7 +363,8 @@ Execute(ALEFix should still lint when nothing was fixed on save):
Assert !filereadable('fix_test_file'), 'The file should not have been saved' Assert !filereadable('fix_test_file'), 'The file should not have been saved'
" We have run the linter. if !has('win32')
" We should have run the linter.
AssertEqual [{ AssertEqual [{
\ 'bufnr': bufnr('%'), \ 'bufnr': bufnr('%'),
\ 'lnum': 1, \ 'lnum': 1,
@ -338,6 +376,7 @@ Execute(ALEFix should still lint when nothing was fixed on save):
\ 'pattern': '', \ 'pattern': '',
\ 'valid': 1, \ 'valid': 1,
\}], getloclist(0) \}], getloclist(0)
endif
Expect(The buffer should be the same): Expect(The buffer should be the same):
a a
@ -358,7 +397,7 @@ Execute(ale#fix#InitBufferData() should set up the correct data):
\ bufnr(''): { \ bufnr(''): {
\ 'temporary_directory_list': [], \ 'temporary_directory_list': [],
\ 'vars': b:, \ 'vars': b:,
\ 'filename': simplify(getcwd() . '/fix_test_file'), \ 'filename': ale#path#Winify(getcwd() . '/fix_test_file'),
\ 'done': 0, \ 'done': 0,
\ 'lines_before': ['a', 'b', 'c'], \ 'lines_before': ['a', 'b', 'c'],
\ 'should_save': 1, \ 'should_save': 1,
@ -374,8 +413,13 @@ Expect(There should be only two lines):
b b
Execute(ALEFix functions returning jobs should be able to accept one argument): Execute(ALEFix functions returning jobs should be able to accept one argument):
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'] let g:ale_fixers.testft = ['CatLine']
ALEFix ALEFix
endif
Expect(An extra line should be added): Expect(An extra line should be added):
a a

View File

@ -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): Execute (ALEInfo should include executable checks in the history):
call ale#linter#Define('testft', g:testlinter1) 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 ale#engine#IsExecutable(bufnr(''), 'TheresNoWayThisIsExecutable')
call CheckInfo([ call CheckInfo([
@ -365,6 +365,6 @@ Execute (ALEInfo should include executable checks in the history):
\ '', \ '',
\] + g:globals_lines + g:command_header + [ \] + g:globals_lines + g:command_header + [
\ '', \ '',
\ '(executable check - success) echo', \ '(executable check - success) ' . (has('win32') ? 'cmd' : 'echo'),
\ '(executable check - failure) TheresNoWayThisIsExecutable', \ '(executable check - failure) TheresNoWayThisIsExecutable',
\]) \])

View File

@ -28,7 +28,7 @@ Before:
\ 'lnum': 2, \ 'lnum': 2,
\ 'vcol': 0, \ 'vcol': 0,
\ 'col': 3, \ 'col': 3,
\ 'text': a:output[0], \ 'text': join(split(a:output[0])),
\ 'type': 'E', \ 'type': 'E',
\ 'nr': -1, \ 'nr': -1,
\}] \}]
@ -37,7 +37,7 @@ Before:
call ale#linter#Define('foobar', { call ale#linter#Define('foobar', {
\ 'name': 'testlinter', \ 'name': 'testlinter',
\ 'callback': 'ToggleTestCallback', \ 'callback': 'ToggleTestCallback',
\ 'executable': 'echo', \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo foo bar', \ 'command': 'echo foo bar',
\}) \})
@ -63,5 +63,11 @@ Execute(ALELint should run the linters):
ALELint ALELint
call ale#engine#WaitForJobs(2000) 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 " Check the loclist
AssertEqual g:expected_loclist, getloclist(0) AssertEqual g:expected_loclist, getloclist(0)

View File

@ -67,7 +67,7 @@ Before:
call ale#linter#Define('foobar', { call ale#linter#Define('foobar', {
\ 'name': 'testlinter', \ 'name': 'testlinter',
\ 'callback': 'ToggleTestCallback', \ 'callback': 'ToggleTestCallback',
\ 'executable': 'echo', \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command': 'echo', \ 'command': 'echo',
\ 'read_buffer': 0, \ 'read_buffer': 0,
\}) \})

View File

@ -39,8 +39,8 @@ Execute(The C GCC handler should include 'include' directories for projects with
AssertEqual AssertEqual
\ ale#Escape('gcc') \ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only ' \ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -' \ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr('')) \ , ale_linters#c#gcc#GetCommand(bufnr(''))
@ -52,8 +52,8 @@ Execute(The C GCC handler should include 'include' directories for projects with
AssertEqual AssertEqual
\ ale#Escape('gcc') \ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only ' \ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -' \ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr('')) \ , 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 AssertEqual
\ ale#Escape('gcc') \ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only ' \ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr('')) \ , ale_linters#c#gcc#GetCommand(bufnr(''))
@ -78,8 +78,8 @@ Execute(The C GCC handler should include root directories for projects with .hpp
AssertEqual AssertEqual
\ ale#Escape('gcc') \ ale#Escape('gcc')
\ . ' -S -x c -fsyntax-only ' \ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#c#gcc#GetCommand(bufnr('')) \ , ale_linters#c#gcc#GetCommand(bufnr(''))
@ -91,8 +91,8 @@ Execute(The C Clang handler should include 'include' directories for projects wi
AssertEqual AssertEqual
\ ale#Escape('clang') \ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only ' \ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -' \ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr('')) \ , ale_linters#c#clang#GetCommand(bufnr(''))
@ -104,8 +104,8 @@ Execute(The C Clang handler should include 'include' directories for projects wi
AssertEqual AssertEqual
\ ale#Escape('clang') \ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only ' \ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr('')) \ , ale_linters#c#clang#GetCommand(bufnr(''))
@ -117,8 +117,8 @@ Execute(The C Clang handler should include root directories for projects with .h
AssertEqual AssertEqual
\ ale#Escape('clang') \ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only ' \ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr('')) \ , ale_linters#c#clang#GetCommand(bufnr(''))
@ -130,8 +130,8 @@ Execute(The C Clang handler should include root directories for projects with .h
AssertEqual AssertEqual
\ ale#Escape('clang') \ ale#Escape('clang')
\ . ' -S -x c -fsyntax-only ' \ . ' -S -x c -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#c#clang#GetCommand(bufnr('')) \ , ale_linters#c#clang#GetCommand(bufnr(''))
@ -143,8 +143,8 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
AssertEqual AssertEqual
\ ale#Escape('gcc') \ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr('')) \ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@ -156,8 +156,8 @@ Execute(The C++ GCC handler should include 'include' directories for projects wi
AssertEqual AssertEqual
\ ale#Escape('gcc') \ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr('')) \ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@ -169,8 +169,8 @@ Execute(The C++ GCC handler should include root directories for projects with .h
AssertEqual AssertEqual
\ ale#Escape('gcc') \ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr('')) \ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@ -182,8 +182,8 @@ Execute(The C++ GCC handler should include root directories for projects with .h
AssertEqual AssertEqual
\ ale#Escape('gcc') \ ale#Escape('gcc')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#gcc#GetCommand(bufnr('')) \ , ale_linters#cpp#gcc#GetCommand(bufnr(''))
@ -195,8 +195,8 @@ Execute(The C++ Clang handler should include 'include' directories for projects
AssertEqual AssertEqual
\ ale#Escape('clang++') \ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/makefile_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/makefile_project/include') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/makefile_project') . '/include') . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr('')) \ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@ -208,8 +208,8 @@ Execute(The C++ Clang handler should include 'include' directories for projects
AssertEqual AssertEqual
\ ale#Escape('clang++') \ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/configure_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/configure_project/include') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/configure_project') . '/include') . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr('')) \ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@ -221,8 +221,8 @@ Execute(The C++ Clang handler should include root directories for projects with
AssertEqual AssertEqual
\ ale#Escape('clang++') \ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/h_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/h_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/h_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr('')) \ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@ -234,8 +234,8 @@ Execute(The C++ Clang handler should include root directories for projects with
AssertEqual AssertEqual
\ ale#Escape('clang++') \ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project/subdir') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project/subdir')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/hpp_file_project') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/hpp_file_project')) . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr('')) \ , 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 AssertEqual
\ ale#Escape('clang++') \ ale#Escape('clang++')
\ . ' -S -x c++ -fsyntax-only ' \ . ' -S -x c++ -fsyntax-only '
\ . '-iquote ' . ale#Escape(g:dir . '/test_c_projects/git_and_nested_makefiles/src') . ' ' \ . '-iquote ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles/src')) . ' '
\ . ' -I' . ale#Escape(g:dir . '/test_c_projects/git_and_nested_makefiles/include') . ' ' \ . ' -I' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/git_and_nested_makefiles') . '/include') . ' '
\ . ' -' \ . ' -'
\ , ale_linters#cpp#clang#GetCommand(bufnr('')) \ , ale_linters#cpp#clang#GetCommand(bufnr(''))
@ -267,8 +267,8 @@ Execute(The C++ ClangTidy handler should include json folders for projects with
AssertEqual AssertEqual
\ ale#Escape('clang-tidy') \ ale#Escape('clang-tidy')
\ . ' -checks=''*'' %s ' \ . ' -checks=' . ale#Escape('*') . ' %s '
\ . '-p ' . ale#Escape(g:dir . '/test_c_projects/json_project/build') \ . '-p ' . ale#Escape(ale#path#Winify(g:dir . '/test_c_projects/json_project') . '/build')
\ , ale_linters#cpp#clangtidy#GetCommand(bufnr('')) \ , ale_linters#cpp#clangtidy#GetCommand(bufnr(''))
Execute(Move .git/HEAD back): Execute(Move .git/HEAD back):

View File

@ -1,7 +1,11 @@
Before: Before:
Save &shell, g:ale_run_synchronously Save &shell, g:ale_run_synchronously
let g:ale_run_synchronously = 1 let g:ale_run_synchronously = 1
if !has('win32')
set shell=/bin/sh set shell=/bin/sh
endif
let g:linter_output = [] let g:linter_output = []
let g:first_echo_called = 0 let g:first_echo_called = 0
let g:second_echo_called = 0 let g:second_echo_called = 0
@ -9,7 +13,7 @@ Before:
function! CollectResults(buffer, output) function! CollectResults(buffer, output)
let g:final_callback_called = 1 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 [] return []
endfunction endfunction
function! RunFirstEcho(buffer) function! RunFirstEcho(buffer)
@ -26,7 +30,7 @@ Before:
call ale#linter#Define('foobar', { call ale#linter#Define('foobar', {
\ 'name': 'testlinter', \ 'name': 'testlinter',
\ 'callback': 'CollectResults', \ 'callback': 'CollectResults',
\ 'executable': 'echo', \ 'executable': has('win32') ? 'cmd' : 'echo',
\ 'command_chain': [ \ 'command_chain': [
\ { \ {
\ 'callback': 'RunFirstEcho', \ 'callback': 'RunFirstEcho',

View File

@ -13,7 +13,7 @@ Execute(--config should be set when the .csslintrc file is found):
AssertEqual AssertEqual
\ ( \ (
\ 'csslint --format=compact ' \ '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' \ . ' %t'
\ ), \ ),
\ ale_linters#css#csslint#GetCommand(bufnr('')) \ ale_linters#css#csslint#GetCommand(bufnr(''))

View File

@ -12,7 +12,7 @@ Execute(should get valid executable with default params):
call ale#test#SetFilename('elm-test-files/app/testfile.elm') call ale#test#SetFilename('elm-test-files/app/testfile.elm')
AssertEqual 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('')) \ ale_linters#elm#make#GetExecutable(bufnr(''))
Execute(should get valid executable with 'use_global' params): Execute(should get valid executable with 'use_global' params):

View File

@ -13,7 +13,7 @@ Before:
call ale#linter#Define('foobar', { call ale#linter#Define('foobar', {
\ 'name': 'buffer_linter', \ 'name': 'buffer_linter',
\ 'callback': 'TestCallback', \ 'callback': 'TestCallback',
\ 'executable': 'true', \ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true', \ 'command': 'true',
\ 'read_buffer': 0, \ 'read_buffer': 0,
\}) \})
@ -21,7 +21,7 @@ Before:
call ale#linter#Define('foobar2', { call ale#linter#Define('foobar2', {
\ 'name': 'buffer_linter', \ 'name': 'buffer_linter',
\ 'callback': 'TestCallback', \ 'callback': 'TestCallback',
\ 'executable': 'true', \ 'executable': has('win32') ? 'cmd': 'true',
\ 'command': 'true', \ 'command': 'true',
\ 'read_buffer': 0, \ 'read_buffer': 0,
\}) \})
@ -41,12 +41,14 @@ After:
Execute(Error should be removed when the filetype changes to something else we cannot check): Execute(Error should be removed when the filetype changes to something else we cannot check):
call ale#Queue(0) call ale#Queue(0)
sleep 1ms
AssertEqual 1, len(getloclist(0)) AssertEqual 1, len(getloclist(0))
noautocmd let &filetype = 'foobar2' noautocmd let &filetype = 'foobar2'
call ale#Queue(0) call ale#Queue(0)
sleep 1ms
" We should get some items from the second filetype. " We should get some items from the second filetype.
AssertEqual 1, len(getloclist(0)) 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' noautocmd let &filetype = 'xxx'
call ale#Queue(0) call ale#Queue(0)
sleep 1ms
AssertEqual 0, len(getloclist(0)) AssertEqual 0, len(getloclist(0))

View File

@ -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') call ale#test#SetFilename('eslint-test-files/react-app/subdir/testfile.js')
AssertEqual 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('')) \ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(use-global should override create-react-app detection): 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') call ale#test#SetFilename('eslint-test-files/other-app/subdir/testfile.js')
AssertEqual 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('')) \ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(use-global should override other app directories): 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') call ale#test#SetFilename('eslint-test-files/app-with-eslint-d/testfile.js')
AssertEqual 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('')) \ ale#handlers#eslint#GetExecutable(bufnr(''))
Execute(eslint.js executables should be run with node on Windows): 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. " We have to execute the file with node.
AssertEqual AssertEqual
\ ale#Escape('node.exe') . ' ' \ 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', \ . ' -f unix --stdin --stdin-filename %s',
\ ale#handlers#eslint#GetCommand(bufnr('')) \ ale#handlers#eslint#GetCommand(bufnr(''))

View File

@ -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') call ale#test#SetFilename('top/middle/bottom/dummy.txt')
AssertEqual 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') \ ale#path#FindNearestDirectory(bufnr('%'), 'ale-special-directory-name-dont-use-this-please')
Execute(We shouldn't find anything for files which don't match): Execute(We shouldn't find anything for files which don't match):

View File

@ -9,13 +9,17 @@ After:
Execute(flow should return a command to run if a .flowconfig file exists): Execute(flow should return a command to run if a .flowconfig file exists):
call ale#test#SetFilename('flow/a/sub/dummy') 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): Execute(flow should should not use --respect-pragma for old versions):
call ale#test#SetFilename('flow/a/sub/dummy') call ale#test#SetFilename('flow/a/sub/dummy')
AssertEqual AssertEqual
\ '''flow'' check-contents --json --from ale %s', \ ale#Escape('flow')
\ . ' check-contents --json --from ale %s',
\ ale_linters#javascript#flow#GetCommand(bufnr('%'), [ \ ale_linters#javascript#flow#GetCommand(bufnr('%'), [
\ 'Warning: `flow --version` is deprecated in favor of `flow version`', \ 'Warning: `flow --version` is deprecated in favor of `flow version`',
\ 'Flow, a static type checker for JavaScript, version 0.27.0', \ 'Flow, a static type checker for JavaScript, version 0.27.0',