Convert DotnetCommand tests with "new" to DotnetNewCommand#52697
Convert DotnetCommand tests with "new" to DotnetNewCommand#52697marcpopMSFT merged 2 commits intomainfrom
Conversation
Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
|
Quick search of the repo shows those four test files have all of the DotnetCommand "new" entries so I think this PR is correct. |
There was a problem hiding this comment.
Pull request overview
This PR converts 7 test instances from using DotnetCommand for dotnet new operations to using the dedicated DotnetNewCommand class. This ensures ephemeral hive configuration is enforced at construction time, preventing intermittent test failures caused by missing hive configuration.
Changes:
- Converted 7
DotnetCommandinstances calling "new" to useDotnetNewCommandwith explicitWithVirtualHive()configuration - Ensures all
dotnet newtest operations use ephemeral hive to avoid test interference
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
test/dotnet.Tests/CommandTests/Run/RunFileTests.cs |
Converted 1 instance in Precedence_NuGetTool test to use DotnetNewCommand with virtual hive |
test/dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs |
Converted 1 instance in SameAsTemplate test to use DotnetNewCommand with virtual hive |
test/dotnet-new.IntegrationTests/DotnetNewInstallTests.cs |
Converted 2 instances in CanInstallToPathWithAt test to use DotnetNewCommand with virtual hive |
test/Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs |
Converted 3 instances across multiple tests (InstallAndRunToolLocal, InstallAndRunNativeAotLocalTool, InstallToolWithHigherFrameworkAsLocalToolShowsAppropriateError) to use DotnetNewCommand with virtual hive |
dsplaisted
left a comment
There was a problem hiding this comment.
Nice! Do we have an idea of how often this is causing failures? Should we backport it to other branches?
We had problems a few years ago with the hive used in the tests but we haven't seen this recently afaik. At the time, v-wuzhai made a pass over the tests but there were a few more tests that ended up using DotnetCommand since that change. There was an existing tracking bug that never got closed so I just had copilot clean up the rest. We could potentially try to flag it as a failure if you use new with a root command but probably not worth it. |
|
/ba-g templating macos leg has been disabled |
If we have an easy way to add a build check for this, then I think we should do it. I don't think we have an easy way to add custom build checks though. @baronfel? |
Tests using
DotnetCommandfordotnet newoperations were not enforcing ephemeral hive usage, causing intermittent test failures.DotnetNewCommandenforces hive configuration at construction time.Changes
Converted 7 instances across 4 test files:
Microsoft.DotNet.PackageInstall.Tests/EndToEndToolTests.cs(3)dotnet-new.IntegrationTests/DotnetNewInstallTests.cs(2)dotnet.Tests/CommandTests/Project/Convert/DotnetProjectConvertTests.cs(1)dotnet.Tests/CommandTests/Run/RunFileTests.cs(1)Pattern
DotnetNewCommandautomatically prepends "new" and requires explicit hive configuration viaWithVirtualHive(),WithCustomHive(), orWithoutCustomHive()before execution.Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.