mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-06 20:32:44 +08:00
fix: enhance logging for interrupted processes and ensure step results are saved in failfast mode
This commit is contained in:
@@ -1 +1 @@
|
||||
v5.0.0-beta-2506242310
|
||||
v5.0.0-beta-2506251157
|
||||
|
||||
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
|
||||
|
||||
@@ -30,7 +30,10 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
|
||||
// Check for context cancellation (interrupt signal)
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Warn().Msg("interrupted in StartToGoal")
|
||||
log.Warn().
|
||||
Int("attempt", attempt).
|
||||
Int("completed_plannings", len(allPlannings)).
|
||||
Msg("interrupted in StartToGoal")
|
||||
return allPlannings, errors.Wrap(code.InterruptError, "StartToGoal interrupted")
|
||||
default:
|
||||
}
|
||||
@@ -83,7 +86,12 @@ func (dExt *XTDriver) StartToGoal(ctx context.Context, prompt string, opts ...op
|
||||
// Check for context cancellation before each action
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
log.Warn().Msg("interrupted in invokeToolCalls")
|
||||
log.Warn().
|
||||
Int("attempt", attempt).
|
||||
Int("completed_plannings", len(allPlannings)).
|
||||
Int("completed_tool_calls", len(planningResult.SubActions)).
|
||||
Int("total_tool_calls", len(planningResult.ToolCalls)).
|
||||
Msg("interrupted in invokeToolCalls")
|
||||
planningResult.Elapsed = time.Since(planningStartTime).Milliseconds()
|
||||
allPlannings = append(allPlannings, planningResult)
|
||||
return allPlannings, errors.Wrap(code.InterruptError, "invokeToolCalls interrupted")
|
||||
|
||||
Reference in New Issue
Block a user