review: test: Fixed nondeterministic failures in SubstitutionTest.testCreateTypeFromTemplate()#6501
Merged
monperrus merged 2 commits intoINRIA:masterfrom Nov 8, 2025
Conversation
Collaborator
|
Thanks a lot @yonghanlin We like short PRs to improve tests. Tip: avoid opening many PRs at once, it's easily overwhelming for maintainers. Prefer opening them one by one, one after the other, once the previous one has been merged. |
Contributor
Author
|
@monperrus Thank you for the review and suggestion! |
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.
What does this PR do?
This PR draws inspiration from the earlier PR #6084, which has not seen recent activity. The fix has been re-implemented on the current codebase and updated accordingly. In particular, this PR fixes a nondeterministic test failure in
SubstitutionTest.testCreateTypeFromTemplate()when running with NonDex.Problem
NonDex exposes that the generation of enum constants inside
createTypeFromTemplatedoes not guarantee a fixed iteration order. During type construction, enum values are collected and inserted using data structures whose traversal order is unspecified (e.g.,HashMap). As a result, the produced enum may list its values asGOOD, BETTERin one run andBETTER, GOODin another. The test assumed a strict positional order of enum constants, even though the underlying creation process does not enforce such ordering. This causes failures under certain NonDex seeds.Reproduce Test
To reproduce the failure, run NonDex on
.module using the following commands:The Fix
The assertion in
testCreateTypeFromTemplateis updated to extract the enum value names, sort them, and then assert against the canonical list["BETTER", "GOOD"]. This verifies correctness by content, not by insertion order.