Skip to content

[MTP dotnet test]: Allow specifying project, solution, directory, or test modules as positional argument#53004

Merged
Evangelink merged 4 commits intorelease/10.0.3xxfrom
dev/ygerges/positional-arg-backport-3xx
Mar 6, 2026
Merged

[MTP dotnet test]: Allow specifying project, solution, directory, or test modules as positional argument#53004
Evangelink merged 4 commits intorelease/10.0.3xxfrom
dev/ygerges/positional-arg-backport-3xx

Conversation

@Youssef1313
Copy link
Member

@Youssef1313 Youssef1313 commented Feb 12, 2026

Manual backport of #52449 to 10.0.3xx

Closes #52636

Copilot AI review requested due to automatic review settings February 12, 2026 08:38
Copy link
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

Backports behavior to the Microsoft.Testing.Platform (MTP) dotnet test command so a project, solution/solution filter, directory, or test modules can be provided as a positional argument (similar to prior VSTest behavior), while still keeping validation for ambiguous/incorrect usage.

Changes:

  • Adds parsing of the first unmatched token as a positional “path/test-modules” input and forwards remaining unmatched tokens to the test application.
  • Updates mutual-exclusion/validation logic to work off computed PathOptions (including the new TestModules field).
  • Expands/adjusts tests to cover positional .slnf and to ensure helpful validation errors still appear for non-first path-like tokens.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
test/dotnet.Tests/CommandTests/Test/TestCommandValidationTests.cs Updates validation tests to keep path-like tokens from being the first unmatched token.
test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTestsWithDifferentOptions.cs Adds test coverage for solution filter (.slnf) as the first positional token.
src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs Refactors option mutual-exclusion/irrelevant-option validation to use PathOptions.TestModules.
src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs Adjusts handler signature to accept test-modules value from computed build/path options.
src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs Switches forwarded args from UnmatchedTokens to TestApplicationArguments.
src/Cli/dotnet/Commands/Test/MTP/Options.cs Extends PathOptions to include TestModules and renames forwarded-args list in BuildOptions.
src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs Uses computed build options earlier and routes into test-modules mode based on PathOptions.TestModules.
src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs Implements positional-argument extraction and updates build option construction accordingly.

@Youssef1313 Youssef1313 force-pushed the dev/ygerges/positional-arg-backport-3xx branch 5 times, most recently from fb0a2f0 to da31109 Compare February 12, 2026 11:14
@Youssef1313 Youssef1313 force-pushed the dev/ygerges/positional-arg-backport-3xx branch from 566158c to 7605d6f Compare February 12, 2026 11:15
Copy link
Member

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

Review Summary

This is a manual backport of #52449 to release/10.0.3xx. The adaptation to the branch's command definition API looks correct in most places, but there are a few issues:

High severity

  • Directory positional argument is misclassified as positionalTestModules instead of positionalProjectOrSolution, which will cause runtime failures when users pass a directory as a positional argument (the test-modules glob matcher won't find anything and will produce a confusing "no test modules found" error). This bug is also present in the original PR on main.
  • Missing parentheses in the ||/&& condition — works by accident due to precedence but inconsistent and fragile.

Medium severity

  • Dead variable filterModeEnabled left behind in MicrosoftTestingPlatformTestCommand.cs.
  • Missing test coverage for .csproj, .sln, .slnx, directory, and .dll/.exe as positional arguments, and for the option+positional conflict error.

Low severity

  • Extra blank line between methods in MSBuildUtility.cs.

@Evangelink Evangelink enabled auto-merge March 6, 2026 13:49
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.

3 participants