From 817fdafd9e96a326d250f04353885abd28fd4128 Mon Sep 17 00:00:00 2001 From: Piotr Nestorow Date: Fri, 7 Jun 2024 09:04:58 +0200 Subject: [PATCH] Programmatic skip scenario (#210) * Skip scenario during execution support Signed-off-by: Piotr Nestorow * Send error info when skip scenario during runtime Signed-off-by: Piotr Nestorow * Workflow LSP tests update --------- Signed-off-by: Piotr Nestorow --- .github/workflows/build.yml | 5 +- src/ExecutionOrchestrator.cs | 19 +++-- src/Gauge.CSharp.Core/Spec.cs | 129 ++++++++++++++++++++++------------ src/Gauge.Dotnet.csproj | 4 +- src/HookExecutor.cs | 28 ++++++-- src/Models/ExecutionResult.cs | 2 + src/StepExecutor.cs | 36 +++++++--- src/dotnet.json | 2 +- 8 files changed, 155 insertions(+), 70 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 933f6b8d..c8c1e4aa 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -115,7 +115,10 @@ jobs: - uses: actions/checkout@v3 - name: Setup go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 + with: + go-version: '1.22' + cache: false - name: Setup .NET Core uses: actions/setup-dotnet@v3 diff --git a/src/ExecutionOrchestrator.cs b/src/ExecutionOrchestrator.cs index f748ce60..0c8e3f9b 100644 --- a/src/ExecutionOrchestrator.cs +++ b/src/ExecutionOrchestrator.cs @@ -92,13 +92,25 @@ private ProtoExecutionResult BuildResult(Stopwatch stopwatch, ExecutionResult ex var result = new ProtoExecutionResult { Failed = false, - ExecutionTime = stopwatch.ElapsedMilliseconds + ExecutionTime = stopwatch.ElapsedMilliseconds, + SkipScenario = executionResult.SkipScenario }; var allPendingMessages = GetAllPendingMessages().Where(m => m != null); result.Message.AddRange(allPendingMessages); var allPendingScreenShotFiles = GetAllPendingScreenshotFiles().Where(s => s != null); result.ScreenshotFiles.AddRange(allPendingScreenShotFiles); + + // If runtime skipped scenario return Error message and stack info + if (!string.IsNullOrEmpty(executionResult.ExceptionMessage)) + { + result.ErrorMessage = executionResult.ExceptionMessage; + } + if (!string.IsNullOrEmpty(executionResult.StackTrace)) + { + result.StackTrace = executionResult.StackTrace; + } if (executionResult.Success) return result; + var elapsedMilliseconds = stopwatch.ElapsedMilliseconds; result.Failed = true; var isScreenShotEnabled = Utils.TryReadEnvValue("SCREENSHOT_ON_FAILURE"); @@ -110,11 +122,6 @@ private ProtoExecutionResult BuildResult(Stopwatch stopwatch, ExecutionResult ex } } - result.ErrorMessage = executionResult.ExceptionMessage; - if (!string.IsNullOrEmpty(executionResult.StackTrace)) - { - result.StackTrace = executionResult.StackTrace; - } result.RecoverableError = executionResult.Recoverable; result.ExecutionTime = elapsedMilliseconds; return result; diff --git a/src/Gauge.CSharp.Core/Spec.cs b/src/Gauge.CSharp.Core/Spec.cs index 161f990d..f0fbe7c4 100644 --- a/src/Gauge.CSharp.Core/Spec.cs +++ b/src/Gauge.CSharp.Core/Spec.cs @@ -104,55 +104,56 @@ static SpecReflection() { "AiABKAsyIC5nYXVnZS5tZXNzYWdlcy5Qcm90b0hvb2tGYWlsdXJlEjkKD3Bv", "c3RIb29rRmFpbHVyZRgDIAEoCzIgLmdhdWdlLm1lc3NhZ2VzLlByb3RvSG9v", "a0ZhaWx1cmUSDwoHc2tpcHBlZBgEIAEoCBIVCg1za2lwcGVkUmVhc29uGAUg", - "ASgJIosDChRQcm90b0V4ZWN1dGlvblJlc3VsdBIOCgZmYWlsZWQYASABKAgS", + "ASgJIqEDChRQcm90b0V4ZWN1dGlvblJlc3VsdBIOCgZmYWlsZWQYASABKAgS", "GAoQcmVjb3ZlcmFibGVFcnJvchgCIAEoCBIUCgxlcnJvck1lc3NhZ2UYAyAB", "KAkSEgoKc3RhY2tUcmFjZRgEIAEoCRIWCgpzY3JlZW5TaG90GAUgASgMQgIY", "ARIVCg1leGVjdXRpb25UaW1lGAYgASgDEg8KB21lc3NhZ2UYByADKAkSQQoJ", "ZXJyb3JUeXBlGAggASgOMi4uZ2F1Z2UubWVzc2FnZXMuU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5nYXVnZVoxZ2l0aHViLmNvbS9nZXRnYXVn", + "ZS9nYXVnZS1wcm90by9nby9nYXVnZV9tZXNzYWdlc6oCDkdhdWdlLk1lc3Nh", + "Z2VzYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Gauge.Messages.ExecutionStatus), }, null, new pbr::GeneratedClrTypeInfo[] { @@ -170,7 +171,7 @@ static SpecReflection() { new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoTable), global::Gauge.Messages.ProtoTable.Parser, new[]{ "Headers", "Rows" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoTableRow), global::Gauge.Messages.ProtoTableRow.Parser, new[]{ "Cells" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoStepExecutionResult), global::Gauge.Messages.ProtoStepExecutionResult.Parser, new[]{ "ExecutionResult", "PreHookFailure", "PostHookFailure", "Skipped", "SkippedReason" }, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoExecutionResult), global::Gauge.Messages.ProtoExecutionResult.Parser, new[]{ "Failed", "RecoverableError", "ErrorMessage", "StackTrace", "ScreenShot", "ExecutionTime", "Message", "ErrorType", "FailureScreenshot", "Screenshots", "FailureScreenshotFile", "ScreenshotFiles" }, null, new[]{ typeof(global::Gauge.Messages.ProtoExecutionResult.Types.ErrorType) }, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoExecutionResult), global::Gauge.Messages.ProtoExecutionResult.Parser, new[]{ "Failed", "RecoverableError", "ErrorMessage", "StackTrace", "ScreenShot", "ExecutionTime", "Message", "ErrorType", "FailureScreenshot", "Screenshots", "FailureScreenshotFile", "ScreenshotFiles", "SkipScenario" }, null, new[]{ typeof(global::Gauge.Messages.ProtoExecutionResult.Types.ErrorType) }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoHookFailure), global::Gauge.Messages.ProtoHookFailure.Parser, new[]{ "StackTrace", "ErrorMessage", "ScreenShot", "TableRowIndex", "FailureScreenshot", "FailureScreenshotFile" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoSuiteResult), global::Gauge.Messages.ProtoSuiteResult.Parser, new[]{ "SpecResults", "PreHookFailure", "PostHookFailure", "Failed", "SpecsFailedCount", "ExecutionTime", "SuccessRate", "Environment", "Tags", "ProjectName", "Timestamp", "SpecsSkippedCount", "PreHookMessages", "PostHookMessages", "PreHookMessage", "PostHookMessage", "PreHookScreenshots", "PostHookScreenshots", "Chunked", "ChunkSize", "PreHookScreenshotFiles", "PostHookScreenshotFiles" }, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Gauge.Messages.ProtoSpecResult), global::Gauge.Messages.ProtoSpecResult.Parser, new[]{ "ProtoSpec", "ScenarioCount", "ScenarioFailedCount", "Failed", "FailedDataTableRows", "ExecutionTime", "Skipped", "ScenarioSkippedCount", "SkippedDataTableRows", "Errors", "Timestamp" }, null, null, null, null), @@ -5890,6 +5891,7 @@ public ProtoExecutionResult(ProtoExecutionResult other) : this() { screenshots_ = other.screenshots_.Clone(); failureScreenshotFile_ = other.failureScreenshotFile_; screenshotFiles_ = other.screenshotFiles_.Clone(); + skipScenario_ = other.skipScenario_; _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); } @@ -6079,6 +6081,21 @@ public string FailureScreenshotFile { get { return screenshotFiles_; } } + /// Field number for the "skipScenario" field. + public const int SkipScenarioFieldNumber = 13; + private bool skipScenario_; + /// + //// Flag to indicate skipping of the scenario execution + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool SkipScenario { + get { return skipScenario_; } + set { + skipScenario_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] public override bool Equals(object other) { @@ -6106,6 +6123,7 @@ public bool Equals(ProtoExecutionResult other) { if(!screenshots_.Equals(other.screenshots_)) return false; if (FailureScreenshotFile != other.FailureScreenshotFile) return false; if(!screenshotFiles_.Equals(other.screenshotFiles_)) return false; + if (SkipScenario != other.SkipScenario) return false; return Equals(_unknownFields, other._unknownFields); } @@ -6125,6 +6143,7 @@ public override int GetHashCode() { hash ^= screenshots_.GetHashCode(); if (FailureScreenshotFile.Length != 0) hash ^= FailureScreenshotFile.GetHashCode(); hash ^= screenshotFiles_.GetHashCode(); + if (SkipScenario != false) hash ^= SkipScenario.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } @@ -6182,6 +6201,10 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteString(FailureScreenshotFile); } screenshotFiles_.WriteTo(output, _repeated_screenshotFiles_codec); + if (SkipScenario != false) { + output.WriteRawTag(104); + output.WriteBool(SkipScenario); + } if (_unknownFields != null) { _unknownFields.WriteTo(output); } @@ -6231,6 +6254,10 @@ public void WriteTo(pb::CodedOutputStream output) { output.WriteString(FailureScreenshotFile); } screenshotFiles_.WriteTo(ref output, _repeated_screenshotFiles_codec); + if (SkipScenario != false) { + output.WriteRawTag(104); + output.WriteBool(SkipScenario); + } if (_unknownFields != null) { _unknownFields.WriteTo(ref output); } @@ -6271,6 +6298,9 @@ public int CalculateSize() { size += 1 + pb::CodedOutputStream.ComputeStringSize(FailureScreenshotFile); } size += screenshotFiles_.CalculateSize(_repeated_screenshotFiles_codec); + if (SkipScenario != false) { + size += 1 + 1; + } if (_unknownFields != null) { size += _unknownFields.CalculateSize(); } @@ -6313,6 +6343,9 @@ public void MergeFrom(ProtoExecutionResult other) { FailureScreenshotFile = other.FailureScreenshotFile; } screenshotFiles_.Add(other.screenshotFiles_); + if (other.SkipScenario != false) { + SkipScenario = other.SkipScenario; + } _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); } @@ -6376,6 +6409,10 @@ public void MergeFrom(pb::CodedInputStream input) { screenshotFiles_.AddEntriesFrom(input, _repeated_screenshotFiles_codec); break; } + case 104: { + SkipScenario = input.ReadBool(); + break; + } } } #endif @@ -6439,6 +6476,10 @@ public void MergeFrom(pb::CodedInputStream input) { screenshotFiles_.AddEntriesFrom(ref input, _repeated_screenshotFiles_codec); break; } + case 104: { + SkipScenario = input.ReadBool(); + break; + } } } } diff --git a/src/Gauge.Dotnet.csproj b/src/Gauge.Dotnet.csproj index a6d89928..a211c113 100644 --- a/src/Gauge.Dotnet.csproj +++ b/src/Gauge.Dotnet.csproj @@ -5,7 +5,7 @@ net6.0;net7.0;net8.0 Runner.NetCore30 The Gauge Team - 0.5.7 + 0.5.8 ThoughtWorks Inc. Gauge C# runner for Gauge. https://gauge.org @@ -23,7 +23,7 @@ - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/src/HookExecutor.cs b/src/HookExecutor.cs index 8ef522f0..c71b831d 100644 --- a/src/HookExecutor.cs +++ b/src/HookExecutor.cs @@ -13,6 +13,7 @@ using Gauge.Dotnet.Strategy; using Gauge.Dotnet.Wrappers; using Gauge.Messages; +using Gauge.CSharp.Lib.Attribute; namespace Gauge.Dotnet { @@ -37,7 +38,8 @@ public ExecutionResult Execute(string hookType, IHooksStrategy strategy, IList @@ -52,14 +57,27 @@ public ExecutionResult Execute(GaugeMethod gaugeMethod, params string[] args) } catch (Exception ex) { - Logger.Debug($"Error executing {method.Name} : {ex.Message}") ; - var innerException = ex.InnerException ?? ex; - executionResult.ExceptionMessage = innerException.Message; - executionResult.StackTrace = innerException is AggregateException - ? innerException.ToString() - : innerException.StackTrace; - executionResult.Source = innerException.Source; - executionResult.Recoverable = gaugeMethod.ContinueOnFailure; + var baseException = ex.GetBaseException(); + if (baseException != null && + baseException.GetType().Name.Contains("SkipScenario", StringComparison.OrdinalIgnoreCase)) { + Logger.Debug($"Skipping scenario when executing method: {method.Name} : {baseException.Message}") ; + executionResult.ExceptionMessage = baseException.Message; + executionResult.StackTrace = baseException.StackTrace; + executionResult.Source = baseException.Source; + executionResult.Success = true; + executionResult.SkipScenario = true; + } + else { + Logger.Debug($"Error executing {method.Name} : {ex.Message}") ; + var innerException = ex.InnerException ?? ex; + executionResult.ExceptionMessage = innerException.Message; + executionResult.StackTrace = innerException is AggregateException + ? innerException.ToString() + : innerException.StackTrace; + executionResult.Source = innerException.Source; + executionResult.Recoverable = gaugeMethod.ContinueOnFailure; + executionResult.Success = false; + } } return executionResult; diff --git a/src/dotnet.json b/src/dotnet.json index 898105db..7ddaab97 100644 --- a/src/dotnet.json +++ b/src/dotnet.json @@ -1,6 +1,6 @@ { "id": "dotnet", - "version": "0.5.7", + "version": "0.5.8", "description": "C# support for gauge + .NET 6.0/7.0/8.0", "run": { "windows": [