Fix TreeNodeFilter OR-pattern diagnostics#7415
Conversation
|
Merged latest Verification:
Ready for CI re-run and review. |
There was a problem hiding this comment.
Pull request overview
This PR clarifies TreeNodeFilter behavior for OR patterns and improves diagnostics when unsupported full-path OR expressions are parenthesized.
Changes:
- Adds regression coverage for single-segment OR patterns and exact-match behavior.
- Updates TreeNodeFilter grammar remarks and propagates filter text into parser error construction.
- Improves the unexpected slash diagnostic for parenthesized full-path OR patterns.
Show a summary per file
| File | Description |
|---|---|
test/UnitTests/Microsoft.Testing.Platform.UnitTests/Requests/TreeNodeFilterTests.cs |
Adds tests for supported OR syntax and unsupported parenthesized full-path OR diagnostics. |
src/Platform/Microsoft.Testing.Platform/Requests/TreeNodeFilter/TreeNodeFilter.cs |
Documents OR syntax limitations and augments the unexpected slash exception message. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
The merge of origin/main into this branch brought in many new resx entries (IsGreaterThan, IsLessThan, IsPositive, IsNegative, IsInRange, Contains*, DoesNotContain*, ContainsSingle, etc.). Regenerated all 13 XLF files via 'dotnet msbuild /t:UpdateXlf' to keep them in sync. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the inline hint diagnostic appended to TreeNodeFilterUnexpectedSlashOperatorErrorMessage into a new PlatformResources entry (TreeNodeFilterUnexpectedSlashOperatorInPathSegmentErrorMessage) so the full message is localized like the surrounding parser diagnostics. XLFs regenerated via UpdateXlf. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Reviewed the outstanding feedback and pushed bc8c8cf. Addressed the remaining actionable Copilot comment by adding the missing Changelog-Platform.md entry, then re-ran .\build.cmd successfully (0 warnings, 0 errors). I did not make further code changes for the older Youssef review because it reads as a discussion note ('Let's discuss offline') rather than concrete change guidance, and I skipped the already-handled localization thread because Evangelink had already replied there. |
…ode-filter # Conflicts: # src/Platform/Microsoft.Testing.Platform/Requests/TreeNodeFilter/TreeNodeFilter.cs
🔍 Build Failure AnalysisSummary — Build failed due to out-of-sync localization files (.xlf) after modifying the FrameworkMessages.resx resource file. Root cause: Localization files (.xlf) out of sync with .resx changesThe PR modifies The XliffTasks validation enforces that all localization files must be perfectly synchronized with the source resource file to prevent translation drift in CI/official builds. Affected files / errors
Resource keys modified in FrameworkMessages.resx:
Proposed fix Run the dotnet build src/TestFramework/TestFramework/TestFramework.csproj /t:UpdateXlfThis will update all 13 localization files:
After running the command, commit the updated Build overviewConfiguration: Debug All MSBuild errors (3)
🤖 Generated by the Build Failure Analysis workflow using binlog analysis · commit 948f3bd
|
Rename ExactMatch_DoesNotMatchAdditionalSuffixUnlessWildcardIsUsed to LiteralSegment_RequiresWildcardToMatchNodesWithAdditionalSuffix and add an explanatory comment so the test documents (not endorses) the surprising behavior reported in issue #7300 where node IDs include suffixes like '()' that literal filter segments don't match. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The earlier 'Sync FrameworkMessages XLF files after merge with main' commit wiped existing translations and marked entries as state="new" because the resx values in this branch were unchanged from main. This PR does not touch FrameworkMessages.resx or AzureDevOpsResources.resx, so their xlf files must match main. Restore them from main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
| { | ||
| InvalidOperationException exception = Assert.ThrowsExactly<InvalidOperationException>( | ||
| () => _ = new TreeNodeFilter("(/*/*/*/MyTest1)|(/*/*/*/MyTest2)")); | ||
|
|
| <trans-unit id="AzureDevOpsFlakyHistoryRequiresAzureDevOps"> | ||
| <source>'--report-azdo-flaky-history' requires '--report-azdo' to be enabled</source> | ||
| <target state="new">'--report-azdo-flaky-history' requires '--report-azdo' to be enabled</target> | ||
| <target state="translated">Aby bylo možné použít parametr ---report-azdo-flaky-history, musí být povolený parametr --report-azdo.</target> |
| <trans-unit id="OptionDescription"> | ||
| <source>Enable Azure DevOps report generator to write errors to the output in a way that Azure DevOps understands.</source> | ||
| <target state="new">Enable Azure DevOps report generator to write errors to the output in a way that Azure DevOps understands.</target> | ||
| <target state="translated">Umožňuje generátoru sestav Azure DevOps zapisovat chyby do výstupu způsobem, který je pro AzureDev Ops srozumitelný.</target> |
Description
Partially addresses (does not fully fix) #7300. That issue reports four broken
--treenode-filterpatterns; this PR only improves the diagnostics and documentation for one of them and clarifies a known matching limitation that affects the other three.Symptoms reported in #7300
/*/*/*/(MyTest1)MyTest1/*/*/*/(MyTest1)|(MyTest2)/*/*/*/(MyTest1|MyTest2)(/*/*/*/MyTest1)|(/*/*/*/MyTest2)InvalidOperationExceptionAnalysis
(MyTest1)and(MyTest1\|MyTest2)do match a node whose final segment is exactlyMyTest1(see the newOrExpression_WorksForSinglePathSegmentInsideParenthesestest). Path segments are matched against an anchored regex^value$, so a literalMyTest1will not match a node whose actual ID isMyTest1()(or anything else with extra suffix). TUnit appends method-signature info to the displayed name, so the node IDs the user is actually filtering against are most likelyMyTest1(),MyTest2(), etc. — which is why every pattern with a wildcard likeMyTest1*"works" while every literal one does not. This is a UX mismatch (display vs. node ID), not a TreeNodeFilter parser defect. Properly resolving it requires either action in TUnit's adapter (use stable IDs that match the displayed name) or a design change to relax literal-segment matching — both are out of scope here.(/A/B/C/X)\|(/A/B/C/Y)hits separator processing inside parentheses and throws a genericInvalidOperationExceptionwith no guidance. This PR replaces that with an actionable message that points the user to the supported form/A/B/C/(X|Y).Changes
TreeNodeFilter.cs: thread the filter string intoProcessStackOperatorso the "unexpected/inside parenthesized expression" error can include the filter and a suggested fix. Add grammar remarks noting that OR over a single path segment is supported but OR over full paths is not.PlatformResources.resx(+ all xlf): newTreeNodeFilterUnexpectedSlashOperatorInPathSegmentErrorMessageresource (the previous one is preserved for back-compat; tests use the new message).TreeNodeFilterTests.cs: regression tests for single-segment OR (OrExpression_WorksForSinglePathSegmentInsideParentheses), for the actionable error on full-path OR (FullPathOrInsideParenthesizedExpressions_IsNotSupported_ThrowsActionableMessage), andLiteralSegment_RequiresWildcardToMatchNodesWithAdditionalSuffixwhich documents (with a comment) the surprising literal-vs-suffix limitation behind cases 1–3.Changelog-Platform.md: entry framed as a diagnostics/docs clarification, not a behavior fix.Validation
dotnet test Microsoft.Testing.Platform.UnitTests.csproj -c Debug --filter "FullyQualifiedName~TreeNodeFilterTests"→ 46/46 passing on net9.0/net8.0/net462.Follow-ups (not in this PR)