Skip to content

Commit 7e4ecb3

Browse files
committed
add debugs
1 parent 60b356c commit 7e4ecb3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

codeflash/verification/equivalence.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import difflib
12
import sys
23

34
from codeflash.cli_cmds.console import logger
@@ -10,6 +11,7 @@
1011
def compare_test_results(original_results: TestResults, candidate_results: TestResults) -> bool:
1112
# This is meant to be only called with test results for the first loop index
1213
if len(original_results) == 0 or len(candidate_results) == 0:
14+
logger.debug("One of the test results is empty, cannot compare.")
1315
return False # empty test results are not equal
1416
original_recursion_limit = sys.getrecursionlimit()
1517
if original_recursion_limit < INCREASED_RECURSION_LIMIT:
@@ -33,6 +35,7 @@ def compare_test_results(original_results: TestResults, candidate_results: TestR
3335
continue
3436
if original_test_result is None or cdd_test_result is None:
3537
are_equal = False
38+
logger.debug("one of the test results is missing")
3639
break
3740
did_all_timeout = did_all_timeout and original_test_result.timed_out
3841
if original_test_result.timed_out:
@@ -67,6 +70,18 @@ def compare_test_results(original_results: TestResults, candidate_results: TestR
6770
if (original_test_result.stdout and cdd_test_result.stdout) and not comparator(
6871
original_test_result.stdout, cdd_test_result.stdout
6972
):
73+
diff_lines = list(
74+
difflib.unified_diff(
75+
original_test_result.stdout.splitlines(keepends=True),
76+
cdd_test_result.stdout.splitlines(keepends=True),
77+
fromfile="original_stdout",
78+
tofile="candidate_stdout",
79+
lineterm="",
80+
)
81+
)
82+
diff_output = "".join(diff_lines) if diff_lines else "No diff available"
83+
84+
logger.debug("Test ID %s has different stdout.\nDiff:\n%s", test_id, diff_output)
7085
are_equal = False
7186
break
7287

@@ -76,9 +91,16 @@ def compare_test_results(original_results: TestResults, candidate_results: TestR
7691
TestType.GENERATED_REGRESSION,
7792
TestType.REPLAY_TEST,
7893
} and (cdd_test_result.did_pass != original_test_result.did_pass):
94+
logger.debug(
95+
"Test ID %s has different pass/fail status.\nOriginal did_pass: %s\nCandidate did_pass: %s",
96+
test_id,
97+
original_test_result.did_pass,
98+
cdd_test_result.did_pass,
99+
)
79100
are_equal = False
80101
break
81102
sys.setrecursionlimit(original_recursion_limit)
82103
if did_all_timeout:
104+
logger.debug("All tests timed out in the original results, cannot compare.")
83105
return False
84106
return are_equal

0 commit comments

Comments
 (0)