@@ -78,11 +78,8 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
7878 time .Sleep (wait .BeforeDuration ())
7979 }
8080 plugin := s .evalPlugins [idx ]
81- pinfo := plugin .Info ()
82- pretry := pinfo .Retry
83- ptimeout := pinfo .Timeout
8481
85- rt := getRetry (ctx , sb . Retry , scDefaults , pretry )
82+ rt := getRetry (ctx , scDefaults , plugin , spec )
8683
8784 // Create a brand new context that inherits the top-level context's
8885 // cancel func. We want to set deadlines for each test spec and if
@@ -91,7 +88,7 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
9188 specCtx , specCancel := context .WithCancel (ctx )
9289 defer specCancel ()
9390
94- to := getTimeout (ctx , sb . Timeout , ptimeout , scDefaults )
91+ to := getTimeout (ctx , scDefaults , plugin , spec )
9592 if to != nil {
9693 var cancel context.CancelFunc
9794 specCtx , cancel = context .WithTimeout (specCtx , to .Duration ())
@@ -113,7 +110,7 @@ func (s *Scenario) Run(ctx context.Context, t *testing.T) error {
113110 ctx = gdtcontext .StorePriorRun (ctx , res .Data ())
114111 }
115112 for _ , fail := range res .Failures () {
116- t .Error (fail )
113+ t .Fatal (fail )
117114 }
118115 }
119116 })
@@ -137,7 +134,7 @@ func (s *Scenario) runSpec(
137134 defer func () {
138135 ctx = gdtcontext .PopTrace (ctx )
139136 }()
140- if retry == nil {
137+ if retry == nil || retry == gdttypes . NoRetry {
141138 // Just evaluate the test spec once
142139 res , err := spec .Eval (ctx )
143140 if err != nil {
@@ -214,31 +211,49 @@ func (s *Scenario) runSpec(
214211 return res , nil
215212}
216213
217- // getTimeout returns the timeout value for the test spec. If the spec has a
218- // timeout override, we use that. Otherwise, we inspect the scenario's defaults
219- // and, if present, use that timeout. If the scenario's defaults for not
220- // indicate a timeout configuration, we ask the plugin if it has timeout
221- // defaults and use that.
214+ // getTimeout returns the timeout configuration for the test spec. We check for
215+ // overrides in timeout configuration using the following precedence:
216+ //
217+ // * Spec (Evaluable) override
218+ // * Spec's Base override
219+ // * Scenario's default
220+ // * Plugin's default
222221func getTimeout (
223222 ctx context.Context ,
224- specTimeout * gdttypes.Timeout ,
225- pluginTimeout * gdttypes.Timeout ,
226223 scenDefaults * Defaults ,
224+ plugin gdttypes.Plugin ,
225+ eval gdttypes.Evaluable ,
227226) * gdttypes.Timeout {
228- if specTimeout != nil {
227+ evalTimeout := eval .Timeout ()
228+ if evalTimeout != nil {
229+ debug .Println (
230+ ctx , "using timeout of %s" ,
231+ evalTimeout .After ,
232+ )
233+ return evalTimeout
234+ }
235+
236+ sb := eval .Base ()
237+ baseTimeout := sb .Timeout
238+ if baseTimeout != nil {
229239 debug .Println (
230240 ctx , "using timeout of %s" ,
231- specTimeout .After ,
241+ baseTimeout .After ,
232242 )
233- return specTimeout
243+ return baseTimeout
234244 }
245+
235246 if scenDefaults != nil && scenDefaults .Timeout != nil {
236247 debug .Println (
237248 ctx , "using timeout of %s [scenario default]" ,
238249 scenDefaults .Timeout .After ,
239250 )
240251 return scenDefaults .Timeout
241252 }
253+
254+ pluginInfo := plugin .Info ()
255+ pluginTimeout := pluginInfo .Timeout
256+
242257 if pluginTimeout != nil {
243258 debug .Println (
244259 ctx , "using timeout of %s [plugin default]" ,
@@ -249,31 +264,59 @@ func getTimeout(
249264 return nil
250265}
251266
252- // getRetry returns the retry configuration for the test spec. If the spec has a
253- // retry override, we use that. Otherwise, we inspect the scenario's defaults
254- // and, if present, use that timeout. If the scenario's defaults do not
255- // indicate a retry configuration, we ask the plugin if it has retry defaults
256- // and use that.
267+ // getRetry returns the retry configuration for the test spec. We check for
268+ // overrides in retry configuration using the following precedence:
269+ //
270+ // * Spec (Evaluable) override
271+ // * Spec's Base override
272+ // * Scenario's default
273+ // * Plugin's default
257274func getRetry (
258275 ctx context.Context ,
259- specRetry * gdttypes.Retry ,
260276 scenDefaults * Defaults ,
261- pluginRetry * gdttypes.Retry ,
277+ plugin gdttypes.Plugin ,
278+ eval gdttypes.Evaluable ,
262279) * gdttypes.Retry {
263- if specRetry != nil {
280+ evalRetry := eval .Retry ()
281+ if evalRetry != nil {
282+ if evalRetry == gdttypes .NoRetry {
283+ return evalRetry
284+ }
264285 msg := "using retry"
265- if specRetry .Attempts != nil {
266- msg += fmt .Sprintf (" (attempts: %d)" , * specRetry .Attempts )
286+ if evalRetry .Attempts != nil {
287+ msg += fmt .Sprintf (" (attempts: %d)" , * evalRetry .Attempts )
267288 }
268- if specRetry .Interval != "" {
269- msg += fmt .Sprintf (" (interval: %s)" , specRetry .Interval )
289+ if evalRetry .Interval != "" {
290+ msg += fmt .Sprintf (" (interval: %s)" , evalRetry .Interval )
270291 }
271- msg += fmt .Sprintf (" (exponential: %t)" , specRetry .Exponential )
292+ msg += fmt .Sprintf (" (exponential: %t)" , evalRetry .Exponential )
272293 debug .Println (ctx , msg )
273- return specRetry
294+ return evalRetry
274295 }
296+
297+ sb := eval .Base ()
298+ baseRetry := sb .Retry
299+ if baseRetry != nil {
300+ if baseRetry == gdttypes .NoRetry {
301+ return baseRetry
302+ }
303+ msg := "using retry"
304+ if baseRetry .Attempts != nil {
305+ msg += fmt .Sprintf (" (attempts: %d)" , * baseRetry .Attempts )
306+ }
307+ if baseRetry .Interval != "" {
308+ msg += fmt .Sprintf (" (interval: %s)" , baseRetry .Interval )
309+ }
310+ msg += fmt .Sprintf (" (exponential: %t)" , baseRetry .Exponential )
311+ debug .Println (ctx , msg )
312+ return baseRetry
313+ }
314+
275315 if scenDefaults != nil && scenDefaults .Retry != nil {
276316 scenRetry := scenDefaults .Retry
317+ if scenRetry == gdttypes .NoRetry {
318+ return scenRetry
319+ }
277320 msg := "using retry"
278321 if scenRetry .Attempts != nil {
279322 msg += fmt .Sprintf (" (attempts: %d)" , * scenRetry .Attempts )
@@ -285,7 +328,14 @@ func getRetry(
285328 debug .Println (ctx , msg )
286329 return scenRetry
287330 }
331+
332+ pluginInfo := plugin .Info ()
333+ pluginRetry := pluginInfo .Retry
334+
288335 if pluginRetry != nil {
336+ if pluginRetry == gdttypes .NoRetry {
337+ return pluginRetry
338+ }
289339 msg := "using retry"
290340 if pluginRetry .Attempts != nil {
291341 msg += fmt .Sprintf (" (attempts: %d)" , * pluginRetry .Attempts )
0 commit comments