mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
job control: add tests for 'jobpid' and 'detach'
This commit is contained in:
parent
f338ea7835
commit
4618307a6c
@ -142,6 +142,35 @@ describe('jobs', function()
|
||||
nvim('command', "call jobstart(['cat', '-'], g:job_opts)")
|
||||
end)
|
||||
|
||||
it('can get the pid value using getpid', function()
|
||||
nvim('command', "let j = jobstart(['cat', '-'], g:job_opts)")
|
||||
local pid = eval('jobpid(j)')
|
||||
eq(0,os.execute('ps -p '..pid..' > /dev/null'))
|
||||
nvim('command', 'call jobstop(j)')
|
||||
eq({'notification', 'exit', {0, 0}}, next_msg())
|
||||
neq(0,os.execute('ps -p '..pid..' > /dev/null'))
|
||||
end)
|
||||
|
||||
it("doesn't survive the exit of nvim", function()
|
||||
-- use sleep, which doesn't die on stdin close
|
||||
nvim('command', "let j = jobstart(['sleep', '1000'], g:job_opts)")
|
||||
local pid = eval('jobpid(j)')
|
||||
eq(0,os.execute('ps -p '..pid..' > /dev/null'))
|
||||
clear()
|
||||
neq(0,os.execute('ps -p '..pid..' > /dev/null'))
|
||||
end)
|
||||
|
||||
it('can survive the exit of nvim with "detach"', function()
|
||||
nvim('command', 'let g:job_opts.detach = 1')
|
||||
nvim('command', "let j = jobstart(['sleep', '1000'], g:job_opts)")
|
||||
local pid = eval('jobpid(j)')
|
||||
eq(0,os.execute('ps -p '..pid..' > /dev/null'))
|
||||
clear()
|
||||
eq(0,os.execute('ps -p '..pid..' > /dev/null'))
|
||||
-- clean up after ourselves
|
||||
os.execute('kill -9 '..pid..' > /dev/null')
|
||||
end)
|
||||
|
||||
it('can pass user data to the callback', function()
|
||||
nvim('command', 'let g:job_opts.user = {"n": 5, "s": "str", "l": [1]}')
|
||||
nvim('command', "call jobstart(['echo'], g:job_opts)")
|
||||
|
Loading…
Reference in New Issue
Block a user