aboutsummaryrefslogtreecommitdiff
path: root/test/unit/helpers.lua
diff options
context:
space:
mode:
authorNikolai Aleksandrovich Pavlov <kp-pav@yandex.ru>2017-04-02 14:25:47 +0300
committerJustin M. Keyes <justinkz@gmail.com>2017-04-02 13:25:47 +0200
commitddfa0359c638a4fd5eba5c339dc3e18e2b8aca35 (patch)
tree1704ae83cdfe588e9d192dac485930c85d6344f9 /test/unit/helpers.lua
parent58422f17d8e7e5f2dcba099b8829e5d23554e980 (diff)
downloadrneovim-ddfa0359c638a4fd5eba5c339dc3e18e2b8aca35.tar.gz
rneovim-ddfa0359c638a4fd5eba5c339dc3e18e2b8aca35.tar.bz2
rneovim-ddfa0359c638a4fd5eba5c339dc3e18e2b8aca35.zip
unittests: Make it easier to determine on which _spec line it crashed (#6424)
Benchmarks: Before change: 17.78s user 3.48s system 94% cpu 22.525 total After change: 25.38s user 4.46s system 101% cpu 29.317 total
Diffstat (limited to 'test/unit/helpers.lua')
-rw-r--r--test/unit/helpers.lua23
1 files changed, 18 insertions, 5 deletions
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index 93e1e91173..74f214a231 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -528,7 +528,8 @@ local hook_msglen = 1 + 1 + 1 + (1 + hook_fnamelen) + (1 + hook_sfnamelen) + (1
local tracehelp = dedent([[
┌ Trace type: _r_eturn from function , function _c_all, _l_ine executed,
- │ _t_ail return, _C_ount (should not actually appear).
+ │ _t_ail return, _C_ount (should not actually appear),
+ │ _s_aved from previous run for reference.
│┏ 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,
@@ -549,15 +550,27 @@ local function child_sethook(wr)
return
end
local trace_only_c = trace_level <= 1
- local function hook(reason, lnum)
+ local prev_info, prev_reason, prev_lnum
+ local function hook(reason, lnum, use_prev)
local info = nil
- if reason ~= 'tail return' then -- tail return
+ if use_prev then
+ info = prev_info
+ elseif reason ~= 'tail return' then -- tail return
info = debug.getinfo(2, 'nSl')
end
- if trace_only_c and (not info or info.what ~= 'C') then
+ if trace_only_c and (not info or info.what ~= 'C') and not use_prev then
+ if info.source:sub(-9) == '_spec.lua' then
+ prev_info = info
+ prev_reason = 'saved'
+ prev_lnum = lnum
+ end
return
end
+ if trace_only_c and not use_prev and prev_reason then
+ hook(prev_reason, prev_lnum, true)
+ prev_reason = nil
+ end
local whatchar = ' '
local namewhatchar = ' '
@@ -609,7 +622,7 @@ local function child_sethook(wr)
-- eq(hook_msglen, #msg)
sc.write(wr, msg)
end
- debug.sethook(hook, trace_only_c and 'cr' or 'crl')
+ debug.sethook(hook, 'crl')
end
local trace_end_msg = ('E%s\n'):format((' '):rep(hook_msglen - 2))