Add exclusion pattern support to --test-modules glob expressions#54252
Open
Copilot wants to merge 8 commits into
Open
Add exclusion pattern support to --test-modules glob expressions#54252Copilot wants to merge 8 commits into
--test-modules glob expressions#54252Copilot wants to merge 8 commits into
Conversation
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
…(MTP) CLI Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add support for exclusion patterns in --test-modules for dotnet test
Add exclusion pattern support to May 11, 2026
--test-modules glob expressions
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for !-prefixed exclusion patterns in dotnet test --test-modules glob expressions (MTP path filtering), aligning behavior with common globbing semantics and enabling “include broad, then exclude specific” scenarios.
Changes:
- Update
TestModulesFilterHandler.GetMatchedModulePathsto parse;-separated patterns as includes vs excludes (leading!) and trim whitespace. - Add implicit include (
"**") when only exclusion patterns are provided. - Add an integration test validating combined include+exclude module filtering.
Show a summary per file
| File | Description |
|---|---|
| test/dotnet.Tests/CommandTests/Test/GivenDotnetTestBuildsAndRunsTestBasedOnGlobbingFilter.cs | Adds a test that validates include+exclude behavior for --test-modules. |
| src/Cli/dotnet/Commands/Test/MTP/TestModulesFilterHandler.cs | Implements parsing and matching logic for exclusion patterns and exclusion-only expressions. |
| src/Microsoft.CodeAnalysis.NetAnalyzers/src/Microsoft.CodeAnalysis.NetAnalyzers.sarif | Appears to change only file encoding/format (BOM/whitespace), unrelated to the feature. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 2
Member
|
@copilot address review comments |
…s as internal Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Contributor
Author
Addressed both review comments:
All 6 tests pass. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Evangelink <11340282+Evangelink@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.
New Feature
What does this feature do?
--test-modulesnow supports!-prefixed exclusion patterns in the semicolon-separated glob expression, consistent with VSTest behavior. Patterns with and without!can be freely mixed:Why is this feature needed?
Previously all patterns were treated as includes only, making it impossible to exclude specific assemblies from a broad glob match without listing every desired assembly explicitly.
Implementation details
TestModulesFilterHandler.GetMatchedModulePaths: Each;-separated token is now trimmed of surrounding whitespace, then routed to eitherMatcher.AddExclude(if prefixed with!, stripping the prefix and any trailing whitespace) orMatcher.AddInclude.**is implicitly added as an include so the result is "all files minus excluded."RunTestProjectsWithIncludeAndExcludeFilterOfDll_ShouldReturnExitCodeSuccess— builds two test projects, runs with a combined include+exclude filter that drops the failing project, and asserts only the passing project executed.