diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-03-11 21:47:12 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-03-16 10:55:12 +0100 |
commit | dbad797edd4636f830abd7ade1138a1a27ac30d2 (patch) | |
tree | 9fbad52284a75fdba28fc4da40da9b1560f4099c /test/functional/api/proc_spec.lua | |
parent | de86f824835b1556cc0070dd5720cdae484a0296 (diff) | |
download | rneovim-dbad797edd4636f830abd7ade1138a1a27ac30d2.tar.gz rneovim-dbad797edd4636f830abd7ade1138a1a27ac30d2.tar.bz2 rneovim-dbad797edd4636f830abd7ade1138a1a27ac30d2.zip |
API: nvim_get_proc_children()
ref https://github.com/libuv/libuv/pull/836
Diffstat (limited to 'test/functional/api/proc_spec.lua')
-rw-r--r-- | test/functional/api/proc_spec.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/test/functional/api/proc_spec.lua b/test/functional/api/proc_spec.lua new file mode 100644 index 0000000000..eee54f9465 --- /dev/null +++ b/test/functional/api/proc_spec.lua @@ -0,0 +1,53 @@ +local helpers = require('test.functional.helpers')(after_each) + +local clear, eq = helpers.clear, helpers.eq +local funcs = helpers.funcs +local nvim_argv = helpers.nvim_argv +local request = helpers.request +local retry = helpers.retry + +describe('api', function() + before_each(clear) + + describe('nvim_get_proc_children', function() + it('returns child process ids', function() + local this_pid = funcs.getpid() + + local job1 = funcs.jobstart(nvim_argv) + retry(nil, nil, function() + eq(1, #request('nvim_get_proc_children', this_pid)) + end) + + local job2 = funcs.jobstart(nvim_argv) + retry(nil, nil, function() + eq(2, #request('nvim_get_proc_children', this_pid)) + end) + + funcs.jobstop(job1) + retry(nil, nil, function() + eq(1, #request('nvim_get_proc_children', this_pid)) + end) + + funcs.jobstop(job2) + retry(nil, nil, function() + eq(0, #request('nvim_get_proc_children', this_pid)) + end) + end) + + it('validates input', function() + local status, rv = pcall(request, "nvim_get_proc_children", -1) + eq(false, status) + eq("Invalid pid: -1", string.match(rv, "Invalid.*")) + + status, rv = pcall(request, "nvim_get_proc_children", 0) + eq(false, status) + eq("Invalid pid: 0", string.match(rv, "Invalid.*")) + + -- Assume PID 99999999 does not exist. + status, rv = pcall(request, "nvim_get_proc_children", 99999999) + eq(true, status) + eq({}, rv) + end) + end) + +end) |