Merge #8120 'test: win: prefer cmd.exe'

This commit is contained in:
Justin M. Keyes
2018-04-15 18:16:37 +02:00
committed by GitHub
2 changed files with 106 additions and 64 deletions

View File

@@ -19,14 +19,18 @@ local expect_twostreams = helpers.expect_twostreams
local expect_msg_seq = helpers.expect_msg_seq local expect_msg_seq = helpers.expect_msg_seq
local Screen = require('test.functional.ui.screen') local Screen = require('test.functional.ui.screen')
-- Kill process with given pid
local function os_kill(pid)
return os.execute((iswin()
and 'taskkill /f /t /pid '..pid..' > nul'
or 'kill -9 '..pid..' > /dev/null'))
end
describe('jobs', function() describe('jobs', function()
local channel local channel
before_each(function() before_each(function()
clear() clear()
if iswin() then
helpers.set_shell_powershell()
end
channel = nvim('get_api_info')[1] channel = nvim('get_api_info')[1]
nvim('set_var', 'channel', channel) nvim('set_var', 'channel', channel)
source([[ source([[
@@ -52,7 +56,7 @@ describe('jobs', function()
it('uses &shell and &shellcmdflag if passed a string', function() it('uses &shell and &shellcmdflag if passed a string', function()
nvim('command', "let $VAR = 'abc'") nvim('command', "let $VAR = 'abc'")
if iswin() then if iswin() then
nvim('command', "let j = jobstart('echo $env:VAR', g:job_opts)") nvim('command', "let j = jobstart('echo %VAR%', g:job_opts)")
else else
nvim('command', "let j = jobstart('echo $VAR', g:job_opts)") nvim('command', "let j = jobstart('echo $VAR', g:job_opts)")
end end
@@ -64,7 +68,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('(Get-Location).Path', g:job_opts)") nvim('command', "let j = jobstart('cd', 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
@@ -79,7 +83,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('(Get-Location).Path', g:job_opts)") nvim('command', "let j = jobstart('cd', 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
@@ -103,7 +107,7 @@ describe('jobs', function()
local _, err = pcall(function() local _, err = pcall(function()
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('cd', 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
@@ -134,10 +138,8 @@ describe('jobs', function()
end) end)
it('invokes callbacks when the job writes and exits', function() it('invokes callbacks when the job writes and exits', function()
-- TODO: hangs on Windows
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(has('win32') ? 'echo:' : '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, {''}}}})
@@ -145,15 +147,28 @@ describe('jobs', function()
end) end)
it('allows interactive commands', function() it('allows interactive commands', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`. nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
neq(0, eval('j')) neq(0, eval('j'))
nvim('command', 'call jobsend(j, "abc\\n")') nvim('command', 'call jobsend(j, "abc\\n")')
eq({'notification', 'stdout', {0, {'abc', ''}}}, next_msg()) eq({'notification', 'stdout', {0, {'abc', ''}}}, next_msg())
nvim('command', 'call jobsend(j, "123\\nxyz\\n")') nvim('command', 'call jobsend(j, "123\\nxyz\\n")')
eq({'notification', 'stdout', {0, {'123', 'xyz', ''}}}, next_msg()) expect_msg_seq(
{ {'notification', 'stdout', {0, {'123', 'xyz', ''}}}
},
-- Alternative sequence:
{ {'notification', 'stdout', {0, {'123', ''}}},
{'notification', 'stdout', {0, {'xyz', ''}}}
}
)
nvim('command', 'call jobsend(j, [123, "xyz", ""])') nvim('command', 'call jobsend(j, [123, "xyz", ""])')
eq({'notification', 'stdout', {0, {'123', 'xyz', ''}}}, next_msg()) expect_msg_seq(
{ {'notification', 'stdout', {0, {'123', 'xyz', ''}}}
},
-- Alternative sequence:
{ {'notification', 'stdout', {0, {'123', ''}}},
{'notification', 'stdout', {0, {'xyz', ''}}}
}
)
nvim('command', "call jobstop(j)") nvim('command', "call jobstop(j)")
eq({'notification', 'stdout', {0, {''}}}, next_msg()) eq({'notification', 'stdout', {0, {''}}}, next_msg())
eq({'notification', 'exit', {0, 0}}, next_msg()) eq({'notification', 'exit', {0, 0}}, next_msg())
@@ -226,16 +241,14 @@ describe('jobs', function()
end) end)
it('closes the job streams with jobclose', function() it('closes the job streams with jobclose', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`. nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
nvim('command', 'call jobclose(j, "stdin")') nvim('command', 'call jobclose(j, "stdin")')
eq({'notification', 'stdout', {0, {''}}}, next_msg()) eq({'notification', 'stdout', {0, {''}}}, next_msg())
eq({'notification', 'exit', {0, 0}}, next_msg()) eq({'notification', 'exit', {0, iswin() and 1 or 0}}, next_msg())
end) end)
it("disallows jobsend on a job that closed stdin", function() it("disallows jobsend on a job that closed stdin", function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`. nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
nvim('command', 'call jobclose(j, "stdin")') nvim('command', 'call jobclose(j, "stdin")')
eq(false, pcall(function() eq(false, pcall(function()
nvim('command', 'call jobsend(j, ["some data"])') nvim('command', 'call jobsend(j, ["some data"])')
@@ -248,8 +261,7 @@ describe('jobs', function()
end) end)
it('disallows jobstop twice on the same job', function() it('disallows jobstop twice on the same job', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`. nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
neq(0, eval('j')) neq(0, eval('j'))
eq(true, pcall(eval, "jobstop(j)")) eq(true, pcall(eval, "jobstop(j)"))
eq(false, pcall(eval, "jobstop(j)")) eq(false, pcall(eval, "jobstop(j)"))
@@ -260,41 +272,49 @@ describe('jobs', function()
end) end)
it('can get the pid value using getpid', function() it('can get the pid value using getpid', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`. nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
local pid = eval('jobpid(j)') local pid = eval('jobpid(j)')
eq(0,os.execute('ps -p '..pid..' > /dev/null')) neq(NIL, meths.get_proc(pid))
nvim('command', 'call jobstop(j)') nvim('command', 'call jobstop(j)')
eq({'notification', 'stdout', {0, {''}}}, next_msg()) eq({'notification', 'stdout', {0, {''}}}, next_msg())
eq({'notification', 'exit', {0, 0}}, next_msg()) if iswin() then
neq(0,os.execute('ps -p '..pid..' > /dev/null')) expect_msg_seq(
-- win64
{ {'notification', 'exit', {0, 1}}
},
-- win32
{ {'notification', 'exit', {0, 15}}
}
)
else
eq({'notification', 'exit', {0, 0}}, next_msg())
end
eq(NIL, meths.get_proc(pid))
end) end)
it("do not survive the exit of nvim", function() it("do not survive the exit of nvim", function()
if helpers.pending_win32(pending) then return end
-- use sleep, which doesn't die on stdin close -- use sleep, which doesn't die on stdin close
nvim('command', "let g:j = jobstart(['sleep', '1000'], g:job_opts)") nvim('command', "let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)")
local pid = eval('jobpid(g:j)') local pid = eval('jobpid(g:j)')
eq(0,os.execute('ps -p '..pid..' > /dev/null')) neq(NIL, meths.get_proc(pid))
clear() clear()
neq(0,os.execute('ps -p '..pid..' > /dev/null')) eq(NIL, meths.get_proc(pid))
end) end)
it('can survive the exit of nvim with "detach"', function() it('can survive the exit of nvim with "detach"', function()
if helpers.pending_win32(pending) then return end
nvim('command', 'let g:job_opts.detach = 1') nvim('command', 'let g:job_opts.detach = 1')
nvim('command', "let g:j = jobstart(['sleep', '1000'], g:job_opts)") nvim('command', "let g:j = jobstart(has('win32') ? ['ping', '-n', '1001', '127.0.0.1'] : ['sleep', '1000'], g:job_opts)")
local pid = eval('jobpid(g:j)') local pid = eval('jobpid(g:j)')
eq(0,os.execute('ps -p '..pid..' > /dev/null')) neq(NIL, meths.get_proc(pid))
clear() clear()
eq(0,os.execute('ps -p '..pid..' > /dev/null')) neq(NIL, meths.get_proc(pid))
-- clean up after ourselves -- clean up after ourselves
os.execute('kill -9 '..pid..' > /dev/null') eq(0, os_kill(pid))
end) end)
it('can pass user data to the callback', function() it('can pass user data to the callback', function()
nvim('command', 'let g:job_opts.user = {"n": 5, "s": "str", "l": [1]}') nvim('command', 'let g:job_opts.user = {"n": 5, "s": "str", "l": [1]}')
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]]) nvim('command', [[call jobstart('echo foo', g:job_opts)]])
local data = {n = 5, s = 'str', l = {1}} local data = {n = 5, s = 'str', l = {1}}
expect_msg_seq( expect_msg_seq(
{ {'notification', 'stdout', {data, {'foo', ''}}}, { {'notification', 'stdout', {data, {'foo', ''}}},
@@ -312,14 +332,14 @@ describe('jobs', function()
it('can omit data callbacks', function() it('can omit data callbacks', function()
nvim('command', 'unlet g:job_opts.on_stdout') nvim('command', 'unlet g:job_opts.on_stdout')
nvim('command', 'let g:job_opts.user = 5') nvim('command', 'let g:job_opts.user = 5')
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]]) nvim('command', [[call jobstart('echo foo', g:job_opts)]])
eq({'notification', 'exit', {5, 0}}, next_msg()) eq({'notification', 'exit', {5, 0}}, next_msg())
end) end)
it('can omit exit callback', function() it('can omit exit callback', function()
nvim('command', 'unlet g:job_opts.on_exit') nvim('command', 'unlet g:job_opts.on_exit')
nvim('command', 'let g:job_opts.user = 5') nvim('command', 'let g:job_opts.user = 5')
nvim('command', [[call jobstart('echo "foo"', g:job_opts)]]) nvim('command', [[call jobstart('echo foo', g:job_opts)]])
expect_msg_seq( expect_msg_seq(
{ {'notification', 'stdout', {5, {'foo', ''} } }, { {'notification', 'stdout', {5, {'foo', ''} } },
{'notification', 'stdout', {5, {''} } }, {'notification', 'stdout', {5, {''} } },
@@ -401,15 +421,14 @@ describe('jobs', function()
end) end)
it('does not repeat output with slow output handlers', function() it('does not repeat output with slow output handlers', function()
if helpers.pending_win32(pending) then return end
source([[ source([[
let d = {'data': []} let d = {'data': []}
function! d.on_stdout(job, data, event) dict function! d.on_stdout(job, data, event) dict
call add(self.data, a:data) call add(self.data, Normalize(a:data))
sleep 200m sleep 200m
endfunction endfunction
if has('win32') if has('win32')
let cmd = '1,2,3,4,5 | foreach-object -process {echo $_; sleep 0.1}' let cmd = 'for /L %I in (1,1,5) do @(echo %I& ping -n 2 127.0.0.1 > nul)'
else else
let cmd = ['sh', '-c', 'for i in $(seq 1 5); do echo $i; sleep 0.1; done'] let cmd = ['sh', '-c', 'for i in $(seq 1 5); do echo $i; sleep 0.1; done']
endif endif
@@ -428,7 +447,7 @@ describe('jobs', function()
endfunction endfunction
let Callback = function('PrintArgs', ["foo", "bar"]) let Callback = function('PrintArgs', ["foo", "bar"])
let g:job_opts = {'on_stdout': Callback} let g:job_opts = {'on_stdout': Callback}
call jobstart('echo "some text"', g:job_opts) call jobstart('echo some text', g:job_opts)
]]) ]])
expect_msg_seq( expect_msg_seq(
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}}, { {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
@@ -448,7 +467,7 @@ describe('jobs', function()
return {id, data, event -> rpcnotify(g:channel, '1', a1, a2, Normalize(data), event)} return {id, data, event -> rpcnotify(g:channel, '1', a1, a2, Normalize(data), event)}
endfun endfun
let g:job_opts = {'on_stdout': MkFun()} let g:job_opts = {'on_stdout': MkFun()}
call jobstart('echo "some text"', g:job_opts) call jobstart('echo some text', g:job_opts)
]]) ]])
expect_msg_seq( expect_msg_seq(
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}}, { {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
@@ -463,7 +482,7 @@ describe('jobs', function()
it('jobstart() works when closure passed directly to `jobstart`', function() it('jobstart() works when closure passed directly to `jobstart`', function()
source([[ source([[
let g:job_opts = {'on_stdout': {id, data, event -> rpcnotify(g:channel, '1', 'foo', 'bar', Normalize(data), event)}} let g:job_opts = {'on_stdout': {id, data, event -> rpcnotify(g:channel, '1', 'foo', 'bar', Normalize(data), event)}}
call jobstart('echo "some text"', g:job_opts) call jobstart('echo some text', g:job_opts)
]]) ]])
expect_msg_seq( expect_msg_seq(
{ {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}}, { {'notification', '1', {'foo', 'bar', {'some text', ''}, 'stdout'}},
@@ -476,9 +495,20 @@ describe('jobs', function()
end) end)
describe('jobwait', function() describe('jobwait', function()
before_each(function()
if iswin() then
helpers.set_shell_powershell()
end
end)
it('returns a list of status codes', function() it('returns a list of status codes', function()
source([[ source([[
call rpcnotify(g:channel, 'wait', jobwait([ call rpcnotify(g:channel, 'wait', jobwait(has('win32') ? [
\ jobstart('Start-Sleep -Milliseconds 100; exit 4'),
\ jobstart('Start-Sleep -Milliseconds 300; exit 5'),
\ jobstart('Start-Sleep -Milliseconds 500; exit 6'),
\ jobstart('Start-Sleep -Milliseconds 700; exit 7')
\ ] : [
\ jobstart('sleep 0.10; exit 4'), \ jobstart('sleep 0.10; exit 4'),
\ jobstart('sleep 0.110; exit 5'), \ jobstart('sleep 0.110; exit 5'),
\ jobstart('sleep 0.210; exit 6'), \ jobstart('sleep 0.210; exit 6'),
@@ -498,7 +528,12 @@ describe('jobs', function()
endif endif
let g:exits += 1 let g:exits += 1
endfunction endfunction
call jobwait([ call jobwait(has('win32') ? [
\ jobstart('Start-Sleep -Milliseconds 100; exit 5', g:dict),
\ jobstart('Start-Sleep -Milliseconds 300; exit 5', g:dict),
\ jobstart('Start-Sleep -Milliseconds 500; exit 5', g:dict),
\ jobstart('Start-Sleep -Milliseconds 700; exit 5', g:dict)
\ ] : [
\ jobstart('sleep 0.010; exit 5', g:dict), \ jobstart('sleep 0.010; exit 5', g:dict),
\ jobstart('sleep 0.030; exit 5', g:dict), \ jobstart('sleep 0.030; exit 5', g:dict),
\ jobstart('sleep 0.050; exit 5', g:dict), \ jobstart('sleep 0.050; exit 5', g:dict),
@@ -511,7 +546,12 @@ describe('jobs', function()
it('will return status codes in the order of passed ids', function() it('will return status codes in the order of passed ids', function()
source([[ source([[
call rpcnotify(g:channel, 'wait', jobwait([ call rpcnotify(g:channel, 'wait', jobwait(has('win32') ? [
\ jobstart('Start-Sleep -Milliseconds 700; exit 4'),
\ jobstart('Start-Sleep -Milliseconds 500; exit 5'),
\ jobstart('Start-Sleep -Milliseconds 300; exit 6'),
\ jobstart('Start-Sleep -Milliseconds 100; exit 7')
\ ] : [
\ jobstart('sleep 0.070; exit 4'), \ jobstart('sleep 0.070; exit 4'),
\ jobstart('sleep 0.050; exit 5'), \ jobstart('sleep 0.050; exit 5'),
\ jobstart('sleep 0.030; exit 6'), \ jobstart('sleep 0.030; exit 6'),
@@ -525,7 +565,7 @@ describe('jobs', function()
source([[ source([[
call rpcnotify(g:channel, 'wait', jobwait([ call rpcnotify(g:channel, 'wait', jobwait([
\ -10, \ -10,
\ jobstart('sleep 0.01; exit 5'), \ jobstart((has('win32') ? 'Start-Sleep -Milliseconds 100' : 'sleep 0.01').'; exit 5'),
\ ])) \ ]))
]]) ]])
eq({'notification', 'wait', {{-3, 5}}}, next_msg()) eq({'notification', 'wait', {{-3, 5}}}, next_msg())
@@ -534,7 +574,9 @@ describe('jobs', function()
it('will return -2 when interrupted without timeout', function() it('will return -2 when interrupted without timeout', function()
feed_command('call rpcnotify(g:channel, "ready") | '.. feed_command('call rpcnotify(g:channel, "ready") | '..
'call rpcnotify(g:channel, "wait", '.. 'call rpcnotify(g:channel, "wait", '..
'jobwait([jobstart("sleep 10; exit 55")]))') 'jobwait([jobstart("'..
(iswin() and 'Start-Sleep 10' or 'sleep 10')..
'; exit 55")]))')
eq({'notification', 'ready', {}}, next_msg()) eq({'notification', 'ready', {}}, next_msg())
feed('<c-c>') feed('<c-c>')
eq({'notification', 'wait', {{-2}}}, next_msg()) eq({'notification', 'wait', {{-2}}}, next_msg())
@@ -543,7 +585,9 @@ describe('jobs', function()
it('will return -2 when interrupted with timeout', function() it('will return -2 when interrupted with timeout', function()
feed_command('call rpcnotify(g:channel, "ready") | '.. feed_command('call rpcnotify(g:channel, "ready") | '..
'call rpcnotify(g:channel, "wait", '.. 'call rpcnotify(g:channel, "wait", '..
'jobwait([jobstart("sleep 10; exit 55")], 10000))') 'jobwait([jobstart("'..
(iswin() and 'Start-Sleep 10' or 'sleep 10')..
'; exit 55")], 10000))')
eq({'notification', 'ready', {}}, next_msg()) eq({'notification', 'ready', {}}, next_msg())
feed('<c-c>') feed('<c-c>')
eq({'notification', 'wait', {{-2}}}, next_msg()) eq({'notification', 'wait', {{-2}}}, next_msg())
@@ -598,20 +642,22 @@ describe('jobs', function()
end) end)
describe('with timeout argument', function() describe('with timeout argument', function()
if helpers.pending_win32(pending) then return end
it('will return -1 if the wait timed out', function() it('will return -1 if the wait timed out', function()
source([[ source([[
call rpcnotify(g:channel, 'wait', jobwait([ call rpcnotify(g:channel, 'wait', jobwait([
\ jobstart('exit 4'), \ jobstart('exit 4'),
\ jobstart('sleep 10; exit 5'), \ jobstart((has('win32') ? 'Start-Sleep 10' : 'sleep 10').'; exit 5'),
\ ], 100)) \ ], has('win32') ? 3000 : 100))
]]) ]])
eq({'notification', 'wait', {{4, -1}}}, next_msg()) eq({'notification', 'wait', {{4, -1}}}, next_msg())
end) end)
it('can pass 0 to check if a job exists', function() it('can pass 0 to check if a job exists', function()
source([[ source([[
call rpcnotify(g:channel, 'wait', jobwait([ call rpcnotify(g:channel, 'wait', jobwait(has('win32') ? [
\ jobstart('Start-Sleep -Milliseconds 50; exit 4'),
\ jobstart('Start-Sleep -Milliseconds 300; exit 5'),
\ ] : [
\ jobstart('sleep 0.05; exit 4'), \ jobstart('sleep 0.05; exit 4'),
\ jobstart('sleep 0.3; exit 5'), \ jobstart('sleep 0.3; exit 5'),
\ ], 0)) \ ], 0))
@@ -633,10 +679,9 @@ describe('jobs', function()
end) end)
it('cannot have both rpc and pty options', function() it('cannot have both rpc and pty options', function()
if helpers.pending_win32(pending) then return end -- TODO: Need `cat`.
command("let g:job_opts.pty = v:true") command("let g:job_opts.pty = v:true")
command("let g:job_opts.rpc = v:true") command("let g:job_opts.rpc = v:true")
local _, err = pcall(command, "let j = jobstart(['cat', '-'], g:job_opts)") local _, err = pcall(command, "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
ok(string.find(err, "E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set") ~= nil) ok(string.find(err, "E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set") ~= nil)
end) end)
@@ -656,19 +701,16 @@ describe('jobs', function()
end) end)
it('jobstop() kills entire process tree #6530', function() it('jobstop() kills entire process tree #6530', function()
command('set shell& shellcmdflag& shellquote& shellpipe& shellredir& shellxquote&')
-- XXX: Using `nvim` isn't a good test, it reaps its children on exit. -- XXX: Using `nvim` isn't a good test, it reaps its children on exit.
-- local c = 'call jobstart([v:progpath, "-u", "NONE", "-i", "NONE", "--headless"])' -- local c = 'call jobstart([v:progpath, "-u", "NONE", "-i", "NONE", "--headless"])'
-- local j = eval("jobstart([v:progpath, '-u', 'NONE', '-i', 'NONE', '--headless', '-c', '" -- local j = eval("jobstart([v:progpath, '-u', 'NONE', '-i', 'NONE', '--headless', '-c', '"
-- ..c.."', '-c', '"..c.."'])") -- ..c.."', '-c', '"..c.."'])")
-- Create child with several descendants. -- Create child with several descendants.
local j = (iswin() local sleep_cmd = (iswin()
and eval([=[jobstart('start /b cmd /c "ping 127.0.0.1 -n 1 -w 30000 > NUL"]=] and 'ping -n 31 127.0.0.1'
..[=[ & start /b cmd /c "ping 127.0.0.1 -n 1 -w 40000 > NUL"]=] or 'sleep 30')
..[=[ & start /b cmd /c "ping 127.0.0.1 -n 1 -w 50000 > NUL"')]=]) local j = eval("jobstart('"..sleep_cmd..' | '..sleep_cmd..' | '..sleep_cmd.."')")
or eval("jobstart('sleep 30 | sleep 30 | sleep 30')"))
local ppid = funcs.jobpid(j) local ppid = funcs.jobpid(j)
local children local children
retry(nil, nil, function() retry(nil, nil, function()

View File

@@ -427,7 +427,7 @@ end
local function set_shell_powershell() local function set_shell_powershell()
source([[ source([[
set shell=powershell shellquote=( shellpipe=\| shellredir=> shellxquote= set shell=powershell shellquote=( shellpipe=\| shellredir=> shellxquote=
set shellcmdflag=-NoLogo\ -NoProfile\ -ExecutionPolicy\ RemoteSigned\ -Command let &shellcmdflag = '-NoLogo -NoProfile -ExecutionPolicy RemoteSigned -Command Remove-Item -Force alias:sleep;'
]]) ]])
end end