File tree Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Expand file tree Collapse file tree 3 files changed +17
-13
lines changed Original file line number Diff line number Diff line change 3131)
3232
3333// TimeoutExceeded returns an ErrTimeoutExceeded when a test's execution
34- // exceeds a timeout length.
35- func TimeoutExceeded (duration string ) error {
34+ // exceeds a timeout length. The optional failure parameter indicates a failed
35+ // assertion that occurred before a timeout was reached.
36+ func TimeoutExceeded (duration string , failure error ) error {
37+ if failure != nil {
38+ return fmt .Errorf (
39+ "%w: timed out waiting for assertion to succeed (%s)" ,
40+ failure , duration ,
41+ )
42+ }
3643 return fmt .Errorf ("%s (%s)" , ErrTimeoutExceeded , duration )
3744}
3845
Original file line number Diff line number Diff line change @@ -71,6 +71,11 @@ func (s *Spec) Eval(ctx context.Context, t *testing.T) *result.Result {
7171 eerr , _ := err .(* exec.ExitError )
7272 ec = eerr .ExitCode ()
7373 }
74- assertions := newAssertions (s .Assert , ec , outbuf , errbuf )
75- return result .New (result .WithFailures (assertions .Failures ()... ))
74+ a := newAssertions (s .Assert , ec , outbuf , errbuf )
75+ if ! a .OK () {
76+ for _ , fail := range a .Failures () {
77+ t .Error (fail )
78+ }
79+ }
80+ return result .New (result .WithFailures (a .Failures ()... ))
7681}
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
8383 res := spec .Eval (specCtx , t )
8484 if res .HasRuntimeError () {
8585 rterr = res .RuntimeError ()
86+ t .Fatal (rterr )
8687 break
8788 }
8889 // Results can have arbitrary run data stored in them and we
@@ -91,15 +92,6 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
9192 if res .HasData () {
9293 ctx = gdtcontext .StorePriorRun (ctx , res .Data ())
9394 }
94- for _ , failure := range res .Failures () {
95- if gdtcontext .TimedOut (specCtx , failure ) {
96- if to != nil && ! to .Expected {
97- t .Fatal (gdterrors .TimeoutExceeded (to .After ))
98- }
99- } else {
100- t .Fatal (failure )
101- }
102- }
10395 if wait != nil && wait .After != "" {
10496 debug .Println (ctx , t , "wait: %s after" , wait .After )
10597 time .Sleep (wait .AfterDuration ())
You can’t perform that action at this time.
0 commit comments