aboutsummaryrefslogtreecommitdiff
path: root/test/unit/helpers.lua
diff options
context:
space:
mode:
authorZyX <kp-pav@yandex.ru>2017-11-11 23:50:37 +0300
committerZyX <kp-pav@yandex.ru>2017-11-11 23:50:37 +0300
commitbbb21e5dd3891727c272ffd3aa4ce2a4841a1f0b (patch)
tree09269079ee1e0637e68c18fcb91d4f1a6b1eea65 /test/unit/helpers.lua
parent4aebd00a9eeeb2f56ff53dd4e383825e997ee7be (diff)
downloadrneovim-bbb21e5dd3891727c272ffd3aa4ce2a4841a1f0b.tar.gz
rneovim-bbb21e5dd3891727c272ffd3aa4ce2a4841a1f0b.tar.bz2
rneovim-bbb21e5dd3891727c272ffd3aa4ce2a4841a1f0b.zip
unittests: Add a way to show some custom messages only when crashed
Diffstat (limited to 'test/unit/helpers.lua')
-rw-r--r--test/unit/helpers.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index 96aa505739..2c148630dd 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -529,9 +529,13 @@ local hook_numlen = 5
local hook_msglen = 1 + 1 + 1 + (1 + hook_fnamelen) + (1 + hook_sfnamelen) + (1 + hook_numlen) + 1
local tracehelp = dedent([[
+ Trace: either in the format described below or custom debug output starting
+ with `>`. Latter lines still have the same width in byte.
+
┌ Trace type: _r_eturn from function , function _c_all, _l_ine executed,
│ _t_ail return, _C_ount (should not actually appear),
- │ _s_aved from previous run for reference.
+ │ _s_aved from previous run for reference, _>_ for custom debug
+ │ output.
│┏ Function type: _L_ua function, _C_ function, _m_ain part of chunk,
│┃ function that did _t_ail call.
│┃┌ Function name type: _g_lobal, _l_ocal, _m_ethod, _f_ield, _u_pvalue,
@@ -629,7 +633,17 @@ end
local trace_end_msg = ('E%s\n'):format((' '):rep(hook_msglen - 2))
+local _debug_log
+
+local debug_log = only_separate(function(...)
+ return _debug_log(...)
+end)
+
local function itp_child(wr, func)
+ _debug_log = function(s)
+ s = s:sub(1, hook_msglen - 2)
+ sc.write(wr, '>' .. s .. (' '):rep(hook_msglen - 2 - #s) .. '\n')
+ end
init()
collectgarbage('stop')
child_sethook(wr)
@@ -845,6 +859,7 @@ local module = {
make_enum_conv_tab = make_enum_conv_tab,
ptr2addr = ptr2addr,
ptr2key = ptr2key,
+ debug_log = debug_log,
}
return function()
return module