Skip to content

Trim whitespace in MTP --test-modules expressions#54250

Open
Copilot wants to merge 6 commits into
mainfrom
copilot/trim-white-spaces-test-modules
Open

Trim whitespace in MTP --test-modules expressions#54250
Copilot wants to merge 6 commits into
mainfrom
copilot/trim-white-spaces-test-modules

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 11, 2026

Bug Fix

What was the bug?

dotnet test (MTP) accepted semicolon-delimited --test-modules glob 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

    • Updated MTP module-pattern parsing to normalize each semicolon-separated token before matching.
    • Current flow: split on ; → trim each token → drop empty entries → pass normalized patterns to the glob matcher.
  • Regression coverage

    • Added an integration test in GivenDotnetTestBuildsAndRunsTestBasedOnGlobbingFilter that passes a whitespace/newline/tab-containing --test-modules expression with multiple patterns and verifies both test modules are included in execution.

Example

dotnet test --test-modules "**/*.ModuleA.mstest.exe;
  **/*.ModuleB.mstest.exe;
	**/*.ModuleC.mstest.exe"

With this change, each pattern is trimmed before glob evaluation, so all intended modules are matched.

Copilot AI and others added 3 commits May 11, 2026 15:17
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 --test-modules expressions May 11, 2026
Copilot AI requested a review from Evangelink May 11, 2026 15:23
@Evangelink Evangelink marked this pull request as ready for review May 11, 2026 20:52
Copilot AI review requested due to automatic review settings May 11, 2026 20:52
@Evangelink Evangelink requested review from a team as code owners May 11, 2026 20:52
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

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-modules pattern 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>
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.

Trim white spaces in --test-modules expression when running dotnet test (MTP) CLI command

3 participants