aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--runtime/lua/man.lua6
-rw-r--r--test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua4
-rw-r--r--test/functional/helpers.lua15
3 files changed, 21 insertions, 4 deletions
diff --git a/runtime/lua/man.lua b/runtime/lua/man.lua
index f0306f4871..88535321ac 100644
--- a/runtime/lua/man.lua
+++ b/runtime/lua/man.lua
@@ -21,13 +21,15 @@ local function man_system(cmd, silent)
local done = false
local exit_code
- local handle = vim.loop.spawn(cmd[1], {
+ local handle
+ handle = vim.loop.spawn(cmd[1], {
args = vim.list_slice(cmd, 2),
stdio = { nil, stdout, stderr },
}, function(code)
exit_code = code
stdout:close()
stderr:close()
+ handle:close()
done = true
end)
@@ -52,7 +54,7 @@ local function man_system(cmd, silent)
if not done then
if handle then
- vim.loop.shutdown(handle)
+ handle:close()
stdout:close()
stderr:close()
end
diff --git a/test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua b/test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua
index a312572c5b..45226ce24b 100644
--- a/test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua
+++ b/test/functional/fixtures/start/nvim-leftpad/lua/async_leftpad.lua
@@ -1,3 +1,5 @@
return function (val, res)
- vim.loop.new_async(function() _G[res] = require'leftpad'(val) end):send()
+ local handle
+ handle = vim.loop.new_async(function() _G[res] = require'leftpad'(val) handle:close() end)
+ handle:send()
end
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index d672037a1e..eff54b6d4a 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -380,10 +380,23 @@ local function remove_args(args, args_rm)
return new_args
end
+function module.check_close(old_session)
+ local start_time = luv.now()
+ old_session:close()
+ luv.update_time() -- Update cached value of luv.now() (libuv: uv_now()).
+ local end_time = luv.now()
+ local delta = end_time - start_time
+ if delta > 500 then
+ print("nvim took " .. delta .. " milliseconds to exit after last test\n"..
+ "This indicates a likely problem with the test even if it passed!\n")
+ io.stdout:flush()
+ end
+end
+
--- @param io_extra used for stdin_fd, see :help ui-option
function module.spawn(argv, merge, env, keep, io_extra)
if session and not keep then
- session:close()
+ module.check_close(session)
end
local child_stream = ChildProcessStream.spawn(