win: enable job tests that use jobstart only

- echo "" does not hang in powershell
    - cmd.exe's echo command does not hang.
    - job tests default to powershell (WHY?)
- wait 5 seconds for powershell to create an empty file
    - powershell is slow
    - cannot reliably validate the id returned by jobstart via jobpid, jobstop
    - if using cmd.exe, waiting for a second should be enough
- remaining job tests are unreliable in Windows because any build can pass/fail
  for same conditions without changes, especially if the error is in stderr
This commit is contained in:
Jan Edmund Lazo
2017-10-06 22:37:48 -04:00
parent 00665d3c70
commit 3e19e18f4c

View File

@@ -60,7 +60,7 @@ describe('jobs', function()
it('changes to given / directory', function() it('changes to given / directory', function()
nvim('command', "let g:job_opts.cwd = '/'") nvim('command', "let g:job_opts.cwd = '/'")
if iswin() then if iswin() then
nvim('command', "let j = jobstart('pwd|%{$_.Path}', g:job_opts)") nvim('command', "let j = jobstart('(Get-Location).Path', g:job_opts)")
else else
nvim('command', "let j = jobstart('pwd', g:job_opts)") nvim('command', "let j = jobstart('pwd', g:job_opts)")
end end
@@ -75,7 +75,7 @@ describe('jobs', function()
mkdir(dir) mkdir(dir)
nvim('command', "let g:job_opts.cwd = '" .. dir .. "'") nvim('command', "let g:job_opts.cwd = '" .. dir .. "'")
if iswin() then if iswin() then
nvim('command', "let j = jobstart('pwd|%{$_.Path}', g:job_opts)") nvim('command', "let j = jobstart('(Get-Location).Path', g:job_opts)")
else else
nvim('command', "let j = jobstart('pwd', g:job_opts)") nvim('command', "let j = jobstart('pwd', g:job_opts)")
end end
@@ -115,13 +115,13 @@ describe('jobs', function()
end) end)
it('returns -1 when target is not executable #5465', function() it('returns -1 when target is not executable #5465', function()
if helpers.pending_win32(pending) then return end
local function new_job() local function new_job()
return eval([[jobstart('')]]) return eval([[jobstart('')]])
end end
local executable_jobid = new_job() local executable_jobid = new_job()
local nonexecutable_jobid = eval( local nonexecutable_jobid = eval("jobstart(['"..(iswin()
"jobstart(['./test/functional/fixtures/non_executable.txt'])") and './test/functional/fixtures'
or './test/functional/fixtures/non_executable.txt').."'])")
eq(-1, nonexecutable_jobid) eq(-1, nonexecutable_jobid)
-- Should _not_ throw an error. -- Should _not_ throw an error.
eq("", eval("v:errmsg")) eq("", eval("v:errmsg"))
@@ -133,11 +133,10 @@ describe('jobs', function()
-- TODO: hangs on Windows -- TODO: hangs on Windows
if helpers.pending_win32(pending) then return end if helpers.pending_win32(pending) then return end
nvim('command', "let g:job_opts.on_stderr = function('OnEvent')") nvim('command', "let g:job_opts.on_stderr = function('OnEvent')")
nvim('command', "call jobstart('echo', g:job_opts)") nvim('command', [[call jobstart('echo ""', g:job_opts)]])
expect_twostreams({{'notification', 'stdout', {0, {'', ''}}}, expect_twostreams({{'notification', 'stdout', {0, {'', ''}}},
{'notification', 'stdout', {0, {''}}}}, {'notification', 'stdout', {0, {''}}}},
{{'notification', 'stderr', {0, {''}}}}) {{'notification', 'stderr', {0, {''}}}})
eq({'notification', 'exit', {0, 0}}, next_msg()) eq({'notification', 'exit', {0, 0}}, next_msg())
end) end)
@@ -253,7 +252,6 @@ describe('jobs', function()
end) end)
it('will not leak memory if we leave a job running', function() it('will not leak memory if we leave a job running', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
nvim('command', "call jobstart(['cat', '-'], g:job_opts)") nvim('command', "call jobstart(['cat', '-'], g:job_opts)")
end) end)
@@ -300,11 +298,7 @@ describe('jobs', function()
end) end)
it('can omit options', function() it('can omit options', function()
if helpers.pending_win32(pending) then return end ok(eval([[jobstart('echo ""')]]) > 0)
neq(0, nvim('eval', 'delete(".Xtestjob")'))
nvim('command', "call jobstart(['touch', '.Xtestjob'])")
nvim('command', "sleep 100m")
eq(0, nvim('eval', 'delete(".Xtestjob")'))
end) end)
it('can omit data callbacks', function() it('can omit data callbacks', function()
@@ -348,7 +342,6 @@ describe('jobs', function()
end) end)
it('can redefine callbacks being used by a job', function() it('can redefine callbacks being used by a job', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
local screen = Screen.new() local screen = Screen.new()
screen:attach() screen:attach()
screen:set_default_attr_ids({ screen:set_default_attr_ids({
@@ -363,7 +356,7 @@ describe('jobs', function()
\ 'on_stderr': function('g:JobHandler'), \ 'on_stderr': function('g:JobHandler'),
\ 'on_exit': function('g:JobHandler') \ 'on_exit': function('g:JobHandler')
\ } \ }
let job = jobstart('cat -', g:callbacks) let job = jobstart(['cat', '-'], g:callbacks)
]]) ]])
wait() wait()
source([[ source([[