From 1df053746e38c6c13e2f96ead68bda97bbe5c2f5 Mon Sep 17 00:00:00 2001 From: Paul Blasucci Date: Sat, 3 May 2025 23:05:05 +0200 Subject: [PATCH 1/2] log standard out on passing tests --- global.json | 4 +++- package.json | 3 ++- release/README.md | 2 +- src/Components/TestExplorer.fs | 34 ++++++++++++++++++++-------------- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/global.json b/global.json index 33021c04..62f01add 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,7 @@ { "sdk": { - "version": "8.0.100" + "version": "8.0.100", + "rollForward": "feature", + "allowPrerelease": false } } \ No newline at end of file diff --git a/package.json b/package.json index 7d9f649b..ceb94163 100644 --- a/package.json +++ b/package.json @@ -27,5 +27,6 @@ }, "engines": { "node": ">=16.0.0" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" } diff --git a/release/README.md b/release/README.md index e8b0d6f2..32914069 100644 --- a/release/README.md +++ b/release/README.md @@ -59,7 +59,7 @@ You find a version of this plugin pre-packaged with the FOSS debugger from Samsu ## How to Contribute -Ths project is hosted on [GitHub](https://github.com/ionide/ionide-vscode-fsharp) where you can [report issues](https://github.com/ionide/ionide-vscode-fsharp/issues), participate in [discussions](https://github.com/ionide/ionide-vscode-fsharp/discussions), fork +This project is hosted on [GitHub](https://github.com/ionide/ionide-vscode-fsharp) where you can [report issues](https://github.com/ionide/ionide-vscode-fsharp/issues), participate in [discussions](https://github.com/ionide/ionide-vscode-fsharp/discussions), fork the project and submit pull requests. ### Building and Running diff --git a/src/Components/TestExplorer.fs b/src/Components/TestExplorer.fs index f93aac27..002718c5 100644 --- a/src/Components/TestExplorer.fs +++ b/src/Components/TestExplorer.fs @@ -240,6 +240,7 @@ module TestFrameworkId = type TestResult = { FullTestName: string Outcome: TestResultOutcome + Output: string option ErrorMessage: string option ErrorStackTrace: string option Expected: string option @@ -312,13 +313,12 @@ module TrxParser = { Message: string option StackTrace: string option } - type Output = { ErrorInfo: ErrorInfo } - type UnitTestResult = { ExecutionId: string Outcome: string Duration: TimeSpan - Output: Output } + Output: string option + ErrorInfo: ErrorInfo } type TestWithResult = { UnitTest: UnitTest @@ -376,6 +376,8 @@ module TrxParser = let outcome = xpathSelector.SelectStringRelative(node, "@outcome") + let outputMessage = xpathSelector.TrySelectStringRelative(node, "t:Output/t:StdOut") + let errorInfoMessage = xpathSelector.TrySelectStringRelative(node, "t:Output/t:ErrorInfo/t:Message") @@ -387,14 +389,13 @@ module TrxParser = let success, ts = TimeSpan.TryParse(durationString) if success then ts else TimeSpan.Zero - { ExecutionId = executionId Outcome = outcome Duration = durationSpan - Output = - { ErrorInfo = - { StackTrace = errorStackTrace - Message = errorInfoMessage } } } + Output = outputMessage + ErrorInfo = + { StackTrace = errorStackTrace + Message = errorInfoMessage } } xpathSelector.SelectNodes "/t:TestRun/t:Results/t:UnitTestResult" |> Array.map extractRow @@ -1237,7 +1238,12 @@ module Interactions = match testResult.Outcome with | TestResultOutcome.NotExecuted -> testRun.skipped testItem - | TestResultOutcome.Passed -> testRun.passed (testItem, testResult.Timing) + | TestResultOutcome.Passed -> + testResult.Output + |> Option.iter (TestRun.appendOutputLineForTest testRun testItem) + + testRun.passed (testItem, testResult.Timing) + | TestResultOutcome.Failed -> let fullErrorMessage = match testResult.ErrorMessage with @@ -1248,10 +1254,10 @@ module Interactions = | None -> "No error reported" let msg = vscode.TestMessage.Create(!^fullErrorMessage) - msg.location <- TestItem.tryGetLocation testItem msg.expectedOutput <- testResult.Expected msg.actualOutput <- testResult.Actual + TestRun.showFailure testRun testItem msg testResult.Timing let mergeTestResultsToExplorer @@ -1303,9 +1309,8 @@ module Interactions = displayTestResultInExplorer testRun (treeItem, additionalResult)) let private trxResultToTestResult (trxResult: TrxParser.TestWithResult) = - // Q: can I get these parameters down to just trxResult? let expected, actual = - match trxResult.UnitTestResult.Output.ErrorInfo.Message with + match trxResult.UnitTestResult.ErrorInfo.Message with | None -> None, None | Some message -> let lines = @@ -1320,8 +1325,9 @@ module Interactions = { FullTestName = trxResult.UnitTest.FullName Outcome = !!trxResult.UnitTestResult.Outcome - ErrorMessage = trxResult.UnitTestResult.Output.ErrorInfo.Message - ErrorStackTrace = trxResult.UnitTestResult.Output.ErrorInfo.StackTrace + Output = trxResult.UnitTestResult.Output + ErrorMessage = trxResult.UnitTestResult.ErrorInfo.Message + ErrorStackTrace = trxResult.UnitTestResult.ErrorInfo.StackTrace Expected = expected Actual = actual Timing = trxResult.UnitTestResult.Duration.Milliseconds From cd1dff8890c25e7a0f319a57a8bd545974dec9fc Mon Sep 17 00:00:00 2001 From: Paul Blasucci Date: Mon, 5 May 2025 00:44:07 +0200 Subject: [PATCH 2/2] Reviewer feedback --- src/Components/TestExplorer.fs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Components/TestExplorer.fs b/src/Components/TestExplorer.fs index 002718c5..a9929121 100644 --- a/src/Components/TestExplorer.fs +++ b/src/Components/TestExplorer.fs @@ -313,12 +313,15 @@ module TrxParser = { Message: string option StackTrace: string option } + type Output = + { StdOut: string option + ErrorInfo: ErrorInfo } + type UnitTestResult = { ExecutionId: string Outcome: string Duration: TimeSpan - Output: string option - ErrorInfo: ErrorInfo } + Output: Output } type TestWithResult = { UnitTest: UnitTest @@ -392,10 +395,11 @@ module TrxParser = { ExecutionId = executionId Outcome = outcome Duration = durationSpan - Output = outputMessage - ErrorInfo = - { StackTrace = errorStackTrace - Message = errorInfoMessage } } + Output = + { StdOut = outputMessage + ErrorInfo = + { StackTrace = errorStackTrace + Message = errorInfoMessage } } } xpathSelector.SelectNodes "/t:TestRun/t:Results/t:UnitTestResult" |> Array.map extractRow @@ -1310,7 +1314,7 @@ module Interactions = let private trxResultToTestResult (trxResult: TrxParser.TestWithResult) = let expected, actual = - match trxResult.UnitTestResult.ErrorInfo.Message with + match trxResult.UnitTestResult.Output.ErrorInfo.Message with | None -> None, None | Some message -> let lines = @@ -1325,9 +1329,9 @@ module Interactions = { FullTestName = trxResult.UnitTest.FullName Outcome = !!trxResult.UnitTestResult.Outcome - Output = trxResult.UnitTestResult.Output - ErrorMessage = trxResult.UnitTestResult.ErrorInfo.Message - ErrorStackTrace = trxResult.UnitTestResult.ErrorInfo.StackTrace + Output = trxResult.UnitTestResult.Output.StdOut + ErrorMessage = trxResult.UnitTestResult.Output.ErrorInfo.Message + ErrorStackTrace = trxResult.UnitTestResult.Output.ErrorInfo.StackTrace Expected = expected Actual = actual Timing = trxResult.UnitTestResult.Duration.Milliseconds