aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2018-03-18 00:09:28 +0100
committerJustin M. Keyes <justinkz@gmail.com>2018-03-18 17:03:05 +0100
commit167898a5177de6d2fa6ae553fc3305d399b453d3 (patch)
tree4910bb984172a64b7d467fbcc4eae7645e07a5c5
parenta034d4b69d6032b3431c10b8a11c998551700fc2 (diff)
downloadrneovim-167898a5177de6d2fa6ae553fc3305d399b453d3.tar.gz
rneovim-167898a5177de6d2fa6ae553fc3305d399b453d3.tar.bz2
rneovim-167898a5177de6d2fa6ae553fc3305d399b453d3.zip
test: jobstop() kills entire process tree
Test correctly fails before 8d90171f8be6. ref #6530
-rw-r--r--test/functional/core/job_spec.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index c5326aedfe..aaa35f6c62 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -6,6 +6,10 @@ local clear, eq, eval, exc_exec, feed_command, feed, insert, neq, next_msg, nvim
helpers.nvim_dir, helpers.ok, helpers.source,
helpers.write_file, helpers.mkdir, helpers.rmdir
local command = helpers.command
+local funcs = helpers.funcs
+local retry = helpers.retry
+local meths = helpers.meths
+local NIL = helpers.NIL
local wait = helpers.wait
local iswin = helpers.iswin
local get_pathsep = helpers.get_pathsep
@@ -636,6 +640,40 @@ describe('jobs', function()
ok(string.find(err, "E475: Invalid argument: job cannot have both 'pty' and 'rpc' options set") ~= nil)
end)
+ it('jobstop() kills entire process tree #6530', function()
+ -- 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 j = eval("jobstart([v:progpath, '-u', 'NONE', '-i', 'NONE', '--headless', '-c', '"
+ -- ..c.."', '-c', '"..c.."'])")
+
+ -- Create child with several descendants.
+ local j = (iswin()
+ and eval([=[jobstart('start /b cmd /c "ping 127.0.0.1 -n 1 -w 30000 > NUL"]=]
+ ..[=[ & start /b cmd /c "ping 127.0.0.1 -n 1 -w 40000 > NUL"]=]
+ ..[=[ & start /b cmd /c "ping 127.0.0.1 -n 1 -w 50000 > NUL"')]=])
+ or eval("jobstart('sleep 30 | sleep 30 | sleep 30')"))
+ local ppid = funcs.jobpid(j)
+ local children
+ retry(nil, nil, function()
+ children = meths.get_proc_children(ppid)
+ eq(3, #children)
+ end)
+ -- Assert that nvim_get_proc() sees the children.
+ for _, child_pid in ipairs(children) do
+ local info = meths.get_proc(child_pid)
+ -- eq((iswin() and 'nvim.exe' or 'nvim'), info.name)
+ eq(ppid, info.ppid)
+ end
+ -- Kill the root of the tree.
+ funcs.jobstop(j)
+ -- Assert that the children were killed.
+ retry(nil, nil, function()
+ for _, child_pid in ipairs(children) do
+ eq(NIL, meths.get_proc(child_pid))
+ end
+ end)
+ end)
+
describe('running tty-test program', function()
if helpers.pending_win32(pending) then return end
local function next_chunk()