mirror of
https://github.com/httprunner/httprunner.git
synced 2026-08-05 21:44:21 +08:00
fix: enhance logging for interrupted processes and ensure step results are saved in failfast mode
This commit is contained in:
17
runner.go
17
runner.go
@@ -909,17 +909,24 @@ func (r *SessionRunner) RunStep(step IStep) (stepResult *StepResult, err error)
|
||||
|
||||
// execute step with merged variables
|
||||
stepResult, stepErr := r.executeStepWithVariables(step, task.stepName, task.parameters)
|
||||
|
||||
// Always add stepResult to stepResults if it exists, even on error
|
||||
// This ensures data is saved in defer function for summary generation
|
||||
if stepResult != nil {
|
||||
stepResults = append(stepResults, stepResult)
|
||||
}
|
||||
|
||||
if stepErr != nil {
|
||||
if r.caseRunner.hrpRunner.failfast {
|
||||
// failfast mode, abort running
|
||||
// failfast mode, abort running but step result is already saved above
|
||||
log.Error().Err(stepErr).
|
||||
Str("step", task.stepName).
|
||||
Int("completed_tasks", len(stepResults)).
|
||||
Msg("execute step failed in failfast mode, step result saved")
|
||||
return nil, errors.Wrap(stepErr, "execute step failed")
|
||||
}
|
||||
log.Error().Err(stepErr).Str("step", task.stepName).Msg("execute step failed")
|
||||
}
|
||||
|
||||
if stepResult != nil {
|
||||
stepResults = append(stepResults, stepResult)
|
||||
}
|
||||
}
|
||||
|
||||
// return last result
|
||||
|
||||
Reference in New Issue
Block a user