Fix flaky DistributedFileLoggerParameters test by isolating log files in TEMP#13704
Open
Fix flaky DistributedFileLoggerParameters test by isolating log files in TEMP#13704
Conversation
Contributor
|
Hello @copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
…nt temp folder Agent-Logs-Url: https://github.com/dotnet/msbuild/sessions/34c84440-a320-492f-971d-81aa53507443 Co-authored-by: rainersigwald <3347530+rainersigwald@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix flaky DistributedFileLoggerParameters test
Fix flaky DistributedFileLoggerParameters test by isolating log files in TEMP
May 6, 2026
rainersigwald
approved these changes
May 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes flakiness in FileLogger_Tests.DistributedFileLoggerParameters by ensuring default/implicit log files (like msbuild0.log) are created in a per-test transient TEMP directory rather than the test bin folder, reducing susceptibility to transient file locks from external processes.
Changes:
- Updated
DistributedFileLoggerParametersto useTestEnvironment+ aTransientTestFolderand set it as the current directory for the test. - Removed manual cleanup logic in favor of
TestEnvironment-managed cleanup and switched string comparisons to Shouldly.
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.
Context
FileLogger_Tests.DistributedFileLoggerParametersintermittently failed withLoggerException: Failed to write to log file "msbuild0.log"... it is being used by another processagainst a path inside the test bin folder.The first iteration calls
Initializewith noParameters, soDistributedFileLoggerdefaults tomsbuild0.loginDirectory.GetCurrentDirectory()— i.e. the test bin directory. Thefinallyblock tried to deletemylogfile0.log(a name that never existed), somsbuild0.logleaked between runs and was vulnerable to transient locks from antivirus, search indexers, or other processes scanning the bin output.Changes Made
Rewrote the test using
TestEnvironmentand modernized pertests.instructions.md:ITestOutputHelperconstructor; pass_outputtoTestEnvironment.Create.TransientTestFolderunder TEMP and set it as the current directory viaenv.SetCurrentDirectory, so the implicitmsbuild0.logand all explicit log paths resolve into the transient folder and get auto-cleaned on dispose. Removed the manualtry/finallycleanup.folder.CreateDirectory("tempura")for the nested-subfolder case instead ofDirectory.CreateDirectory+ manual delete.Assert.Equal(0, string.Compare(..., StringComparison.OrdinalIgnoreCase))withShouldBe(..., StringCompareShould.IgnoreCase).Testing
DistributedFileLoggerParametersand the rest ofFileLogger_Testspass locally (the unrelatedInvalidFiletest remains skipped on Linux via its existing trait).Notes
Other hypotheses considered and ruled out: reuse of the
fileLoggerinstance across iterations (eachShutdown()properly closes the writer) and stale_logFilestate (theParameterssetter re-parses on eachInitialize). The leakedmsbuild0.login the bin directory is the only plausible flakiness vector, and isolating to a per-test TEMP folder removes it.