Skip to content

Commit 59c796e

Browse files
committed
clarify things
1 parent 094e20e commit 59c796e

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

tests/scripts/end_to_end_test_utilities.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ class TestConfig:
2727
# Make file_path optional when trace_mode is True
2828
file_path: Optional[pathlib.Path] = None
2929
function_name: Optional[str] = None
30-
expected_unit_tests: Optional[int] = None
30+
# Global count: "Discovered X existing unit tests and Y replay tests in Z.Zs at /path"
31+
expected_unit_tests_count: Optional[int] = None
32+
# Per-function count: "Discovered X existing unit test files, Y replay test files, and Z concolic..."
33+
expected_unit_test_files: Optional[int] = None
3134
min_improvement_x: float = 0.1
3235
trace_mode: bool = False
3336
coverage_expectations: list[CoverageExpectation] = field(default_factory=list)
@@ -182,17 +185,30 @@ def validate_output(stdout: str, return_code: int, expected_improvement_pct: int
182185
logging.error(f"Performance improvement rate {improvement_x}x not above {config.min_improvement_x}x")
183186
return False
184187

185-
if config.expected_unit_tests is not None:
188+
if config.expected_unit_tests_count is not None:
186189
# Match the global test discovery message from optimizer.py which counts test invocations
187190
# Format: "Discovered X existing unit tests and Y replay tests in Z.Zs at /path/to/tests"
188191
unit_test_match = re.search(r"Discovered (\d+) existing unit tests? and \d+ replay tests? in [\d.]+s at", stdout)
189192
if not unit_test_match:
190-
logging.error("Could not find unit test count")
193+
logging.error("Could not find global unit test count")
191194
return False
192195

193196
num_tests = int(unit_test_match.group(1))
194-
if num_tests != config.expected_unit_tests:
195-
logging.error(f"Expected {config.expected_unit_tests} unit tests, found {num_tests}")
197+
if num_tests != config.expected_unit_tests_count:
198+
logging.error(f"Expected {config.expected_unit_tests_count} global unit tests, found {num_tests}")
199+
return False
200+
201+
if config.expected_unit_test_files is not None:
202+
# Match the per-function test discovery message from function_optimizer.py
203+
# Format: "Discovered X existing unit test files, Y replay test files, and Z concolic..."
204+
unit_test_files_match = re.search(r"Discovered (\d+) existing unit test files?", stdout)
205+
if not unit_test_files_match:
206+
logging.error("Could not find per-function unit test file count")
207+
return False
208+
209+
num_test_files = int(unit_test_files_match.group(1))
210+
if num_test_files != config.expected_unit_test_files:
211+
logging.error(f"Expected {config.expected_unit_test_files} unit test files, found {num_test_files}")
196212
return False
197213

198214
if config.coverage_expectations:

0 commit comments

Comments
 (0)