Print more complete tracebacks on test check failures

Any library functions written in Lua, like `dfhack.with_finalize()`, would
cause the traceback to end even if there were more stack frames in the test file.
develop
lethosor 2021-06-24 00:39:03 -04:00
parent 2fc5fbacb5
commit bc4e00b242
No known key found for this signature in database
GPG Key ID: 76A269552F4F58C1
1 changed files with 3 additions and 5 deletions

@ -245,7 +245,6 @@ local function wrap_expect(func, private)
orig_printerr('Check failed! ' .. (msg or '(no message)')) orig_printerr('Check failed! ' .. (msg or '(no message)'))
-- Generate a stack trace with all function calls in the same file as the caller to expect.*() -- Generate a stack trace with all function calls in the same file as the caller to expect.*()
-- (this produces better stack traces when using helpers in tests) -- (this produces better stack traces when using helpers in tests)
-- Skip any frames corresponding to C calls, which could be pcall() / with_finalize()
local frame = 2 local frame = 2
local caller_src local caller_src
while true do while true do
@ -254,10 +253,9 @@ local function wrap_expect(func, private)
if not caller_src then if not caller_src then
caller_src = info.short_src caller_src = info.short_src
end end
if info.what == 'Lua' then -- Skip any frames corresponding to C calls, or Lua functions defined in another file
if info.short_src ~= caller_src then -- these could include pcall(), with_finalize(), etc.
break if info.what == 'Lua' and info.short_src == caller_src then
end
orig_printerr((' at %s:%d'):format(info.short_src, info.currentline)) orig_printerr((' at %s:%d'):format(info.short_src, info.currentline))
end end
frame = frame + 1 frame = frame + 1