mirror of
https://github.com/neovim/neovim.git
synced 2025-12-20 13:25:34 +00:00
unittests: Add a way to show some custom messages only when crashed
This commit is contained in:
@@ -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 hook_msglen = 1 + 1 + 1 + (1 + hook_fnamelen) + (1 + hook_sfnamelen) + (1 + hook_numlen) + 1
|
||||||
|
|
||||||
local tracehelp = dedent([[
|
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,
|
┌ 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.
|
│ _s_aved from previous run for reference, _>_ for custom debug
|
||||||
|
│ output.
|
||||||
│┏ Function type: _L_ua function, _C_ function, _m_ain part of chunk,
|
│┏ Function type: _L_ua function, _C_ function, _m_ain part of chunk,
|
||||||
│┃ function that did _t_ail call.
|
│┃ function that did _t_ail call.
|
||||||
│┃┌ Function name type: _g_lobal, _l_ocal, _m_ethod, _f_ield, _u_pvalue,
|
│┃┌ 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 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)
|
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()
|
init()
|
||||||
collectgarbage('stop')
|
collectgarbage('stop')
|
||||||
child_sethook(wr)
|
child_sethook(wr)
|
||||||
@@ -845,6 +859,7 @@ local module = {
|
|||||||
make_enum_conv_tab = make_enum_conv_tab,
|
make_enum_conv_tab = make_enum_conv_tab,
|
||||||
ptr2addr = ptr2addr,
|
ptr2addr = ptr2addr,
|
||||||
ptr2key = ptr2key,
|
ptr2key = ptr2key,
|
||||||
|
debug_log = debug_log,
|
||||||
}
|
}
|
||||||
return function()
|
return function()
|
||||||
return module
|
return module
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ local child_call_once = helpers.child_call_once
|
|||||||
local alloc_log_new = helpers.alloc_log_new
|
local alloc_log_new = helpers.alloc_log_new
|
||||||
local kvi_destroy = helpers.kvi_destroy
|
local kvi_destroy = helpers.kvi_destroy
|
||||||
local conv_enum = helpers.conv_enum
|
local conv_enum = helpers.conv_enum
|
||||||
|
local debug_log = helpers.debug_log
|
||||||
local ptr2key = helpers.ptr2key
|
local ptr2key = helpers.ptr2key
|
||||||
local cimport = helpers.cimport
|
local cimport = helpers.cimport
|
||||||
local ffi = helpers.ffi
|
local ffi = helpers.ffi
|
||||||
@@ -233,6 +234,7 @@ describe('Expressions parser', function()
|
|||||||
local function check_parsing(str, exp_ast, exp_highlighting_fs, nz_flags_exps)
|
local function check_parsing(str, exp_ast, exp_highlighting_fs, nz_flags_exps)
|
||||||
nz_flags_exps = nz_flags_exps or {}
|
nz_flags_exps = nz_flags_exps or {}
|
||||||
for _, flags in ipairs({0, 1, 2, 3}) do
|
for _, flags in ipairs({0, 1, 2, 3}) do
|
||||||
|
debug_log(('Running test case (%s, %u)'):format(str, flags))
|
||||||
local err, msg = pcall(function()
|
local err, msg = pcall(function()
|
||||||
if os.getenv('NVIM_TEST_PARSER_SPEC_PRINT_TEST_CASE') == '1' then
|
if os.getenv('NVIM_TEST_PARSER_SPEC_PRINT_TEST_CASE') == '1' then
|
||||||
print(str, flags)
|
print(str, flags)
|
||||||
|
|||||||
Reference in New Issue
Block a user