Skip to content

test: strengthen weak assert_ne in nested_marker_detection_matches_replacement#1507

Merged
jamesadevine merged 1 commit into
mainfrom
test-reducer/fix-weak-assert-ne-in-path-marker-codemod-202288720e637aab
Jul 15, 2026
Merged

test: strengthen weak assert_ne in nested_marker_detection_matches_replacement#1507
jamesadevine merged 1 commit into
mainfrom
test-reducer/fix-weak-assert-ne-in-path-marker-codemod-202288720e637aab

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Test Suite Reduction: src/compile/codemods/0004_legacy_path_markers.rs

What was wrong

nested_marker_detection_matches_replacement used assert_ne!(result, input) to verify that replace_marker substituted the inner {{ workspace }} marker in the doubly-nested input "{{ bad {{ workspace }} }}". This assertion only checks that the output is different from the input — it would pass even if the replacement happened at the wrong span (e.g. the outer braces were consumed, or an extra character was dropped), as long as the result was something other than the original string.

The actual output of replace_marker is fully deterministic: the outer {{ bad ... }} span does not match because its interior ("bad {{ workspace") is not the marker name, so only the inner {{ workspace }} is replaced, leaving the surrounding braces intact: "{{ bad REPL }}".

Changes

Test Action Reason
nested_marker_detection_matches_replacement Rewritten Replaced assert_ne!(result, input) with assert_eq!(result, "{{ bad REPL }}") — pinpoints the exact replacement boundary and catches regressions where the wrong span is substituted

Verification

  • cargo test: 2569 tests pass ✅
  • cargo clippy --all-targets --all-features: no errors ✅

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • spsprodeus21.vssps.visualstudio.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "spsprodeus21.vssps.visualstudio.com"

See Network Configuration for more information.

Generated by Test Reducer · 182.2 AIC · ⌖ 9.28 AIC · ⊞ 8.7K ·

…placement

The test used assert_ne!(result, input) which only verified the output
differed from the input. Since replace_marker is deterministic, the
expected output is predictable: the outer braces are preserved while
only the inner {{ workspace }} is substituted.

Replace with assert_eq! asserting the exact output "{{ bad REPL }}".
This catches regressions where replacement occurs at the wrong span
(e.g. swallowing the outer braces, or replacing the wrong occurrence).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jamesadevine jamesadevine marked this pull request as ready for review July 15, 2026 09:47
@jamesadevine jamesadevine merged commit 2657ad9 into main Jul 15, 2026
21 checks passed
@jamesadevine jamesadevine deleted the test-reducer/fix-weak-assert-ne-in-path-marker-codemod-202288720e637aab branch July 15, 2026 09:54
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.

1 participant