aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/README.md3
-rw-r--r--test/unit/helpers.lua9
2 files changed, 11 insertions, 1 deletions
diff --git a/test/README.md b/test/README.md
index 01db5960cd..15041b74e8 100644
--- a/test/README.md
+++ b/test/README.md
@@ -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.
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index 4b9f185156..a629fca9a2 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -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