From a550d71ca2ff2408b0f49bf06d9bf76e28633490 Mon Sep 17 00:00:00 2001 From: Piotr Nestorow Date: Mon, 11 Mar 2024 07:27:55 +0100 Subject: [PATCH] Added scenario retries info params (#2496) * Added scenario retries info params Signed-off-by: Piotr Nestorow * Go.mod update Signed-off-by: Piotr Nestorow * Added ScenarioRetriesInfo unit test Signed-off-by: Piotr Nestorow * Added ScenarioRetriesInfo unit test Signed-off-by: Piotr Nestorow --------- Signed-off-by: Piotr Nestorow --- execution/specExecutor.go | 4 ++++ execution/specExecutor_test.go | 23 +++++++++++++++++++++++ go.mod | 4 ++-- go.sum | 8 ++++---- version/version.go | 2 +- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/execution/specExecutor.go b/execution/specExecutor.go index 2f27be6d3..0f878b099 100644 --- a/execution/specExecutor.go +++ b/execution/specExecutor.go @@ -299,6 +299,10 @@ func (e *specExecutor) executeScenario(scenario *gauge.Scenario) (*result.Scenar Name: scenario.Heading.Value, Tags: getTagValue(scenario.Tags), IsFailed: false, + Retries: &gauge_messages.ScenarioRetriesInfo{ + MaxRetries: int32(MaxRetriesCount)-1, + CurrentRetry: int32(retriesCount), + }, } scenarioResult = &result.ScenarioResult{ diff --git a/execution/specExecutor_test.go b/execution/specExecutor_test.go index 3e1e46de2..a80bf8637 100644 --- a/execution/specExecutor_test.go +++ b/execution/specExecutor_test.go @@ -722,3 +722,26 @@ func TestExecuteShouldMarkSpecAsSkippedWhenAllScenariosSkipped(t *testing.T) { t.Error("Expect SpecResult.Skipped = true, got false") } } + +func TestExecuteScenarioShoulHaveRetriesInfo(t *testing.T) { + MaxRetriesCount = 3 + RetryOnlyTags = "tagSce" + + se := newSpecExecutorForTestsWithRetry() + sceResult, _ := se.executeScenario(exampleSpecWithTags.Scenarios[0]) + + if sceResult.GetFailed() { + t.Errorf("Expect sceResult.GetFailed() = false, got true") + } + if se.currentExecutionInfo.CurrentScenario.Retries.MaxRetries != int32(MaxRetriesCount - 1) { + t.Errorf("Expected MaxRetries %d, got %d", + int32(MaxRetriesCount - 1), + se.currentExecutionInfo.CurrentScenario.Retries.MaxRetries) + } + if se.currentExecutionInfo.CurrentScenario.Retries.CurrentRetry != int32(MaxRetriesCount - 1) { + t.Errorf("Expected CurrentRetry %d, got %d", + int32(MaxRetriesCount - 1), + se.currentExecutionInfo.CurrentScenario.Retries.CurrentRetry) + } +} + diff --git a/go.mod b/go.mod index 3be890712..6c4a7f6a4 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/daviddengcn/go-colortext v1.0.0 github.com/fsnotify/fsnotify v1.7.0 github.com/getgauge/common v0.0.0-20231211152919-94c93e29f0b9 - github.com/getgauge/gauge-proto/go/gauge_messages v0.0.0-20240224015747-16d1a26a9fea + github.com/getgauge/gauge-proto/go/gauge_messages v0.0.0-20240305092417-e4088981ee73 github.com/golang/protobuf v1.5.3 github.com/magiconair/properties v1.8.7 github.com/natefinch/lumberjack v2.0.0+incompatible @@ -18,7 +18,7 @@ require ( github.com/sourcegraph/jsonrpc2 v0.2.0 github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 - google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c + google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 google.golang.org/grpc v1.62.0 google.golang.org/protobuf v1.32.0 gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c diff --git a/go.sum b/go.sum index 6b594881c..2ea42665d 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/getgauge/common v0.0.0-20231211152919-94c93e29f0b9 h1:OwggKdL8AeteB2y0xJzloieq9CMhYG7YmKKMh6D8FLs= github.com/getgauge/common v0.0.0-20231211152919-94c93e29f0b9/go.mod h1:p/Q0+qO2bLq08PuxaHrxIgkvKlGGYHyXad33+zKIiXU= -github.com/getgauge/gauge-proto/go/gauge_messages v0.0.0-20240224015747-16d1a26a9fea h1:l2xnnhqp0wlvCwOQn+TGk3yBfqOdUw2hYRf5UwAl1C4= -github.com/getgauge/gauge-proto/go/gauge_messages v0.0.0-20240224015747-16d1a26a9fea/go.mod h1:qf8Dv2iFBwlgpBZBOKjW9JDaYi5lHqXNYXEHTXd62Uw= +github.com/getgauge/gauge-proto/go/gauge_messages v0.0.0-20240305092417-e4088981ee73 h1:WkPxV7TpYcqzSWHMSEnDAKJFLWugp/rWtvHVJz+0h0E= +github.com/getgauge/gauge-proto/go/gauge_messages v0.0.0-20240305092417-e4088981ee73/go.mod h1:TXmEkop8jQOf4Q84sCcbJE1kVvb3rcZLkMHL6WbCbcQ= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= @@ -69,8 +69,8 @@ golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 h1:IR+hp6ypxjH24bkMfEJ0yHR21+gwPWdV+/IBrPQyn3k= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs= google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= diff --git a/version/version.go b/version/version.go index 3f00343d8..87e212ccf 100644 --- a/version/version.go +++ b/version/version.go @@ -14,7 +14,7 @@ import ( ) // CurrentGaugeVersion represents the current version of Gauge -var CurrentGaugeVersion = &Version{1, 6, 3} +var CurrentGaugeVersion = &Version{1, 6, 4} // BuildMetadata represents build information of current release (e.g, nightly build information) var BuildMetadata = ""