Trim whitespace in MTP --test-modules expressions#54250
Open
Copilot wants to merge 6 commits into
Open
Conversation
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Trim white spaces in --test-modules expression for dotnet test
Trim whitespace in MTP May 11, 2026
--test-modules expressions
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes dotnet test (MTP) --test-modules parsing so semicolon-delimited glob patterns are trimmed per-token before matching, ensuring patterns with surrounding whitespace (including newline/tab) are honored consistently.
Changes:
- Trim each semicolon-separated
--test-modulespattern token and drop empty tokens before passing patterns to the glob matcher. - Add an integration test validating that whitespace/newline/tab around semicolon-delimited patterns still matches all intended test modules.
- Includes an unrelated SARIF formatting/encoding diff that should be reverted (see PR comment).
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTestBasedOnGlobbingFilter.cs | Adds a regression test covering semicolon-delimited --test-modules patterns containing whitespace/newlines/tabs. |
| src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs | Normalizes --test-modules semicolon-separated patterns by trimming tokens and removing empties before glob matching. |
| src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers.sarif | Contains formatting/encoding-only changes unrelated to this PR’s purpose (should be reverted). |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 1
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Bug Fix
What was the bug?
dotnet test(MTP) accepted semicolon-delimited--test-modulesglob expressions, but did not trim surrounding whitespace per segment.As a result, expressions like
"**/*.Platform.mstest.exe; **/*.Modules.mstest.exe"could ignore later patterns, which also impacts folded YAML argument formatting.How did you fix it?
CLI parsing behavior
;→ trim each token → drop empty entries → pass normalized patterns to the glob matcher.Regression coverage
GivenDotnetTestBuildsAndRunsTestBasedOnGlobbingFilterthat passes a whitespace/newline/tab-containing--test-modulesexpression with multiple patterns and verifies both test modules are included in execution.Example
With this change, each pattern is trimmed before glob evaluation, so all intended modules are matched.