Refactor: Java comparator result handling into focused helpers#2076
Open
shreejaykurhade wants to merge 2 commits intocodeflash-ai:mainfrom
Open
Refactor: Java comparator result handling into focused helpers#2076shreejaykurhade wants to merge 2 commits intocodeflash-ai:mainfrom
shreejaykurhade wants to merge 2 commits intocodeflash-ai:mainfrom
Conversation
Author
Collaborator
|
@shreejaykurhade hi, thanks for the PRs, can you hold off on future PRs? let me come up with issues and context so that you're better able to help us |
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.
This PR refactors compare_test_results in codeflash/languages/java/comparator.py to reduce local complexity without changing comparison behavior. Issue #526
The original function handled several responsibilities in one place:
That made the function harder to review and harder to modify safely, especially in a path that mixes subprocess failure handling with result translation.
What Changed
The result-handling portion of compare_test_results is now split into focused private helpers:
_parse_comparator_output
Validates stdout, parses the JSON payload, and preserves the existing stderr/debug logging behavior.
_build_test_diffs
Converts the Java comparator’s diff payload into TestDiff objects and keeps the per-diff debug logging in one place.
_finalize_comparison_result
Applies the final summary validation (actualComparisons, skipped placeholder/deserialization counts) and centralizes the final equivalence logging.
compare_test_results now acts as the orchestration layer for:
Why This Is Better
This improves maintainability by:
This is intended to be a behavior-preserving refactor, not a comparison-logic change.
Behavior / Compatibility
No comparison behavior is intended to change.
In particular, this refactor preserves:
Validation
Results:
Risk
Low.
This is a structural refactor in a well-covered module with dedicated Java comparator tests already in place. The refactor preserves the original execution order and error handling while only extracting cohesive result-processing steps.