From caf9a26660a721262e6fe34a1c746719d8806d4f Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sat, 14 Sep 2019 14:35:20 +0200 Subject: [PATCH] tests: runner.run_steps: add fname/lnum for failed steps (#2877) --- tests/_runner.lua | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/tests/_runner.lua b/tests/_runner.lua index 0fca6a4fe..688ebe1cc 100644 --- a/tests/_runner.lua +++ b/tests/_runner.lua @@ -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)