Skip to content

Commit b6af185

Browse files
committed
fix: split discovery and instrumentation log messages for E2E harnesses
Log "Discovered N existing unit test files" after counting tests, and "Instrumented N existing unit test files" after injecting profiling. Python E2E harness matches "Discovered", JS harness matches "Instrumented".
1 parent 6f2939a commit b6af185

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

codeflash/optimization/function_optimizer.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,18 @@ def instrument_existing_tests(self, function_to_all_tests: dict[str, set[Functio
16251625
msg = f"Unexpected test type: {test_type}"
16261626
raise ValueError(msg)
16271627

1628+
if existing_test_files_count > 0 or replay_test_files_count > 0 or concolic_coverage_test_files_count > 0:
1629+
logger.info(
1630+
f"Discovered {existing_test_files_count} existing unit test file"
1631+
f"{'s' if existing_test_files_count != 1 else ''}, {replay_test_files_count} replay test file"
1632+
f"{'s' if replay_test_files_count != 1 else ''}, and "
1633+
f"{concolic_coverage_test_files_count} concolic coverage test file"
1634+
f"{'s' if concolic_coverage_test_files_count != 1 else ''} for {func_qualname}"
1635+
)
1636+
console.rule()
1637+
1638+
for (test_file, test_type), tests_in_file_list in test_file_invocation_positions.items():
1639+
path_obj_test_file = Path(test_file)
16281640
# Use language-specific instrumentation
16291641
success, injected_behavior_test = self.language_support.instrument_existing_test(
16301642
test_path=path_obj_test_file,
@@ -1696,13 +1708,11 @@ def get_instrumented_path(original_path: str, suffix: str) -> Path:
16961708
)
16971709
)
16981710

1699-
if existing_test_files_count > 0 or replay_test_files_count > 0 or concolic_coverage_test_files_count > 0:
1711+
instrumented_count = len(unique_instrumented_test_files) // 2 # each test produces behavior + perf files
1712+
if instrumented_count > 0:
17001713
logger.info(
1701-
f"Discovered {existing_test_files_count} existing unit test file"
1702-
f"{'s' if existing_test_files_count != 1 else ''}, {replay_test_files_count} replay test file"
1703-
f"{'s' if replay_test_files_count != 1 else ''}, and "
1704-
f"{concolic_coverage_test_files_count} concolic coverage test file"
1705-
f"{'s' if concolic_coverage_test_files_count != 1 else ''} for {func_qualname}"
1714+
f"Instrumented {instrumented_count} existing unit test file"
1715+
f"{'s' if instrumented_count != 1 else ''} for {func_qualname}"
17061716
)
17071717
console.rule()
17081718
return unique_instrumented_test_files

tests/scripts/end_to_end_test_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def validate_output(stdout: str, return_code: int, expected_improvement_pct: int
220220
return False
221221

222222
if config.expected_unit_test_files is not None:
223-
# Match the per-function test discovery message from function_optimizer.py
223+
# Match the per-function discovery message from function_optimizer.py
224224
# Format: "Discovered X existing unit test files, Y replay test files, and Z concolic..."
225225
unit_test_files_match = re.search(r"Discovered (\d+) existing unit test files?", stdout)
226226
if not unit_test_files_match:

0 commit comments

Comments
 (0)