aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-01-08 17:25:13 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2016-01-20 11:09:29 +0100
commit4618307a6ccd2b45349d8ade88c47e101844e9ee (patch)
treeb688f9e37f99fd8504c30d08fa2022a314592af3
parentf338ea783591cdf4fcbaf948cd675374ba1fb3b9 (diff)
downloadrneovim-4618307a6ccd2b45349d8ade88c47e101844e9ee.tar.gz
rneovim-4618307a6ccd2b45349d8ade88c47e101844e9ee.tar.bz2
rneovim-4618307a6ccd2b45349d8ade88c47e101844e9ee.zip
job control: add tests for 'jobpid' and 'detach'
-rw-r--r--test/functional/job/job_spec.lua29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua
index 0915ab0955..d21b9051e2 100644
--- a/test/functional/job/job_spec.lua
+++ b/test/functional/job/job_spec.lua
@@ -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)")