Skip to content

Commit ba04f88

Browse files
authored
Merge branch 'main' into feat/hypothesis-tests
2 parents 01a189a + b9d5f16 commit ba04f88

File tree

11 files changed

+275
-155
lines changed

11 files changed

+275
-155
lines changed

codeflash-benchmark/codeflash_benchmark/plugin.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ def pytest_addoption(parser: pytest.Parser) -> None:
5252
parser.addoption(
5353
"--codeflash-trace", action="store_true", default=False, help="Enable CodeFlash tracing for benchmarks"
5454
)
55-
# These options are ignored when --codeflash-trace is used
56-
for option, action, default, help_text in benchmark_options:
57-
help_suffix = " (ignored when --codeflash-trace is used)"
58-
parser.addoption(option, action=action, default=default, help=help_text + help_suffix)
55+
# Only add benchmark options if pytest-benchmark is not installed for backward compatibility with existing pytest-benchmark setup
56+
if not PYTEST_BENCHMARK_INSTALLED:
57+
for option, action, default, help_text in benchmark_options:
58+
help_suffix = " (ignored when --codeflash-trace is used)"
59+
parser.addoption(option, action=action, default=default, help=help_text + help_suffix)
5960

6061

6162
@pytest.fixture

codeflash/cli_cmds/console.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,16 @@ def paneled_text(
8080
console.print(panel)
8181

8282

83-
def code_print(code_str: str, file_name: Optional[str] = None, function_name: Optional[str] = None) -> None:
83+
def code_print(
84+
code_str: str,
85+
file_name: Optional[str] = None,
86+
function_name: Optional[str] = None,
87+
lsp_message_id: Optional[str] = None,
88+
) -> None:
8489
if is_LSP_enabled():
85-
lsp_log(LspCodeMessage(code=code_str, file_name=file_name, function_name=function_name))
90+
lsp_log(
91+
LspCodeMessage(code=code_str, file_name=file_name, function_name=function_name, message_id=lsp_message_id)
92+
)
8693
return
8794
"""Print code with syntax highlighting."""
8895
from rich.syntax import Syntax

codeflash/code_utils/code_utils.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,3 +360,19 @@ def exit_with_message(message: str, *, error_on_exit: bool = False) -> None:
360360
paneled_text(message, panel_args={"style": "red"})
361361

362362
sys.exit(1 if error_on_exit else 0)
363+
364+
365+
def extract_unique_errors(pytest_output: str) -> set[str]:
366+
unique_errors = set()
367+
368+
# Regex pattern to match error lines:
369+
# - Start with 'E' followed by optional whitespace
370+
# - Capture the actual error message
371+
pattern = r"^E\s+(.*)$"
372+
373+
for error_message in re.findall(pattern, pytest_output, re.MULTILINE):
374+
error_message = error_message.strip() # noqa: PLW2901
375+
if error_message:
376+
unique_errors.add(error_message)
377+
378+
return unique_errors

0 commit comments

Comments
 (0)