[MTP dotnet test]: Allow specifying project, solution, directory, or test modules as positional argument#52449
Conversation
0dddf98 to
74b4ee0
Compare
74b4ee0 to
0786567
Compare
There was a problem hiding this comment.
Pull request overview
This PR changes the dotnet test command for Microsoft Testing Platform (MTP) to allow specifying projects, solutions, directories, or test modules as positional arguments (without requiring explicit switches like --project, --solution, or --test-modules), matching the behavior that existed in VSTest. The change only considers the first unmatched token to limit impact.
Changes:
- Moved validation logic from
ValidationUtility.cstoMSBuildUtility.csand enhanced it to handle positional arguments - Added positional argument parsing in
GetPositionalArguments()that detects file types and treats the first matching token as a positional argument - Updated
PathOptionsrecord to includeTestModulesfield and renamedUnmatchedTokenstoTestApplicationArgumentsinBuildOptions
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| MSBuildUtility.cs | Added GetPositionalArguments() and ValidatePathOptions() to parse and validate positional arguments for projects, solutions, and test modules |
| ValidationUtility.cs | Removed ValidateSolutionOrProjectOrDirectoryOrModulesArePassedCorrectly() and simplified ValidateMutuallyExclusiveOptions() to work with parsed path options |
| Options.cs | Added TestModules field to PathOptions and renamed UnmatchedTokens to TestApplicationArguments in BuildOptions for clarity |
| MicrosoftTestingPlatformTestCommand.cs | Reordered operations to parse build options before validation and updated condition to check PathOptions.TestModules |
| TestModulesFilterHandler.cs | Changed method signature to accept testModules string parameter instead of extracting it from ParseResult |
| TestApplication.cs | Updated to use renamed TestApplicationArguments field instead of UnmatchedTokens |
0786567 to
4187d5a
Compare
…test modules as positional argument
4187d5a to
3ccebc5
Compare
|
/backport to release/10.0.2xx |
|
Started backporting to |
|
@Youssef1313 backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: [MTP dotnet test]Allow specifying project, solution, directory, or test modules as positional argument
Using index info to reconstruct a base tree...
M src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
M src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
M src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
M src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
M src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 [MTP dotnet test]Allow specifying project, solution, directory, or test modules as positional argument
Error: The process '/usr/bin/git' failed with exit code 128 |
|
/backport to release/10.0.3xx |
|
Started backporting to |
|
@Youssef1313 backporting to git am output$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: [MTP dotnet test]Allow specifying project, solution, directory, or test modules as positional argument
Using index info to reconstruct a base tree...
M src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
M src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
M src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
M src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
M src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MSBuildUtility.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/MicrosoftTestingPlatformTestCommand.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/TestApplication.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs
Auto-merging src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Commands/Test/MTP/ValidationUtility.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 [MTP dotnet test]Allow specifying project, solution, directory, or test modules as positional argument
Error: The process '/usr/bin/git' failed with exit code 128 |
…test modules as positional argument (#52449)
…test modules as positional argument (#52449)
…test modules as positional argument (#52449)
…test modules as positional argument (#52449)
…test modules as positional argument (#52449)
…test modules as positional argument (#52449)
…test modules as positional argument (#52449)
This brings back the same behavior that was with VSTest, where we don't require
--projectand similar options for specifying what to test.To limit the impact of this change, we only consider the first unmatched token.
This helps AI agents that always get confused and call MTP incorrectly.