mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
test: include stderr in EOF failure message
This commit is contained in:
@@ -12,10 +12,8 @@ local RpcStream = require('test.client.rpc_stream')
|
|||||||
--- @field private _rpc_stream test.RpcStream
|
--- @field private _rpc_stream test.RpcStream
|
||||||
--- @field private _prepare uv.uv_prepare_t
|
--- @field private _prepare uv.uv_prepare_t
|
||||||
--- @field private _timer uv.uv_timer_t
|
--- @field private _timer uv.uv_timer_t
|
||||||
--- @field exec_lua_setup boolean
|
|
||||||
--- @field private _is_running boolean true during `Session:run()` scope.
|
--- @field private _is_running boolean true during `Session:run()` scope.
|
||||||
--- @field private _stdout_buffer string[] Stores stdout chunks
|
--- @field exec_lua_setup boolean
|
||||||
--- @field public stdout string Full stdout after the process exits
|
|
||||||
local Session = {}
|
local Session = {}
|
||||||
Session.__index = Session
|
Session.__index = Session
|
||||||
if package.loaded['jit'] then
|
if package.loaded['jit'] then
|
||||||
@@ -231,7 +229,13 @@ function Session:_run(request_cb, notification_cb, timeout)
|
|||||||
end
|
end
|
||||||
self._rpc_stream:read_start(request_cb, notification_cb, function()
|
self._rpc_stream:read_start(request_cb, notification_cb, function()
|
||||||
uv.stop()
|
uv.stop()
|
||||||
self.eof_err = { 1, 'EOF was received from Nvim. Likely the Nvim process crashed.' }
|
|
||||||
|
--- @diagnostic disable-next-line: invisible
|
||||||
|
local stderr = self._rpc_stream._stream.stderr --[[@as string?]]
|
||||||
|
-- See if `ProcStream.stderr` has anything useful.
|
||||||
|
stderr = '' ~= ((stderr or ''):match('^%s*(.*%S)') or '') and ' stderr:\n' .. stderr or ''
|
||||||
|
|
||||||
|
self.eof_err = { 1, 'EOF was received from Nvim. Likely the Nvim process crashed.' .. stderr }
|
||||||
end)
|
end)
|
||||||
uv.run()
|
uv.run()
|
||||||
self._prepare:stop()
|
self._prepare:stop()
|
||||||
|
@@ -127,9 +127,11 @@ end
|
|||||||
--- @field private _child_stdout uv.uv_pipe_t
|
--- @field private _child_stdout uv.uv_pipe_t
|
||||||
--- @field private _child_stderr uv.uv_pipe_t
|
--- @field private _child_stderr uv.uv_pipe_t
|
||||||
--- @field stdout string
|
--- @field stdout string
|
||||||
|
--- stderr is always collected in this field, regardless of `collect_output`.
|
||||||
--- @field stderr string
|
--- @field stderr string
|
||||||
--- @field stdout_eof boolean
|
--- @field stdout_eof boolean
|
||||||
--- @field stderr_eof boolean
|
--- @field stderr_eof boolean
|
||||||
|
--- Collects stdout in the `stdout` field, and stdout+stderr in `output` field.
|
||||||
--- @field private collect_output boolean
|
--- @field private collect_output boolean
|
||||||
--- Exit code
|
--- Exit code
|
||||||
--- @field status integer
|
--- @field status integer
|
||||||
@@ -149,8 +151,6 @@ function ProcStream.spawn(argv, env, io_extra)
|
|||||||
output = '',
|
output = '',
|
||||||
stdout = '',
|
stdout = '',
|
||||||
stderr = '',
|
stderr = '',
|
||||||
stdout_error = nil, -- TODO: not used, remove
|
|
||||||
stderr_error = nil, -- TODO: not used, remove
|
|
||||||
stdout_eof = false,
|
stdout_eof = false,
|
||||||
stderr_eof = false,
|
stderr_eof = false,
|
||||||
_child_stdin = assert(uv.new_pipe(false)),
|
_child_stdin = assert(uv.new_pipe(false)),
|
||||||
@@ -189,14 +189,16 @@ end
|
|||||||
|
|
||||||
function ProcStream:on_read(stream, cb, err, chunk)
|
function ProcStream:on_read(stream, cb, err, chunk)
|
||||||
if err then
|
if err then
|
||||||
-- stderr_error/stdout_error
|
error(err) -- stream read failed?
|
||||||
self[stream .. '_error'] = err ---@type string
|
|
||||||
-- error(err)
|
|
||||||
elseif chunk then
|
elseif chunk then
|
||||||
-- 'stderr' or 'stdout'
|
-- Always collect stderr, in case it gives useful info on failure.
|
||||||
|
if stream == 'stderr' then
|
||||||
|
self.stderr = self.stderr .. chunk ---@type string
|
||||||
|
end
|
||||||
|
-- Collect stdout if `collect_output` is enabled.
|
||||||
if self.collect_output then
|
if self.collect_output then
|
||||||
self[stream] = self[stream] .. chunk ---@type string
|
self.stdout = self.stdout .. chunk ---@type string
|
||||||
--- Collects both stdout + stderr.
|
--- Collect both stdout + stderr in the `output` field.
|
||||||
self.output = self[stream] .. chunk ---@type string
|
self.output = self[stream] .. chunk ---@type string
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@@ -333,9 +333,9 @@ end
|
|||||||
function M.expect_exit(fn_or_timeout, ...)
|
function M.expect_exit(fn_or_timeout, ...)
|
||||||
local eof_err_msg = 'EOF was received from Nvim. Likely the Nvim process crashed.'
|
local eof_err_msg = 'EOF was received from Nvim. Likely the Nvim process crashed.'
|
||||||
if type(fn_or_timeout) == 'function' then
|
if type(fn_or_timeout) == 'function' then
|
||||||
eq(eof_err_msg, t.pcall_err(fn_or_timeout, ...))
|
t.matches(eof_err_msg, t.pcall_err(fn_or_timeout, ...))
|
||||||
else
|
else
|
||||||
eq(
|
t.matches(
|
||||||
eof_err_msg,
|
eof_err_msg,
|
||||||
t.pcall_err(function(timeout, fn, ...)
|
t.pcall_err(function(timeout, fn, ...)
|
||||||
fn(...)
|
fn(...)
|
||||||
|
Reference in New Issue
Block a user