Repository navigation
Write xUnit command log before running tests - #17609
Conversation
Initialize the captured log before Exec and append runner output, avoiding the post-run MSBuild reopen. Add coverage for ordering, captured and console output, failure status, quoting, and fresh logs on reruns. Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The changes require final human review because they are too complex or risky for automated approval.
Review effort: Lite
Findings: None
What changed in this PR
Moves xUnit command logging before test execution to avoid reopening the output log afterward, while preserving output capture and exit-code behavior.
Changes:
- Appends runner output and initializes the log with an overwrite-enabled command header.
- Adds integration-style tests covering ordering, capture modes, exit codes, paths, arguments, and stale logs.
| File | Description |
|---|---|
| src/Microsoft.DotNet.Arcade.Sdk/tools/XUnit/XUnit.Runner.targets | Updated as part of this pull request. |
| src/Microsoft.DotNet.Arcade.Sdk.Tests/XUnitRunnerTests.cs | Updated as part of this pull request. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@copilot all the newly added tests seem to be failing on Windows |
Co-authored-by: premun <[email protected]>
Windows-built test assemblies retain CRLF in raw string literals even when executed on Unix. Normalize the generated shell script to LF so stderr redirection is parsed correctly in cross-platform Helix runs. Co-authored-by: Copilot App <[email protected]>
|
Fixed the cross-platform test-script issue in 953fb8d. The failing legs are Windows-built assemblies running on Linux/macOS, not Windows execution. All five execution cases were missing The C# raw string retains the build checkout's CRLF. The Unix script now uses Validation:
|
|
/backport to release/11.0 |
|
Started backporting to |
|
Also seen in 11.0 in aspnetcore. |
Summary
Move xUnit's
WriteLinesToFileimmediately after output-directory creation and deletion, beforeExec. Initialize the log withOverwrite="true"and append runner stdout/stderr with>> ... 2>&1. Remove the post-run write.The command is intentionally a header instead of a footer. Retaining the MSBuild writer keeps the command as data rather than introducing another shell-parsing layer through
echo. Capture-disabled console behavior, exit-code reporting, timeout, XML/HTML paths, batching, andFileWritesare unchanged. No retries or suppressed errors are added.Motivation and evidence
In ASP.NET Core build 1597302, the failing Windows job was on stage/job attempt 2, while the Run build.cmd task log recorded task attempt 1.
XUnit.Runner.targets(96,5)in Arcade SDK11.0.0-beta.26453.108reported MSB3491 while appending toServerComparison.FunctionalTests_net11.0_x64.log: the file was being used by another process.The investigation found one
RunTestsexecution:Execreturned 0 after 24,851 ms, thenWriteLinesToFilefailed after 14 ms. The runner log reported 37 tests, 31 passed, 6 skipped, no failures/errors, and no command footer. Build attempt 3 succeeded with the same counts and the footer present. Another occurrence was observed in build 1597356, followed by recovery in 1597643; test success is not inferred for that second incident.This follows the ordering/append approach used for analogous VSTest contention in #9864, #9915, and #10037, while retaining
WriteLinesToFile. The conflicting handle owner is unknown. This does not establish antivirus or concurrency as the cause, or guarantee elimination of every sharing violation. It removes the post-run reopen where this failure occurred.Validation
Execwith a fake runner: command ordering, default/explicit/disabled capture, successful and failing exit codes, stdout and stderr preservation, quoted metacharacters and paths with spaces, XML/HTML arguments,FileWrites, and repeat execution without stale log contents.CentralPackageManagementTests.ImplicitPackageReferences_ShouldNotConflictWithPackageVersionEntries, reporting the implicitMicrosoft.VisualStudioEng.MicroBuild.Plugins.SwixBuildreference also present in central package versions. A clean-baseline comparison was not performed.DisableParallelization=trueto avoid overlapping the shared in-process MSBuildBuildManagerused by other tests.Build.cmd -configuration Release -test -binaryLogcompiled the repository but did not pass all tests. In addition to the SDK failure above, observed failures included Workloads MSI/Visual Studio tests (including missing VS MSBuild and a WiX compilation failure) andSignToolTests.SignBundleDoubleNested. These were not baseline-verified or changed here./bin/shrunner path, but Unix execution was not performed (no WSL distribution installed). No live CI reproduction or retries were performed.To double check: