aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-09-26 23:13:55 +0300
committerZyX <kp-pav@yandex.ru>2017-09-29 01:21:13 +0300
commit190c8516f534499f89d610fc78a20c025386b2f2 (patch)
treecdf1c3e7d49ec476773c9001ca787102d1f1983d /test
parent520c0b91a528e7943bc6163a65de7adde387869b (diff)
downloadrneovim-190c8516f534499f89d610fc78a20c025386b2f2.tar.gz
rneovim-190c8516f534499f89d610fc78a20c025386b2f2.tar.bz2
rneovim-190c8516f534499f89d610fc78a20c025386b2f2.zip
unittests: Add a way to print trace on regular error
Diffstat (limited to 'test')
-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