Skip to content

Commit 9f3ae73

Browse files
rolfbjarneCopilotEvangelink
authored
Add an in-process TRX generation mode (#12318)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Amaury Levé <amauryleve@microsoft.com>
1 parent c98af1a commit 9f3ae73

41 files changed

Lines changed: 1401 additions & 103 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
#nullable enable
2+
static Microsoft.Testing.Extensions.TrxReport.Abstractions.TrxReportEngine.AddArtifactsAsync(System.IO.FileInfo! trxFile, System.Collections.Generic.Dictionary<Microsoft.Testing.Platform.Extensions.IExtension!, System.Collections.Generic.List<Microsoft.Testing.Platform.Extensions.Messages.SessionFileArtifact!>!>! artifacts, Microsoft.Testing.Platform.Helpers.IFileSystem! fileSystem, Microsoft.Testing.Platform.Helpers.IEnvironment! environment, Microsoft.Testing.Platform.Configurations.IConfiguration! configuration, Microsoft.Testing.Platform.Helpers.IClock! clock, System.Threading.CancellationToken cancellationToken) -> System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<string!>!>!
3+
Microsoft.Testing.Extensions.TrxReport.Abstractions.TrxReportGeneratorCommandLine.TrxReportGeneratorCommandLine(bool isTestHostControllerSupported, Microsoft.Testing.Platform.Helpers.IEnvironment! environment) -> void
4+
static Microsoft.Testing.Extensions.TrxReport.TrxModeHelpers.GetControllerModeEnvironmentVariableName(string! controllerPid) -> string!
5+
static Microsoft.Testing.Extensions.TrxReport.TrxModeHelpers.GetEffectiveMode(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions, Microsoft.Testing.Platform.Helpers.IEnvironment! environment) -> string?
6+
static Microsoft.Testing.Extensions.TrxReport.TrxModeHelpers.ShouldUseOutOfProcessTrxGeneration(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions, Microsoft.Testing.Platform.Helpers.IEnvironment! environment) -> bool
27
*REMOVED*const Microsoft.Testing.Platform.Helpers.EnvironmentVariableConstants.TESTINGPLATFORM_DIAGNOSTIC_FILELOGGER_SYNCHRONOUSWRITE = "TESTINGPLATFORM_DIAGNOSTIC_FILELOGGER_SYNCHRONOUSWRITE" -> string!
38
*REMOVED*const Microsoft.Testing.Platform.Helpers.EnvironmentVariableConstants.TESTINGPLATFORM_DIAGNOSTIC_OUTPUT_FILEPREFIX = "TESTINGPLATFORM_DIAGNOSTIC_OUTPUT_FILEPREFIX" -> string!
9+
const Microsoft.Testing.Extensions.TrxReport.Abstractions.TrxReportGeneratorCommandLine.InProcessMode = "in-process" -> string!
10+
const Microsoft.Testing.Extensions.TrxReport.Abstractions.TrxReportGeneratorCommandLine.OutOfProcessMode = "out-of-process" -> string!
11+
const Microsoft.Testing.Extensions.TrxReport.Abstractions.TrxReportGeneratorCommandLine.TrxModeOptionName = "trx-mode" -> string!
12+
override Microsoft.Testing.Extensions.TrxReport.Abstractions.TrxReportGeneratorCommandLine.ValidateCommandLineOptionsAsync(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions) -> System.Threading.Tasks.Task<Microsoft.Testing.Platform.Extensions.ValidationResult>!
13+
override Microsoft.Testing.Extensions.TrxReport.Abstractions.TrxReportGeneratorCommandLine.ValidateOptionArgumentsAsync(Microsoft.Testing.Platform.Extensions.CommandLine.CommandLineOption! commandOption, string![]! arguments) -> System.Threading.Tasks.Task<Microsoft.Testing.Platform.Extensions.ValidationResult>!
14+
static Microsoft.Testing.Extensions.TrxReport.TrxModeHelpers.ShouldUseControllerBackedTrxGeneration(Microsoft.Testing.Platform.CommandLine.ICommandLineOptions! commandLineOptions) -> bool
415
static Microsoft.Testing.Platform.OutputDevice.TargetFrameworkParser.GetTargetFrameworkFromAssembly(System.Reflection.Assembly? entryAssembly) -> string?

‎src/Platform/Microsoft.Testing.Extensions.TrxReport/PACKAGE.md‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,21 @@ This package extends Microsoft.Testing.Platform with:
2222

2323
Enable TRX report generation via the `--report-trx` command line option.
2424

25-
On platforms that can launch a test-host process (all except Android, browser, iOS, tvOS, and WASI), TRX uses controller-backed recovery by default: the test host still streams results and generates the report during normal execution, but a surviving controller process can recover completed results into a TRX report if the test host crashes, hangs, or is stopped by `--timeout`. Android, browser, iOS, tvOS, and WASI cannot launch a test-host process, so TRX automatically falls back to its original in-process implementation there — no controller-backed recovery is attempted, and no configuration is required to get this fallback.
25+
On macOS, Windows, Linux, and other platforms that support a controller process, TRX uses one by default. The test host generates the report during normal execution; the controller can recover completed results if the host crashes, hangs, or is stopped by `--timeout`. On Android, iOS, Mac Catalyst, tvOS, WASI, and in browsers, TRX always runs in-process, without controller-backed recovery.
2626

27-
The extra process has a measurable startup cost, which varies by target framework: for a trivial single-test run, launching the controller added no statistically measurable overhead on .NET (differences were within normal process-launch noise) but added roughly 700-800ms on .NET Framework in local measurements. Weigh this against the reliability benefit for your scenario, especially on .NET Framework or in tight inner-loop test runs.
27+
The controller adds another process and may increase startup time.
28+
29+
Use `--report-trx --trx-mode:in-process` to generate a report without starting a controller for TRX. This can be useful when a launcher runs tests in a separate app, for example on a device or simulator.
30+
31+
In-process mode cannot recover a report if the test host crashes, hangs, or is terminated. Other options, such as `--crashdump` or `--hangdump`, may still start a controller, but TRX recovery remains disabled.
32+
33+
Use `--trx-mode:out-of-process` to explicitly request controller-backed recovery. This mode is unavailable on Android, iOS, Mac Catalyst, tvOS, WASI, and in browsers. Both modes require `--report-trx`; leaving `--trx-mode` unspecified preserves the default behavior.
34+
35+
To make in-process mode the passive default, set `"commandLineOptionDefaults": { "trx-mode": "in-process" }` in `testconfig.json`. It takes effect only with `--report-trx`, and an explicit `--trx-mode` overrides it.
36+
37+
The controller passes its selected mode to the test host, so a custom launcher can use a child application with different configuration defaults. Configured run defaults remain passive when invoking `merge-trx` or `ms-trxcompare`.
38+
39+
When another extension starts a controller, in-process mode still includes that controller's file attachments in the completed TRX. This does not enable crash recovery or make TRX request a controller.
2840

2941
## Related packages
3042

‎src/Platform/Microsoft.Testing.Extensions.TrxReport/Resources/ExtensionResources.resx‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,22 @@
200200
<data name="TrxReportArtifactDescription" xml:space="preserve">
201201
<value>Test session</value>
202202
</data>
203+
<data name="TrxModeOptionDescription" xml:space="preserve">
204+
<value>TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</value>
205+
<comment>Do not localize format name {Locked="TRX"}, mode names {Locked="in-process"}{Locked="out-of-process"}, or option name {Locked="--report-trx"}.</comment>
206+
</data>
207+
<data name="TrxModeInvalidValue" xml:space="preserve">
208+
<value>'--trx-mode' expects 'in-process' or 'out-of-process'</value>
209+
<comment>Do not localize option name {Locked="--trx-mode"} or mode names {Locked="in-process"}{Locked="out-of-process"}.</comment>
210+
</data>
211+
<data name="TrxModeRequiresTrxReport" xml:space="preserve">
212+
<value>'--trx-mode' requires '--report-trx' to be enabled</value>
213+
<comment>Do not localize option names {Locked="--trx-mode"}{Locked="--report-trx"}.</comment>
214+
</data>
215+
<data name="TrxModeOutOfProcessNotSupported" xml:space="preserve">
216+
<value>'--trx-mode out-of-process' is not supported on this platform</value>
217+
<comment>Do not localize option and value {Locked="--trx-mode out-of-process"}.</comment>
218+
</data>
203219
<data name="TrxReportArtifactDisplayName" xml:space="preserve">
204220
<value>TRX Report</value>
205221
<comment>Do not localize format name {Locked="TRX"}.</comment>

‎src/Platform/Microsoft.Testing.Extensions.TrxReport/Resources/xlf/ExtensionResources.cs.xlf‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@
102102
<target state="translated">Sloučená sestava TRX</target>
103103
<note>Do not localize format name {Locked="TRX"}.</note>
104104
</trans-unit>
105+
<trans-unit id="TrxModeInvalidValue">
106+
<source>'--trx-mode' expects 'in-process' or 'out-of-process'</source>
107+
<target state="new">'--trx-mode' expects 'in-process' or 'out-of-process'</target>
108+
<note>Do not localize option name {Locked="--trx-mode"} or mode names {Locked="in-process"}{Locked="out-of-process"}.</note>
109+
</trans-unit>
110+
<trans-unit id="TrxModeOptionDescription">
111+
<source>TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</source>
112+
<target state="new">TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</target>
113+
<note>Do not localize format name {Locked="TRX"}, mode names {Locked="in-process"}{Locked="out-of-process"}, or option name {Locked="--report-trx"}.</note>
114+
</trans-unit>
115+
<trans-unit id="TrxModeOutOfProcessNotSupported">
116+
<source>'--trx-mode out-of-process' is not supported on this platform</source>
117+
<target state="new">'--trx-mode out-of-process' is not supported on this platform</target>
118+
<note>Do not localize option and value {Locked="--trx-mode out-of-process"}.</note>
119+
</trans-unit>
120+
<trans-unit id="TrxModeRequiresTrxReport">
121+
<source>'--trx-mode' requires '--report-trx' to be enabled</source>
122+
<target state="new">'--trx-mode' requires '--report-trx' to be enabled</target>
123+
<note>Do not localize option names {Locked="--trx-mode"}{Locked="--report-trx"}.</note>
124+
</trans-unit>
105125
<trans-unit id="TrxReportArtifactDescription">
106126
<source>Test session</source>
107127
<target state="translated">Relace testu</target>

‎src/Platform/Microsoft.Testing.Extensions.TrxReport/Resources/xlf/ExtensionResources.de.xlf‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@
102102
<target state="translated">Zusammengeführter TRX-Bericht</target>
103103
<note>Do not localize format name {Locked="TRX"}.</note>
104104
</trans-unit>
105+
<trans-unit id="TrxModeInvalidValue">
106+
<source>'--trx-mode' expects 'in-process' or 'out-of-process'</source>
107+
<target state="new">'--trx-mode' expects 'in-process' or 'out-of-process'</target>
108+
<note>Do not localize option name {Locked="--trx-mode"} or mode names {Locked="in-process"}{Locked="out-of-process"}.</note>
109+
</trans-unit>
110+
<trans-unit id="TrxModeOptionDescription">
111+
<source>TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</source>
112+
<target state="new">TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</target>
113+
<note>Do not localize format name {Locked="TRX"}, mode names {Locked="in-process"}{Locked="out-of-process"}, or option name {Locked="--report-trx"}.</note>
114+
</trans-unit>
115+
<trans-unit id="TrxModeOutOfProcessNotSupported">
116+
<source>'--trx-mode out-of-process' is not supported on this platform</source>
117+
<target state="new">'--trx-mode out-of-process' is not supported on this platform</target>
118+
<note>Do not localize option and value {Locked="--trx-mode out-of-process"}.</note>
119+
</trans-unit>
120+
<trans-unit id="TrxModeRequiresTrxReport">
121+
<source>'--trx-mode' requires '--report-trx' to be enabled</source>
122+
<target state="new">'--trx-mode' requires '--report-trx' to be enabled</target>
123+
<note>Do not localize option names {Locked="--trx-mode"}{Locked="--report-trx"}.</note>
124+
</trans-unit>
105125
<trans-unit id="TrxReportArtifactDescription">
106126
<source>Test session</source>
107127
<target state="translated">Testsitzung</target>

‎src/Platform/Microsoft.Testing.Extensions.TrxReport/Resources/xlf/ExtensionResources.es.xlf‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@
102102
<target state="translated">Informe TRX combinado</target>
103103
<note>Do not localize format name {Locked="TRX"}.</note>
104104
</trans-unit>
105+
<trans-unit id="TrxModeInvalidValue">
106+
<source>'--trx-mode' expects 'in-process' or 'out-of-process'</source>
107+
<target state="new">'--trx-mode' expects 'in-process' or 'out-of-process'</target>
108+
<note>Do not localize option name {Locked="--trx-mode"} or mode names {Locked="in-process"}{Locked="out-of-process"}.</note>
109+
</trans-unit>
110+
<trans-unit id="TrxModeOptionDescription">
111+
<source>TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</source>
112+
<target state="new">TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</target>
113+
<note>Do not localize format name {Locked="TRX"}, mode names {Locked="in-process"}{Locked="out-of-process"}, or option name {Locked="--report-trx"}.</note>
114+
</trans-unit>
115+
<trans-unit id="TrxModeOutOfProcessNotSupported">
116+
<source>'--trx-mode out-of-process' is not supported on this platform</source>
117+
<target state="new">'--trx-mode out-of-process' is not supported on this platform</target>
118+
<note>Do not localize option and value {Locked="--trx-mode out-of-process"}.</note>
119+
</trans-unit>
120+
<trans-unit id="TrxModeRequiresTrxReport">
121+
<source>'--trx-mode' requires '--report-trx' to be enabled</source>
122+
<target state="new">'--trx-mode' requires '--report-trx' to be enabled</target>
123+
<note>Do not localize option names {Locked="--trx-mode"}{Locked="--report-trx"}.</note>
124+
</trans-unit>
105125
<trans-unit id="TrxReportArtifactDescription">
106126
<source>Test session</source>
107127
<target state="translated">Sesión de prueba</target>

‎src/Platform/Microsoft.Testing.Extensions.TrxReport/Resources/xlf/ExtensionResources.fr.xlf‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@
102102
<target state="translated">Rapport TRX fusionné</target>
103103
<note>Do not localize format name {Locked="TRX"}.</note>
104104
</trans-unit>
105+
<trans-unit id="TrxModeInvalidValue">
106+
<source>'--trx-mode' expects 'in-process' or 'out-of-process'</source>
107+
<target state="new">'--trx-mode' expects 'in-process' or 'out-of-process'</target>
108+
<note>Do not localize option name {Locked="--trx-mode"} or mode names {Locked="in-process"}{Locked="out-of-process"}.</note>
109+
</trans-unit>
110+
<trans-unit id="TrxModeOptionDescription">
111+
<source>TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</source>
112+
<target state="new">TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</target>
113+
<note>Do not localize format name {Locked="TRX"}, mode names {Locked="in-process"}{Locked="out-of-process"}, or option name {Locked="--report-trx"}.</note>
114+
</trans-unit>
115+
<trans-unit id="TrxModeOutOfProcessNotSupported">
116+
<source>'--trx-mode out-of-process' is not supported on this platform</source>
117+
<target state="new">'--trx-mode out-of-process' is not supported on this platform</target>
118+
<note>Do not localize option and value {Locked="--trx-mode out-of-process"}.</note>
119+
</trans-unit>
120+
<trans-unit id="TrxModeRequiresTrxReport">
121+
<source>'--trx-mode' requires '--report-trx' to be enabled</source>
122+
<target state="new">'--trx-mode' requires '--report-trx' to be enabled</target>
123+
<note>Do not localize option names {Locked="--trx-mode"}{Locked="--report-trx"}.</note>
124+
</trans-unit>
105125
<trans-unit id="TrxReportArtifactDescription">
106126
<source>Test session</source>
107127
<target state="translated">Session de test</target>

‎src/Platform/Microsoft.Testing.Extensions.TrxReport/Resources/xlf/ExtensionResources.it.xlf‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@
102102
<target state="translated">Report TRX unito</target>
103103
<note>Do not localize format name {Locked="TRX"}.</note>
104104
</trans-unit>
105+
<trans-unit id="TrxModeInvalidValue">
106+
<source>'--trx-mode' expects 'in-process' or 'out-of-process'</source>
107+
<target state="new">'--trx-mode' expects 'in-process' or 'out-of-process'</target>
108+
<note>Do not localize option name {Locked="--trx-mode"} or mode names {Locked="in-process"}{Locked="out-of-process"}.</note>
109+
</trans-unit>
110+
<trans-unit id="TrxModeOptionDescription">
111+
<source>TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</source>
112+
<target state="new">TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</target>
113+
<note>Do not localize format name {Locked="TRX"}, mode names {Locked="in-process"}{Locked="out-of-process"}, or option name {Locked="--report-trx"}.</note>
114+
</trans-unit>
115+
<trans-unit id="TrxModeOutOfProcessNotSupported">
116+
<source>'--trx-mode out-of-process' is not supported on this platform</source>
117+
<target state="new">'--trx-mode out-of-process' is not supported on this platform</target>
118+
<note>Do not localize option and value {Locked="--trx-mode out-of-process"}.</note>
119+
</trans-unit>
120+
<trans-unit id="TrxModeRequiresTrxReport">
121+
<source>'--trx-mode' requires '--report-trx' to be enabled</source>
122+
<target state="new">'--trx-mode' requires '--report-trx' to be enabled</target>
123+
<note>Do not localize option names {Locked="--trx-mode"}{Locked="--report-trx"}.</note>
124+
</trans-unit>
105125
<trans-unit id="TrxReportArtifactDescription">
106126
<source>Test session</source>
107127
<target state="translated">Sessione di test</target>

‎src/Platform/Microsoft.Testing.Extensions.TrxReport/Resources/xlf/ExtensionResources.ja.xlf‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,26 @@
102102
<target state="translated">マージされた TRX レポート</target>
103103
<note>Do not localize format name {Locked="TRX"}.</note>
104104
</trans-unit>
105+
<trans-unit id="TrxModeInvalidValue">
106+
<source>'--trx-mode' expects 'in-process' or 'out-of-process'</source>
107+
<target state="new">'--trx-mode' expects 'in-process' or 'out-of-process'</target>
108+
<note>Do not localize option name {Locked="--trx-mode"} or mode names {Locked="in-process"}{Locked="out-of-process"}.</note>
109+
</trans-unit>
110+
<trans-unit id="TrxModeOptionDescription">
111+
<source>TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</source>
112+
<target state="new">TRX generation mode: 'in-process' disables controller-backed recovery; 'out-of-process' enables it (the default on supported platforms). Requires '--report-trx'.</target>
113+
<note>Do not localize format name {Locked="TRX"}, mode names {Locked="in-process"}{Locked="out-of-process"}, or option name {Locked="--report-trx"}.</note>
114+
</trans-unit>
115+
<trans-unit id="TrxModeOutOfProcessNotSupported">
116+
<source>'--trx-mode out-of-process' is not supported on this platform</source>
117+
<target state="new">'--trx-mode out-of-process' is not supported on this platform</target>
118+
<note>Do not localize option and value {Locked="--trx-mode out-of-process"}.</note>
119+
</trans-unit>
120+
<trans-unit id="TrxModeRequiresTrxReport">
121+
<source>'--trx-mode' requires '--report-trx' to be enabled</source>
122+
<target state="new">'--trx-mode' requires '--report-trx' to be enabled</target>
123+
<note>Do not localize option names {Locked="--trx-mode"}{Locked="--report-trx"}.</note>
124+
</trans-unit>
105125
<trans-unit id="TrxReportArtifactDescription">
106126
<source>Test session</source>
107127
<target state="translated">テスト セッション</target>

0 commit comments

Comments
 (0)