Fix ValidatePatternBaseDir for wildcard-in-directory-name patterns#55433
Merged
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: ffc47f67-df45-4968-a755-7f30f3d3da22
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
MichaelSimons
marked this pull request as ready for review
July 23, 2026 15:30
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes base-directory validation for glob patterns in EvaluateConditionalTestScopes.cs so patterns with wildcards inside a directory name (e.g. test/dotnet-format.*/**) validate against the nearest real parent directory instead of a partial, non-existent path segment.
Changes:
- Update
ValidatePatternBaseDirto truncate the prefix at the last/before the first wildcard. - Add a unit test covering wildcard-in-directory-name patterns to prevent regressions.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| scripts/EvaluateConditionalTestScopes.cs | Adjusts glob base-directory derivation to avoid validating partial directory segments when wildcards occur mid-segment. |
| test/Microsoft.NET.Infrastructure.Tests/EvaluateConditionalTestScopesTests.cs | Adds a regression test ensuring validation succeeds for test/dotnet-format.*/** when only test/ exists. |
Member
Author
|
/ba-g unrelated intermittent test failure in Microsoft.DotNet.Cli.New.IntegrationTests.DotnetNewSearchTests.CanFilterType |
mthalman
approved these changes
Jul 23, 2026
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.
Summary
ValidatePatternBaseDirinscripts/EvaluateConditionalTestScopes.csderived the base directory of a glob pattern by taking everything before the first wildcard and trimming a trailing/. When a wildcard appears within a path segment (e.g.test/dotnet-format.*/**), this produced a bogus base directory liketest/dotnet-format., which never exists on disk — causing a spurious validation error.This change trims the prefix back to the last complete
/boundary, so the base directory is the nearest real parent segment (testin the example above).Changes
scripts/EvaluateConditionalTestScopes.cs: derive the base directory from the last/before the first wildcard instead of the raw prefix.test/Microsoft.NET.Infrastructure.Tests/EvaluateConditionalTestScopesTests.cs: addValidation_WildcardInDirectoryName_ValidatesParentSegmentcovering atest/dotnet-format.*/**pattern where only the parenttestdirectory exists.Related
This issue was discovered while working on #55399 — this PR is a follow-up fix that came out of that work.