@@ -93,7 +93,19 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
93
93
defer cancel ()
94
94
}
95
95
96
- res , rterr := s .runSpec (specCtx , rt , to , idx , spec )
96
+ var res * api.Result
97
+ ch := make (chan runSpecRes , 1 )
98
+
99
+ go s .runSpec (specCtx , ch , rt , to , idx , spec )
100
+
101
+ select {
102
+ case <- specCtx .Done ():
103
+ t .Fatalf ("assertion failed: timeout exceeded (%s)" , to .After )
104
+ break
105
+ case runres := <- ch :
106
+ res = runres .r
107
+ rterr = runres .err
108
+ }
97
109
if rterr != nil {
98
110
break
99
111
}
@@ -115,14 +127,20 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
115
127
return rterr
116
128
}
117
129
130
+ type runSpecRes struct {
131
+ r * api.Result
132
+ err error
133
+ }
134
+
118
135
// runSpec executes an individual test spec
119
136
func (s * Scenario ) runSpec (
120
137
ctx context.Context ,
138
+ ch chan runSpecRes ,
121
139
retry * api.Retry ,
122
140
timeout * api.Timeout ,
123
141
idx int ,
124
142
spec api.Evaluable ,
125
- ) ( * api. Result , error ) {
143
+ ) {
126
144
sb := spec .Base ()
127
145
specTraceMsg := strconv .Itoa (idx )
128
146
if sb .Name != "" {
@@ -136,13 +154,15 @@ func (s *Scenario) runSpec(
136
154
// Just evaluate the test spec once
137
155
res , err := spec .Eval (ctx )
138
156
if err != nil {
139
- return nil , err
157
+ ch <- runSpecRes {nil , err }
158
+ return
140
159
}
141
160
debug .Println (
142
161
ctx , "run: single-shot (no retries) ok: %v" ,
143
162
! res .Failed (),
144
163
)
145
- return res , nil
164
+ ch <- runSpecRes {res , nil }
165
+ return
146
166
}
147
167
148
168
// retry the action and test the assertions until they succeed,
@@ -187,7 +207,8 @@ func (s *Scenario) runSpec(
187
207
188
208
res , err = spec .Eval (ctx )
189
209
if err != nil {
190
- return nil , err
210
+ ch <- runSpecRes {nil , err }
211
+ return
191
212
}
192
213
success = ! res .Failed ()
193
214
debug .Println (
@@ -200,13 +221,13 @@ func (s *Scenario) runSpec(
200
221
}
201
222
for _ , f := range res .Failures () {
202
223
debug .Println (
203
- ctx , "run: attempt %d after %s failure: %s" ,
204
- attempts , after , f ,
224
+ ctx , "run: attempt %d failure: %s" ,
225
+ attempts , f ,
205
226
)
206
227
}
207
228
attempts ++
208
229
}
209
- return res , nil
230
+ ch <- runSpecRes { res , nil }
210
231
}
211
232
212
233
// getTimeout returns the timeout configuration for the test spec. We check for
0 commit comments