Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions errors/failure.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ var (
)

// TimeoutExceeded returns an ErrTimeoutExceeded when a test's execution
// exceeds a timeout length.
func TimeoutExceeded(duration string) error {
// exceeds a timeout length. The optional failure parameter indicates a failed
// assertion that occurred before a timeout was reached.
func TimeoutExceeded(duration string, failure error) error {
if failure != nil {
return fmt.Errorf(
"%w: timed out waiting for assertion to succeed (%s)",
failure, duration,
)
}
return fmt.Errorf("%s (%s)", ErrTimeoutExceeded, duration)
}

Expand Down
9 changes: 7 additions & 2 deletions plugin/exec/eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result {
eerr, _ := err.(*exec.ExitError)
ec = eerr.ExitCode()
}
assertions := newAssertions(s.Assert, ec, outbuf, errbuf)
return result.New(result.WithFailures(assertions.Failures()...))
a := newAssertions(s.Assert, ec, outbuf, errbuf)
if !a.OK() {
for _, fail := range a.Failures() {
t.Error(fail)
}
}
return result.New(result.WithFailures(a.Failures()...))
}
10 changes: 1 addition & 9 deletions scenario/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
res := spec.Eval(specCtx, t)
if res.HasRuntimeError() {
rterr = res.RuntimeError()
t.Fatal(rterr)
break
}
// Results can have arbitrary run data stored in them and we
Expand All @@ -91,15 +92,6 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
if res.HasData() {
ctx = gdtcontext.StorePriorRun(ctx, res.Data())
}
for _, failure := range res.Failures() {
if gdtcontext.TimedOut(specCtx, failure) {
if to != nil && !to.Expected {
t.Fatal(gdterrors.TimeoutExceeded(to.After))
}
} else {
t.Fatal(failure)
}
}
if wait != nil && wait.After != "" {
debug.Println(ctx, t, "wait: %s after", wait.After)
time.Sleep(wait.AfterDuration())
Expand Down