aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2016-01-20 11:55:40 +0100
committerBjörn Linse <bjorn.linse@gmail.com>2016-01-20 11:55:40 +0100
commit297075bf47d09437deb82266c61cd830dc8d72eb (patch)
treeb6a2e2f41abb83f0f732ad259cddf7dab66ef741 /test/functional
parentee0e214427d7ed2a9fd8ffc85c424cfffc927408 (diff)
parentf6ecd127b9c999b63d33e2da542f32528530698a (diff)
downloadrneovim-297075bf47d09437deb82266c61cd830dc8d72eb.tar.gz
rneovim-297075bf47d09437deb82266c61cd830dc8d72eb.tar.bz2
rneovim-297075bf47d09437deb82266c61cd830dc8d72eb.zip
Merge pull request #3944 from bfredl/detach
job control: add `detach` option and `jobpid` function and teardown PTY processes correctly.
Diffstat (limited to 'test/functional')
-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)")