Repository navigation
Copy acceptance test diagnostic logs into the test results directory - #16403
Merged
Jakub Jareš (nohwnd) merged 1 commit intoAug 24, 2026
Conversation
TestContext.AddResultFile only records the path it is given. The diagnostic logs of an acceptance test are written under the agent temp directory, which is not published and is deleted when the agent is recycled, so the published trx points at files that no longer exist. Copy the attached files into a per-test directory under the test results directory, and attach the copies. The pipeline already publishes that folder when the job fails, so no pipeline change is needed. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves diagnosability of failing acceptance tests by ensuring diagnostic log attachments referenced by TRX results live under the published test results directory (instead of the agent temp directory), so attached paths remain valid in CI artifacts.
Changes:
- Refactors
IntegrationTestBasetest cleanup to copy diagnostic attachments into a per-test subdirectory under the test results directory, then attaches the copied files. - Introduces
AttachmentUtilsto sanitize per-test attachment directory names and to enumerate/copy attachment trees in a cleanup-safe (non-throwing) way. - Adds acceptance tests validating attachment sanitization and copy semantics (including copying files that are still open for writing).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Microsoft.TestPlatform.TestUtilities/IntegrationTestBase.cs | Copies attachments into the MSTest results directory on failure and attaches the copied paths so TRX references remain valid in CI artifacts. |
| test/Microsoft.TestPlatform.TestUtilities/AttachmentUtils.cs | New helper for sanitizing per-test attachment directory names and safely enumerating/copying attached files/directories. |
| test/Microsoft.TestPlatform.Acceptance.IntegrationTests/AttachmentUtilsTests.cs | New tests covering sanitize + copy behaviors (directory trees, open files, duplicates, missing attachments). |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+49
to
+52
| // Windows does not allow a name to end with a dot or a space. | ||
| var sanitized = builder.ToString().Trim('_', '.', ' '); | ||
| return sanitized.Length == 0 ? "test" : sanitized; | ||
| } |
Jakub Jareš (nohwnd)
enabled auto-merge (squash)
August 24, 2026 16:30
Amaury Levé (Evangelink)
approved these changes
Aug 24, 2026
This was referenced Oct 13, 2026
Merged
This was referenced Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The cleanup already keeps the temp directory when an acceptance test fails, and the pipeline already publishes
artifacts/TestResults/<config>when the job fails. Nothing connects the two.TestContext.AddResultFileonly records the path it is given, and the diagnostic logs are written under$(Agent.TempDirectory), which is not published and is deleted when the agent is recycled. So the published trx ends up with<ResultFile>entries likeD:\a\_work\_temp\vstest\IVpTd\logs\log.datacollector.26-08-24_13-50-25_67394_5.txtthat point at nothing.That is why the
CrashDumpOnStackOverflowfailure in build 20260824.3 could not be diagnosed. The blame data collector log would have explained it, and it is not in any artifact.Now the attached files are copied into a per-test directory under the test results directory, and the copies are attached instead. Each test needs a directory of its own because acceptance tests run in parallel and they all write a file called
log.txt. Only the log directories that are in_attachmentsare copied, so crash dumps and extracted packages stay in the temp directory. A file that cannot be copied is logged and skipped, so cleanup never replaces the failure the test reported.No pipeline change is needed, the existing
Publish Test Results foldersstep picks the files up.Verified: failed an acceptance test on purpose, the logs landed in
artifacts/TestResults/Release/.../attachments/<test name>_<id>/and the trx<ResultFile>entries pointed at the copies. Unit tests andbuild.cmd -c Release -packare green.🤖