aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/proc_spec.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/functional/api/proc_spec.lua')
-rw-r--r--test/functional/api/proc_spec.lua34
1 files changed, 31 insertions, 3 deletions
diff --git a/test/functional/api/proc_spec.lua b/test/functional/api/proc_spec.lua
index eee54f9465..d99c26b6c2 100644
--- a/test/functional/api/proc_spec.lua
+++ b/test/functional/api/proc_spec.lua
@@ -1,10 +1,14 @@
local helpers = require('test.functional.helpers')(after_each)
-local clear, eq = helpers.clear, helpers.eq
+local clear = helpers.clear
+local eq = helpers.eq
local funcs = helpers.funcs
+local iswin = helpers.iswin
local nvim_argv = helpers.nvim_argv
+local ok = helpers.ok
local request = helpers.request
local retry = helpers.retry
+local NIL = helpers.NIL
describe('api', function()
before_each(clear)
@@ -43,11 +47,35 @@ describe('api', function()
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)
+ -- Assume PID 99999 does not exist.
+ status, rv = pcall(request, "nvim_get_proc_children", 99999)
eq(true, status)
eq({}, rv)
end)
end)
+ describe('nvim_get_proc', function()
+ it('returns process info', function()
+ local pid = funcs.getpid()
+ local pinfo = request('nvim_get_proc', pid)
+ eq((iswin() and 'nvim.exe' or 'nvim'), pinfo.name)
+ ok(pinfo.pid == pid)
+ ok(type(pinfo.ppid) == 'number' and pinfo.ppid ~= pid)
+ end)
+
+ it('validates input', function()
+ local status, rv = pcall(request, "nvim_get_proc", -1)
+ eq(false, status)
+ eq("Invalid pid: -1", string.match(rv, "Invalid.*"))
+
+ status, rv = pcall(request, "nvim_get_proc", 0)
+ eq(false, status)
+ eq("Invalid pid: 0", string.match(rv, "Invalid.*"))
+
+ -- Assume PID 99999 does not exist.
+ status, rv = pcall(request, "nvim_get_proc", 99999)
+ eq(true, status)
+ eq(NIL, rv)
+ end)
+ end)
end)