Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions codeflash/code_utils/code_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ def exit_with_message(message: str, *, error_on_exit: bool = False) -> None:
sys.exit(1 if error_on_exit else 0)


def shorten_pytest_error(pytest_error_string: str) -> str:
return "\n".join(re.findall(r"^[E>] +(.*)$", pytest_error_string, re.MULTILINE))
Comment on lines +365 to +366
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

codeflash will optimize this away or should've



def extract_unique_errors(pytest_output: str) -> set[str]:
unique_errors = set()

Expand Down
20 changes: 20 additions & 0 deletions codeflash/verification/equivalence.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from __future__ import annotations

import reprlib
import sys
from typing import TYPE_CHECKING

from codeflash.cli_cmds.console import logger
from codeflash.code_utils.code_utils import shorten_pytest_error
from codeflash.models.models import TestDiff, TestDiffScope, TestResults, TestType, VerificationType
from codeflash.verification.comparator import comparator

Expand Down Expand Up @@ -57,11 +59,29 @@ def compare_test_results(original_results: TestResults, candidate_results: TestR
if candidate_test_failures
else ""
)
if cdd_pytest_error:
cdd_pytest_error = shorten_pytest_error(cdd_pytest_error)
original_pytest_error = (
original_test_failures.get(original_test_result.id.test_fn_qualified_name(), "")
if original_test_failures
else ""
)
if original_pytest_error:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe change the var name? it's no longer the original pytest error if it's been shortened

original_pytest_error = shorten_pytest_error(original_pytest_error)
test_src_code = original_test_result.id.get_src_code(original_test_result.file_name)
test_diff = TestDiff(
scope=TestDiffScope.RETURN_VALUE,
original_value=reprlib.repr(original_test_result.return_value),
candidate_value=reprlib.repr(cdd_test_result.return_value),
test_src_code=test_src_code,
candidate_pytest_error=cdd_pytest_error,
original_pass=original_test_result.did_pass,
candidate_pass=cdd_test_result.did_pass,
original_pytest_error=original_pytest_error,
)
if not comparator(original_test_result.return_value, cdd_test_result.return_value, superset_obj=superset_obj):
test_diff.scope = TestDiffScope.RETURN_VALUE
test_diffs.append(test_diff)

if not comparator(original_test_result.return_value, cdd_test_result.return_value, superset_obj=superset_obj):
test_diffs.append(
Expand Down
Loading