Skip to content

Commit 462f278

Browse files
committed
Properly handle an error from StepRunner.Run
Signed-off-by: Ilya <[email protected]>
1 parent c523ce2 commit 462f278

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

pkg/runner/test_runner.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,9 @@ loop:
452452
}
453453
tr.mu.Unlock()
454454
// Make sure we have a step runner active. If not, start one.
455-
tr.runStepIfNeeded(ss)
455+
err := tr.runStepIfNeeded(ss)
456456
// Inject the target.
457-
var err error
458-
if inject {
457+
if err == nil && inject {
459458
err = tr.injectTarget(ctx, tgs, ss)
460459
}
461460
// Await result. It will be communicated to us by the step runner
@@ -496,7 +495,7 @@ loop:
496495
}
497496

498497
// runStepIfNeeded starts the step runner goroutine if not already running.
499-
func (tr *TestRunner) runStepIfNeeded(ss *stepState) {
498+
func (tr *TestRunner) runStepIfNeeded(ss *stepState) error {
500499
tr.mu.Lock()
501500
resumeState := ss.resumeState
502501
ss.resumeState = nil
@@ -519,9 +518,10 @@ func (tr *TestRunner) runStepIfNeeded(ss *stepState) {
519518
tr.monitorCond.Signal()
520519
},
521520
)
522-
if err != nil && !errors.Is(err, &cerrors.ErrAlreadyDone{}) {
523-
ss.setErrLocked(err)
521+
if errors.Is(err, &cerrors.ErrAlreadyDone{}) {
522+
return nil
524523
}
524+
return err
525525
}
526526

527527
// setErrLocked sets step runner error unless already set.

0 commit comments

Comments
 (0)