fix: deduplicate test function names in render_test_plan#938
Merged
Conversation
When multiple branches produce identical slugified conditions (e.g. two 'None => return false' match arms), the test generator now appends numeric suffixes (_2, _3, ...) instead of producing duplicate function names that prevent compilation. Tracks seen names in a HashMap during rendering and only appends a suffix when a name has been used before. Includes a unit test with 3 identical names verifying the suffix behavior.
Contributor
Homeboy Results —
|
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
Fixes duplicate test function names that break compilation in auto-generated tests (#818).
Problem
When a function has multiple branches with identical slugified conditions (e.g., two
None => return falsematch arms), the test generator produces duplicatefn test_foo_none_return_false()definitions. Rust compilation fails:This is one of the bugs causing the pre-existing
cargo testcompilation failures inversion_overrides.rs.Fix
render_test_plannow tracks seen test names in aHashMap. When a duplicate is detected, it appends a numeric suffix (_2,_3, etc.):Test
Added
test_render_test_plan_deduplicates_identical_names— 3 cases with identical names, verifies suffix behavior.