Skip to content

Fix ItFailsWithAnAppropriateErrorMessage test for file-based programs#53981

Merged
baronfel merged 3 commits intodotnet:mainfrom
MichaelSimons:fix-dotnet-run-parse-error-test
Apr 21, 2026
Merged

Fix ItFailsWithAnAppropriateErrorMessage test for file-based programs#53981
baronfel merged 3 commits intodotnet:mainfrom
MichaelSimons:fix-dotnet-run-parse-error-test

Conversation

@MichaelSimons
Copy link
Copy Markdown
Member

Problem

The test GivenDotnetRunThrowsAParseError.ItFailsWithAnAppropriateErrorMessage fails intermittently on Helix CI (Build 1384286, Helix job 212f0243-ba7b-46c1-b518-6747e726c978, work item dotnet.Tests.dll.18).

Fix

Replace Path.GetTempPath() with TestAssetsManager.CreateTestDirectory().Path to use a dedicated empty directory, ensuring no stray files interfere. This follows the pattern used by other tests in the same directory.

Validation

  • Built the test project successfully
  • Ran the test locally — passes

Copilot AI review requested due to automatic review settings April 17, 2026 22:40
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>
@MichaelSimons MichaelSimons force-pushed the fix-dotnet-run-parse-error-test branch from b471def to 051dcef Compare April 17, 2026 22:41
@MichaelSimons MichaelSimons requested a review from a team April 17, 2026 22:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 via TestAssetsManager.CreateTestDirectory().
  • Add an explanatory comment documenting why the shared temp directory is unreliable for this scenario.

Comment thread test/dotnet.Tests/CommandTests/Run/GivenDotnetRunThrowsAParseError.cs Outdated
MichaelSimons and others added 2 commits April 20, 2026 10:03
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@baronfel baronfel merged commit 0b52d15 into dotnet:main Apr 21, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants