Skip to content

Fix ValidatePatternBaseDir for wildcard-in-directory-name patterns#55433

Merged
MichaelSimons merged 1 commit into
mainfrom
michaelsimons-fix-wildcard-dirname-validator
Jul 23, 2026
Merged

Fix ValidatePatternBaseDir for wildcard-in-directory-name patterns#55433
MichaelSimons merged 1 commit into
mainfrom
michaelsimons-fix-wildcard-dirname-validator

Conversation

@MichaelSimons

@MichaelSimons MichaelSimons commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

ValidatePatternBaseDir in scripts/EvaluateConditionalTestScopes.cs derived 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 like test/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 (test in 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: add Validation_WildcardInDirectoryName_ValidatesParentSegment covering a test/dotnet-format.*/** pattern where only the parent test directory exists.

Related

This issue was discovered while working on #55399 — this PR is a follow-up fix that came out of that work.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: ffc47f67-df45-4968-a755-7f30f3d3da22
@azure-pipelines

Copy link
Copy Markdown
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
MichaelSimons marked this pull request as ready for review July 23, 2026 15:30
@azure-pipelines

Copy link
Copy Markdown
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ValidatePatternBaseDir to 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.

@MichaelSimons

Copy link
Copy Markdown
Member Author

/ba-g unrelated intermittent test failure in Microsoft.DotNet.Cli.New.IntegrationTests.DotnetNewSearchTests.CanFilterType

@MichaelSimons
MichaelSimons merged commit d9d7ec4 into main Jul 23, 2026
29 of 31 checks passed
@MichaelSimons
MichaelSimons deleted the michaelsimons-fix-wildcard-dirname-validator branch July 23, 2026 20:43
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.

3 participants