unittests: Add a way to print trace on regular error

This commit is contained in:
ZyX 2017-09-26 23:13:55 +03:00
parent 520c0b91a5
commit 190c8516f5
2 changed files with 11 additions and 1 deletions

View File

@ -110,3 +110,6 @@ disables tracing (the fastest, but you get no data if tests crash and there was
no core dump generated), `1` or empty/undefined leaves only C function cals and
returns in the trace (faster then recording everything), `2` records all
function calls, returns and lua source lines exuecuted.
`NVIM_TEST_TRACE_ON_ERROR` (U) (1): makes unit tests yield trace on error in
addition to regular error message.

View File

@ -698,7 +698,14 @@ local function check_child_err(rd)
local len_s = sc.read(rd, 5)
local len = tonumber(len_s)
neq(0, len)
local err = sc.read(rd, len + 1)
local err = ''
if os.getenv('NVIM_TEST_TRACE_ON_ERROR') == '1' and #trace ~= 0 then
err = '\nTest failed, trace:\n' .. tracehelp
for _, traceline in ipairs(trace) do
err = err .. traceline
end
end
err = err .. sc.read(rd, len + 1)
assert.just_fail(err)
end