aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/functional/core/job_spec.lua29
-rw-r--r--test/functional/ex_cmds/swapfile_preserve_recover_spec.lua3
-rw-r--r--test/functional/testnvim.lua12
-rw-r--r--test/functional/vimscript/system_spec.lua5
4 files changed, 15 insertions, 34 deletions
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index 75e09f3455..7a50993171 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -21,7 +21,6 @@ local rmdir = n.rmdir
local assert_alive = n.assert_alive
local command = n.command
local fn = n.fn
-local os_kill = n.os_kill
local retry = t.retry
local api = n.api
local NIL = vim.NIL
@@ -444,27 +443,23 @@ describe('jobs', function()
end)
it('disposed on Nvim exit', function()
- -- use sleep, which doesn't die on stdin close
- 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)')
- neq(NIL, api.nvim_get_proc(pid))
+ -- Start a child process which doesn't die on stdin close.
+ local j = n.fn.jobstart({ n.nvim_prog, '--clean', '--headless' })
+ local pid = n.fn.jobpid(j)
+ eq('number', type(api.nvim_get_proc(pid).pid))
clear()
eq(NIL, api.nvim_get_proc(pid))
end)
- it('can survive the exit of nvim with "detach"', function()
- command('let g:job_opts.detach = 1')
- 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)')
- neq(NIL, api.nvim_get_proc(pid))
+ it('can survive Nvim exit with "detach"', function()
+ local j = n.fn.jobstart({ n.nvim_prog, '--clean', '--headless' }, { detach = true })
+ local pid = n.fn.jobpid(j)
+ eq('number', type(api.nvim_get_proc(pid).pid))
clear()
- neq(NIL, api.nvim_get_proc(pid))
- -- clean up after ourselves
- eq(0, os_kill(pid))
+ -- Still alive.
+ eq('number', type(api.nvim_get_proc(pid).pid))
+ -- Clean up after ourselves.
+ eq(0, vim.uv.kill(pid, 'sigkill'))
end)
it('can pass user data to the callback', function()
diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
index f84fc140d2..2974564f70 100644
--- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
+++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
@@ -14,7 +14,6 @@ local ok = t.ok
local rmdir = n.rmdir
local new_pipename = n.new_pipename
local pesc = vim.pesc
-local os_kill = n.os_kill
local set_session = n.set_session
local async_meths = n.async_meths
local expect_msg_seq = n.expect_msg_seq
@@ -100,7 +99,7 @@ describe("preserve and (R)ecover with custom 'directory'", function()
it('with :preserve and SIGKILL', function()
local swappath1 = setup_swapname()
command('preserve')
- os_kill(eval('getpid()'))
+ eq(0, vim.uv.kill(eval('getpid()'), 'sigkill'))
test_recover(swappath1)
end)
diff --git a/test/functional/testnvim.lua b/test/functional/testnvim.lua
index 9b7ece3c21..99d69e9287 100644
--- a/test/functional/testnvim.lua
+++ b/test/functional/testnvim.lua
@@ -978,18 +978,6 @@ function M.add_builddir_to_rtp()
M.command(string.format([[set rtp+=%s/runtime]], t.paths.test_build_dir))
end
---- Kill (reap) a process by PID.
---- @param pid string
---- @return boolean?
-function M.os_kill(pid)
- return os.execute(
- (
- is_os('win') and 'taskkill /f /t /pid ' .. pid .. ' > nul'
- or 'kill -9 ' .. pid .. ' > /dev/null'
- )
- )
-end
-
--- Create folder with non existing parents
--- @param path string
--- @return boolean?
diff --git a/test/functional/vimscript/system_spec.lua b/test/functional/vimscript/system_spec.lua
index b5c4972d7b..2813128aae 100644
--- a/test/functional/vimscript/system_spec.lua
+++ b/test/functional/vimscript/system_spec.lua
@@ -12,7 +12,6 @@ local command = n.command
local insert = n.insert
local expect = n.expect
local exc_exec = n.exc_exec
-local os_kill = n.os_kill
local pcall_err = t.pcall_err
local is_os = t.is_os
@@ -394,7 +393,7 @@ describe('system()', function()
it("with a program that doesn't close stdout will exit properly after passing input", function()
local out = eval(string.format("system('%s', 'clip-data')", testprg('streams-test')))
assert(out:sub(0, 5) == 'pid: ', out)
- os_kill(out:match('%d+'))
+ eq(0, vim.uv.kill(assert(tonumber(out:match('%d+'))), 'sigkill'))
end)
end)
@@ -538,7 +537,7 @@ describe('systemlist()', function()
it("with a program that doesn't close stdout will exit properly after passing input", function()
local out = eval(string.format("systemlist('%s', 'clip-data')", testprg('streams-test')))
assert(out[1]:sub(0, 5) == 'pid: ', out)
- os_kill(out[1]:match('%d+'))
+ eq(0, vim.uv.kill(assert(tonumber(out[1]:match('%d+'))), 'sigkill'))
end)
it('powershell w/ UTF-8 text #13713', function()