aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <janedmundlazo@hotmail.com>2018-03-12 12:26:43 -0400
committerJan Edmund Lazo <janedmundlazo@hotmail.com>2018-03-26 01:45:42 -0400
commit51f5cfc16e5fb769877e2a3e83f750e24235ada3 (patch)
tree72b5e02e23f61d13cdf502f821f9f0c28ac4da4b
parentad6d57731476d74efc15934967f7916914ff826d (diff)
downloadrneovim-51f5cfc16e5fb769877e2a3e83f750e24235ada3.tar.gz
rneovim-51f5cfc16e5fb769877e2a3e83f750e24235ada3.tar.bz2
rneovim-51f5cfc16e5fb769877e2a3e83f750e24235ada3.zip
test: win: enable jobpid() tests
Use ping to test job detach Use find.exe as an alternative to cat.exe Use nvim_get_proc to check pid
-rw-r--r--test/functional/core/job_spec.lua43
1 files changed, 29 insertions, 14 deletions
diff --git a/test/functional/core/job_spec.lua b/test/functional/core/job_spec.lua
index a46e107c77..45b739057f 100644
--- a/test/functional/core/job_spec.lua
+++ b/test/functional/core/job_spec.lua
@@ -19,6 +19,13 @@ local expect_twostreams = helpers.expect_twostreams
local expect_msg_seq = helpers.expect_msg_seq
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()
local channel
@@ -265,36 +272,44 @@ describe('jobs', function()
end)
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(['cat', '-'], g:job_opts)")
+ nvim('command', "let j = jobstart(has('win32') ? ['find', '/v', ''] : ['cat', '-'], g:job_opts)")
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)')
eq({'notification', 'stdout', {0, {''}}}, next_msg())
- eq({'notification', 'exit', {0, 0}}, next_msg())
- neq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ if iswin() then
+ 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)
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
- 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)')
- eq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ neq(NIL, meths.get_proc(pid))
clear()
- neq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ eq(NIL, meths.get_proc(pid))
end)
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: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)')
- eq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ neq(NIL, meths.get_proc(pid))
clear()
- eq(0,os.execute('ps -p '..pid..' > /dev/null'))
+ neq(NIL, meths.get_proc(pid))
-- clean up after ourselves
- os.execute('kill -9 '..pid..' > /dev/null')
+ eq(0, os_kill(pid))
end)
it('can pass user data to the callback', function()