Refactor: Java comparator result handling into focused helpers#2076
Refactor: Java comparator result handling into focused helpers#2076shreejaykurhade wants to merge 2 commits intocodeflash-ai:mainfrom
Conversation
|
@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 |
|
Hey @shreejaykurhade — thanks for your patience. I've set up a structured plan for improving test coverage across the repo: #2079 I'd suggest closing these two refactor PRs for now and focusing on coverage instead — it's higher priority and gives you clear targets to hit. |
|
A couple of process updates: Reviews: We've set up CODEOWNERS, so you don't need to tag anyone for reviews — the right people will be requested automatically based on which files your PR touches. New policy: Going forward, every PR needs to link an issue or discussion ( |
|
Closing in favor of test coverage work — see #2079 for issues to pick up. Thanks for the contribution! |
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.