Skip to content

Commit

Permalink
Properly handle an error from StepRunner.Run
Browse files Browse the repository at this point in the history
  • Loading branch information
rihter007 committed Dec 5, 2021
1 parent a9a2e90 commit 0aa919e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/runner/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,10 +452,9 @@ loop:
}
tr.mu.Unlock()
// Make sure we have a step runner active. If not, start one.
tr.runStepIfNeeded(ss)
err := tr.runStepIfNeeded(ss)
// Inject the target.
var err error
if inject {
if err == nil && inject {
err = tr.injectTarget(ctx, tgs, ss)
}
// Await result. It will be communicated to us by the step runner
Expand Down Expand Up @@ -496,7 +495,7 @@ loop:
}

// runStepIfNeeded starts the step runner goroutine if not already running.
func (tr *TestRunner) runStepIfNeeded(ss *stepState) {
func (tr *TestRunner) runStepIfNeeded(ss *stepState) error {
tr.mu.Lock()
resumeState := ss.resumeState
ss.resumeState = nil
Expand All @@ -519,9 +518,10 @@ func (tr *TestRunner) runStepIfNeeded(ss *stepState) {
tr.monitorCond.Signal()
},
)
if err != nil && !errors.Is(err, &cerrors.ErrAlreadyDone{}) {
ss.setErrLocked(err)
if errors.Is(err, &cerrors.ErrAlreadyDone{}) {
return nil
}
return err
}

// setErrLocked sets step runner error unless already set.
Expand Down

0 comments on commit 0aa919e

Please sign in to comment.