Skip to content

Commit dbdfa78

Browse files
Merge branch 'main' of github.com:codeflash-ai/codeflash into fix/git-remote
2 parents ac2f35e + c288419 commit dbdfa78

File tree

11 files changed

+1246
-1046
lines changed

11 files changed

+1246
-1046
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,7 @@ def install_github_app() -> None:
981981
)
982982
click.launch("https://github.com/apps/codeflash-ai/installations/select_target")
983983
click.prompt(
984-
f"Press Enter once you've finished installing the github app from https://github.com/apps/codeflash-ai/installations/select_target{LF}",
984+
f"Press Enter once you've finished installing the github app from https://github.com/apps/codeflash-ai/installations/select_target{LF}",
985985
default="",
986986
type=click.STRING,
987987
prompt_suffix="",

codeflash/discovery/discover_unit_tests.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def discover_unit_tests(
341341
cfg: TestConfig,
342342
discover_only_these_tests: list[Path] | None = None,
343343
file_to_funcs_to_optimize: dict[Path, list[FunctionToOptimize]] | None = None,
344-
) -> tuple[dict[str, set[FunctionCalledInTest]], int]:
344+
) -> tuple[dict[str, set[FunctionCalledInTest]], int, int]:
345345
framework_strategies: dict[str, Callable] = {"pytest": discover_tests_pytest, "unittest": discover_tests_unittest}
346346
strategy = framework_strategies.get(cfg.test_framework, None)
347347
if not strategy:
@@ -352,8 +352,10 @@ def discover_unit_tests(
352352
functions_to_optimize = None
353353
if file_to_funcs_to_optimize:
354354
functions_to_optimize = [func for funcs_list in file_to_funcs_to_optimize.values() for func in funcs_list]
355-
function_to_tests, num_discovered_tests = strategy(cfg, discover_only_these_tests, functions_to_optimize)
356-
return function_to_tests, num_discovered_tests
355+
function_to_tests, num_discovered_tests, num_discovered_replay_tests = strategy(
356+
cfg, discover_only_these_tests, functions_to_optimize
357+
)
358+
return function_to_tests, num_discovered_tests, num_discovered_replay_tests
357359

358360

359361
def discover_tests_pytest(
@@ -515,6 +517,7 @@ def process_test_files(
515517

516518
function_to_test_map = defaultdict(set)
517519
num_discovered_tests = 0
520+
num_discovered_replay_tests = 0
518521
jedi_project = jedi.Project(path=project_root_path)
519522

520523
with test_files_progress_bar(total=len(file_to_test_map), description="Processing test files") as (
@@ -661,11 +664,14 @@ def process_test_files(
661664
position=CodePosition(line_no=name.line, col_no=name.column),
662665
)
663666
)
667+
if test_func.test_type == TestType.REPLAY_TEST:
668+
num_discovered_replay_tests += 1
669+
664670
num_discovered_tests += 1
665671
except Exception as e:
666672
logger.debug(str(e))
667673
continue
668674

669675
progress.advance(task_id)
670676

671-
return dict(function_to_test_map), num_discovered_tests
677+
return dict(function_to_test_map), num_discovered_tests, num_discovered_replay_tests

codeflash/discovery/functions_to_optimize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ def get_all_replay_test_functions(
304304
logger.error("Could not find trace_file_path in replay test files.")
305305
exit_with_message("Could not find trace_file_path in replay test files.")
306306

307-
function_tests, _ = discover_unit_tests(test_cfg, discover_only_these_tests=replay_test)
307+
function_tests, _, _ = discover_unit_tests(test_cfg, discover_only_these_tests=replay_test)
308308
# Get the absolute file paths for each function, excluding class name if present
309309
filtered_valid_functions = defaultdict(list)
310310
file_to_functions_map = defaultdict(list)

codeflash/optimization/optimizer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ def discover_tests(
226226

227227
console.rule()
228228
start_time = time.time()
229-
function_to_tests, num_discovered_tests = discover_unit_tests(
229+
function_to_tests, num_discovered_tests, num_discovered_replay_tests = discover_unit_tests(
230230
self.test_cfg, file_to_funcs_to_optimize=file_to_funcs_to_optimize
231231
)
232232
console.rule()
233233
logger.info(
234-
f"Discovered {num_discovered_tests} existing unit tests in {(time.time() - start_time):.1f}s at {self.test_cfg.tests_root}"
234+
f"Discovered {num_discovered_tests} existing unit tests and {num_discovered_replay_tests} replay tests in {(time.time() - start_time):.1f}s at {self.test_cfg.tests_root}"
235235
)
236236
console.rule()
237237
ph("cli-optimize-discovered-tests", {"num_tests": num_discovered_tests})

0 commit comments

Comments
 (0)