Skip to content

Commit 9b8347e

Browse files
CopilotT-Gro
andcommitted
Add CaptureTrace attribute and remove console capturing logic
Co-authored-by: T-Gro <[email protected]>
1 parent 63b7ee9 commit 9b8347e

File tree

3 files changed

+6
-44
lines changed

3 files changed

+6
-44
lines changed

tests/FSharp.Test.Utilities/FileInlineDataAttribute.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ open System.Runtime.CompilerServices
99
open System.Runtime.InteropServices
1010

1111
open Xunit
12-
open Xunit.Abstractions
1312
open Xunit.Sdk
1413

1514
open FSharp.Compiler.IO

tests/FSharp.Test.Utilities/XunitHelpers.fs

Lines changed: 5 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ namespace FSharp.Test
66

77
open System
88
open Xunit.Sdk
9-
open Xunit.Abstractions
109

1110
open TestFramework
1211

@@ -32,31 +31,10 @@ type StressAttribute([<ParamArray>] data: obj array) =
3231

3332
#if XUNIT_EXTRAS
3433

35-
// To use xUnit means to customize it. The following abomination adds 2 features:
36-
// - Capturing full console output individually for each test case, viewable in Test Explorer as test stdout.
34+
// To use xUnit means to customize it. The following features are added:
3735
// - Internally parallelize test classes and theories. Test cases and theory cases included in a single class or F# module can execute simultaneously
38-
39-
/// Passes captured console output to xUnit.
40-
type ConsoleCapturingTestRunner(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource) =
41-
inherit XunitTestRunner(test, messageBus, testClass, constructorArguments, testMethod, testMethodArguments, skipReason, beforeAfterAttributes, aggregator, cancellationTokenSource)
42-
43-
member _.BaseInvokeTestMethodAsync aggregator = base.InvokeTestMethodAsync aggregator
44-
override this.InvokeTestAsync (aggregator: ExceptionAggregator) =
45-
task {
46-
use capture = new TestConsole.ExecutionCapture()
47-
use _ = Activity.startNoTags test.DisplayName
48-
let! executionTime = this.BaseInvokeTestMethodAsync aggregator
49-
let output =
50-
seq {
51-
capture.OutText
52-
if not (String.IsNullOrEmpty capture.ErrorText) then
53-
""
54-
"=========== Standard Error ==========="
55-
""
56-
capture.ErrorText
57-
} |> String.concat Environment.NewLine
58-
return executionTime, output
59-
}
36+
// - Add batch traits for CI multi-agent testing support
37+
// Note: Console output capturing is now handled by xUnit3's built-in [<assembly: CaptureTrace>] attribute
6038

6139
module TestCaseCustomizations =
6240
// Internally parallelize test classes and theories.
@@ -110,19 +88,11 @@ module TestCaseCustomizations =
11088

11189
type CustomTestCase =
11290
inherit XunitTestCase
113-
// xUinit demands this constructor for deserialization.
91+
// xUnit demands this constructor for deserialization.
11492
new() = { inherit XunitTestCase() }
11593

11694
new(sink: IMessageSink, md, mdo, testMethod, testMethodArgs) = { inherit XunitTestCase(sink, md, mdo, testMethod, testMethodArgs) }
11795

118-
override testCase.RunAsync (_, bus, args, aggregator, cts) =
119-
let runner : XunitTestCaseRunner =
120-
{ new XunitTestCaseRunner(testCase, testCase.DisplayName, testCase.SkipReason, args, testCase.TestMethodArguments, bus, aggregator, cts) with
121-
override this.CreateTestRunner(test, bus, testCase, args, testMethod, methodArgs, skipReason, attrs, aggregator, cts) =
122-
ConsoleCapturingTestRunner(test, bus, testCase, args, testMethod, methodArgs, skipReason, attrs, aggregator, cts)
123-
}
124-
runner.RunAsync()
125-
12696
// Initialize is ensured by xUnit to run once before any property access.
12797
override testCase.Initialize () =
12898
base.Initialize()
@@ -135,14 +105,6 @@ type CustomTheoryTestCase =
135105

136106
new(sink: IMessageSink, md, mdo, testMethod) = { inherit XunitTheoryTestCase(sink, md, mdo, testMethod) }
137107

138-
override testCase.RunAsync (sink, bus, args, aggregator, cts) =
139-
let runner : XunitTestCaseRunner =
140-
{ new XunitTheoryTestCaseRunner(testCase, testCase.DisplayName, testCase.SkipReason, args, sink, bus, aggregator, cts) with
141-
override this.CreateTestRunner(test, bus, testCase, args, testMethod, methodArgs, skipReason, attrs, aggregator, cts) =
142-
ConsoleCapturingTestRunner(test, bus, testCase, args, testMethod, methodArgs, skipReason, attrs, aggregator, cts)
143-
}
144-
runner.RunAsync()
145-
146108
override testCase.Initialize () =
147109
base.Initialize()
148110
testCase.TestMethod <- TestCaseCustomizations.rewriteTestMethod testCase
@@ -239,7 +201,7 @@ type FSharpXunitFramework(sink: IMessageSink) =
239201
}
240202

241203
#if XUNIT_EXTRAS
242-
// Rewrites discovered test cases to support extra parallelization and capturing console as test output.
204+
// Rewrites discovered test cases to support extra parallelization and batch trait injection.
243205
override this.CreateDiscoverer (assemblyInfo) =
244206
{ new XunitTestFrameworkDiscoverer(assemblyInfo, this.SourceInformationProvider, this.DiagnosticMessageSink) with
245207
override _.FindTestsForType (testClass, includeSourceInformation, messageBus, options) =

tests/FSharp.Test.Utilities/XunitSetup.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ type NotThreadSafeResourceCollection = class end
1010
module XUnitSetup =
1111

1212
[<assembly: TestFramework("FSharp.Test.FSharpXunitFramework", "FSharp.Test.Utilities")>]
13+
[<assembly: CaptureTrace>]
1314
do ()

0 commit comments

Comments
 (0)