test: strengthen weak assert_ne in nested_marker_detection_matches_replacement#1507
Merged
jamesadevine merged 1 commit intoJul 15, 2026
Conversation
…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>
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.
Test Suite Reduction:
src/compile/codemods/0004_legacy_path_markers.rsWhat was wrong
nested_marker_detection_matches_replacementusedassert_ne!(result, input)to verify thatreplace_markersubstituted 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_markeris 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
nested_marker_detection_matches_replacementassert_ne!(result, input)withassert_eq!(result, "{{ bad REPL }}")— pinpoints the exact replacement boundary and catches regressions where the wrong span is substitutedVerification
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.comSee Network Configuration for more information.