From 04b3f9176b92bcce63cac31d5c2035c2b3c04045 Mon Sep 17 00:00:00 2001 From: John Barnes Date: Mon, 17 Oct 2022 19:49:36 +0200 Subject: [PATCH 1/2] Execute before and after for each spec Signed-off-by: John Barnes --- execution/simpleExecution.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/execution/simpleExecution.go b/execution/simpleExecution.go index 915e0bd53..30fd479db 100644 --- a/execution/simpleExecution.go +++ b/execution/simpleExecution.go @@ -125,12 +125,8 @@ func (e *simpleExecution) executeSpecs(sc *gauge.SpecCollection) (results []*res specs := sc.Next() var preHookFailures, postHookFailures []*gauge_messages.ProtoHookFailure var specResults []*result.SpecResult - var before, after = true, false - for i, spec := range specs { - if i == len(specs)-1 { - after = true - } - res := newSpecExecutor(spec, e.runner, e.pluginHandler, e.errMaps, e.stream).execute(before, preHookFailures == nil, after) + for _, spec := range specs { + res := newSpecExecutor(spec, e.runner, e.pluginHandler, e.errMaps, e.stream).execute(true, preHookFailures == nil, true) before = false specResults = append(specResults, res) preHookFailures = append(preHookFailures, res.GetPreHook()...) From f5df097d3f486152469575e384c8ce2166efaeac Mon Sep 17 00:00:00 2001 From: John Barnes Date: Mon, 17 Oct 2022 19:49:36 +0200 Subject: [PATCH 2/2] Execute before and after for each spec Signed-off-by: John Barnes --- execution/simpleExecution.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/execution/simpleExecution.go b/execution/simpleExecution.go index 915e0bd53..ed20f9443 100644 --- a/execution/simpleExecution.go +++ b/execution/simpleExecution.go @@ -125,13 +125,8 @@ func (e *simpleExecution) executeSpecs(sc *gauge.SpecCollection) (results []*res specs := sc.Next() var preHookFailures, postHookFailures []*gauge_messages.ProtoHookFailure var specResults []*result.SpecResult - var before, after = true, false - for i, spec := range specs { - if i == len(specs)-1 { - after = true - } - res := newSpecExecutor(spec, e.runner, e.pluginHandler, e.errMaps, e.stream).execute(before, preHookFailures == nil, after) - before = false + for _, spec := range specs { + res := newSpecExecutor(spec, e.runner, e.pluginHandler, e.errMaps, e.stream).execute(true, preHookFailures == nil, true) specResults = append(specResults, res) preHookFailures = append(preHookFailures, res.GetPreHook()...) postHookFailures = append(postHookFailures, res.GetPostHook()...)