tests: runner.run_steps: add fname/lnum for failed steps (#2877)

This commit is contained in:
Daniel Hahler 2019-09-14 14:35:20 +02:00 committed by GitHub
parent 13ea02eeeb
commit caf9a26660
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 12 deletions

View File

@ -109,14 +109,16 @@ function runner.run_steps(steps, options)
end
t:connect_signal("timeout", function() timer.delayed_call(function()
io.flush() -- for "tail -f".
local step_func = steps[step]
step_count = step_count + 1
local step_as_string = step..'/'..#steps..' (@'..step_count..')'
io.flush() -- for "tail -f".
runner.verbose(string.format('Running step %s..\n', step_as_string))
-- Call the current step's function.
local success, result = xpcall(function()
return steps[step](step_count)
return step_func(step_count)
end, debug.traceback)
if not success then
@ -136,18 +138,25 @@ function runner.run_steps(steps, options)
-- All steps finished, we are done.
runner.done()
end
elseif result == false then
runner.done("Step "..step_as_string.." failed (returned false).")
else
-- No result yet, run this step again.
wait = wait-1
if wait > 0 then
t.timeout = 0.1
t:again()
-- Append filename/lnum of failed step function.
local step_info = debug.getinfo(step_func)
local step_loc = string.format("%s:%d", step_info["short_src"], step_info["linedefined"])
step_as_string = step_as_string .. " ("..step_loc..")"
if result == false then
runner.done("Step "..step_as_string.." failed (returned false).")
else
runner.done("timeout waiting for signal in step "
..step_as_string..".")
t:stop()
-- No result yet, run this step again.
wait = wait-1
if wait > 0 then
t.timeout = 0.1
t:again()
else
runner.done("timeout waiting for signal in step "
..step_as_string..".")
t:stop()
end
end
end
end) end)