Skip to content
This repository was archived by the owner on Jun 30, 2023. It is now read-only.

Commit a77d906

Browse files
committed
feat(ChildProcessStream): capture exit code on exit
1 parent 12d070b commit a77d906

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

nvim/child_process_stream.lua

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function ChildProcessStream.spawn(argv, env, io_extra)
1919
stdio = {self._child_stdin, self._child_stdout, 2, io_extra},
2020
args = args,
2121
env = env,
22-
}, function()
22+
}, function(ecode)
23+
self._exit_code = ecode
2324
self:close()
2425
end)
2526

test/session_spec.lua

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ local SocketStream = require('nvim.socket_stream')
44
local Session = require('nvim.session')
55
local coxpcall = require('coxpcall')
66
local busted = require('busted')
7+
local uv = require('luv')
78
require('nvim._compat')
89

910
local nvim_prog = os.getenv('NVIM_PROG') or 'nvim'
@@ -168,6 +169,23 @@ test_session("Session using ChidProcessStream", function ()
168169
return Session.new(proc_stream)
169170
end)
170171

172+
describe("ChildProcessStream", function()
173+
it("can capture exit code", function()
174+
local proc_stream = ChildProcessStream.spawn({
175+
nvim_prog, '-u', 'NONE', '--embed',
176+
})
177+
178+
local session = Session.new(proc_stream)
179+
local ok = session:request "nvim_get_api_info"
180+
session:request("nvim_command", "qall!")
181+
182+
assert.is_true(ok)
183+
uv.run()
184+
185+
assert.is.same(proc_stream._exit_code, 0)
186+
end)
187+
end)
188+
171189
-- Session using SocketStream
172190
test_session(string.format("Session using SocketStream [%s]", socket_file), function ()
173191
child_session = Session.new(ChildProcessStream.spawn({

0 commit comments

Comments
 (0)