From d1bd42c3f721594db7784aff340579b3941009e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20R=C3=A4tzel?= Date: Wed, 24 May 2023 16:34:01 +0000 Subject: [PATCH] Record more details on test results Mainly to support the investigation of weird crashes of test runners on MacOS environments. --- On MacOS, `dotnet test` often crashed with an output like this: -------------- The active test run was aborted. Reason: Test host process crashed : # # Fatal error in , line 0 # Check failed: 12 == (*__error()). # # # #FailureMessage Object: 0x7000099fac00 Results File: /Users/runner/work/elm-time/elm-time/implement/test-elm-time/TestResults/_Mac-1684933830638_2023-05-24_13_11_43.trx Test Run Aborted with error System.Exception: One or more errors occurred. Passed! - Failed: 0, Passed: 4, Skipped: 0, Total: 4, Duration: 4 s - test-elm-time.dll (net7.0) ---> System.Exception: Unable to read beyond the end of the stream. at System.IO.BinaryReader.Read7BitEncodedInt() at System.IO.BinaryReader.ReadString() at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.LengthPrefixCommunicationChannel.NotifyDataAvailable() at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TcpClientExtensions.MessageLoopAsync(TcpClient client, ICommunicationChannel channel, Action`1 errorHandler, CancellationToken cancellationToken) --- End of inner exception stack trace ---. Error: Process completed with exit code 1. ------------ See https://github.com/microsoft/vstest/issues/4376 and https://github.com/microsoft/vstest/issues/2952 --- .github/workflows/test-and-publish.yml | 12 +++++++++++- implement/elm-time/elm-time.csproj | 2 +- implement/test-elm-time/JavaScriptEngineTest.cs | 13 ++----------- implement/test-elm-time/test-elm-time.csproj | 4 ++-- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test-and-publish.yml b/.github/workflows/test-and-publish.yml index ba873692..e44d899c 100644 --- a/.github/workflows/test-and-publish.yml +++ b/.github/workflows/test-and-publish.yml @@ -36,7 +36,7 @@ jobs: run: dotnet clean ./implement/test-elm-time/test-elm-time.csproj && dotnet nuget locals all --clear - name: Run tests with dotnet test - run: dotnet test ./implement/test-elm-time/test-elm-time.csproj --logger trx + run: dotnet test ./implement/test-elm-time/test-elm-time.csproj --logger "trx" --diag "./implement/test-elm-time/TestResults/diag-log.txt" --verbosity diagnostic - name: Publish test results uses: actions/upload-artifact@v3 @@ -45,6 +45,16 @@ jobs: name: test-results-${{ github.sha }}-${{ matrix.environment }} path: ./implement/test-elm-time/TestResults + - name: Summarize Test Results + uses: EnricoMi/publish-unit-test-result-action/composite@v2 + if: always() + with: + check_name: "Test Results Summaries ${{ matrix.environment }}" + files: | + ./implement/test-elm-time/TestResults/**/*.xml + ./implement/test-elm-time/TestResults/**/*.trx + ./implement/test-elm-time/TestResults/**/*.json + - name: dotnet publish run: dotnet publish -c Debug -r ${{ matrix.publish-runtime-id }} --self-contained true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true -p:IncludeAllContentForSelfExtract=true -p:PublishReadyToRun=true -p:PublishReadyToRunShowWarnings=true --output ./publish ./implement/elm-time diff --git a/implement/elm-time/elm-time.csproj b/implement/elm-time/elm-time.csproj index 5049c497..fc2073b7 100644 --- a/implement/elm-time/elm-time.csproj +++ b/implement/elm-time/elm-time.csproj @@ -28,7 +28,7 @@ - + diff --git a/implement/test-elm-time/JavaScriptEngineTest.cs b/implement/test-elm-time/JavaScriptEngineTest.cs index c5ddb5a1..c1ee983b 100644 --- a/implement/test-elm-time/JavaScriptEngineTest.cs +++ b/implement/test-elm-time/JavaScriptEngineTest.cs @@ -1,7 +1,5 @@ using ElmTime; -using Microsoft.ClearScript; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; namespace TestElmTime; @@ -11,15 +9,8 @@ public class JavaScriptEngineTest [TestMethod] public void Evaluate_in_JavaScriptEngine() { - try - { - var jsEngine = JsEngineFromJavaScriptEngineSwitcher.ConstructJsEngine(); + var jsEngine = JsEngineFromJavaScriptEngineSwitcher.ConstructJsEngine(); - Assert.AreEqual(4, jsEngine.Evaluate("3 + 1")); - } - finally - { - Console.WriteLine("HostSettings.AuxiliarySearchPath: " + HostSettings.AuxiliarySearchPath); - } + Assert.AreEqual(4, jsEngine.Evaluate("3 + 1")); } } diff --git a/implement/test-elm-time/test-elm-time.csproj b/implement/test-elm-time/test-elm-time.csproj index 440b8f1f..45d1410e 100644 --- a/implement/test-elm-time/test-elm-time.csproj +++ b/implement/test-elm-time/test-elm-time.csproj @@ -15,10 +15,10 @@ - + - + runtime; build; native; contentfiles; analyzers; buildtransitive all