Fix ItFailsWithAnAppropriateErrorMessage test for file-based programs#53981
Merged
baronfel merged 3 commits intodotnet:mainfrom Apr 21, 2026
Merged
Conversation
The test used Path.GetTempPath() as the working directory, expecting 'dotnet run' to fail with 'Couldn't find a project to run.' However, with .NET 11 file-based program support, 'dotnet run' now also scans for loose .cs files. On Helix, the temp directory is shared across parallel test runs and can contain stray .cs files from other tests, causing 'dotnet run' to attempt compilation instead of producing the expected error message. Fix: use TestAssetsManager.CreateTestDirectory() to get a dedicated empty directory, ensuring no stray files interfere with the test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
b471def to
051dcef
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Stabilizes dotnet run parse-error coverage by ensuring the test runs in a truly empty working directory, avoiding intermittent interference from stray files in shared temp locations.
Changes:
- Switch working directory from
Path.GetTempPath()to a dedicated empty directory created viaTestAssetsManager.CreateTestDirectory(). - Add an explanatory comment documenting why the shared temp directory is unreliable for this scenario.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This was referenced Apr 20, 2026
Open
baronfel
approved these changes
Apr 21, 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.
Problem
The test
GivenDotnetRunThrowsAParseError.ItFailsWithAnAppropriateErrorMessagefails intermittently on Helix CI (Build 1384286, Helix job212f0243-ba7b-46c1-b518-6747e726c978, work itemdotnet.Tests.dll.18).Fix
Replace
Path.GetTempPath()withTestAssetsManager.CreateTestDirectory().Pathto use a dedicated empty directory, ensuring no stray files interfere. This follows the pattern used by other tests in the same directory.Validation