Many fixes, concolic test coverage.

This commit is contained in:
RD 2024-11-07 16:00:57 -08:00
parent 11409bdd2f
commit a22ce95482
4 changed files with 17 additions and 14 deletions

View file

@ -1,4 +1,4 @@
from __future__ import annotations from __future__ import annotations
from typing import Any, Callable, Iterable, NewType, Optional, Protocol, TypeVar from typing import Any, Callable, Iterable, NewType, Optional, Protocol, TypeVar

View file

@ -0,0 +1,11 @@
from __future__ import annotations
def find_common_tags(articles: list[dict[str, list[str]]]) -> set[str]:
if not articles:
return set()
common_tags = articles[0]["tags"]
for article in articles[1:]:
common_tags = [tag for tag in common_tags if tag in article["tags"]]
return set(common_tags)

View file

@ -156,26 +156,18 @@ def get_functions_to_optimize(
module_root: Path, module_root: Path,
) -> tuple[dict[Path, list[FunctionToOptimize]], int]: ) -> tuple[dict[Path, list[FunctionToOptimize]], int]:
assert ( assert (
sum( sum([bool(optimize_all), bool(replay_test), bool(file)]) <= 1
[ # Ensure only one of the options is provided
bool(optimize_all),
bool(replay_test),
bool(file),
]
)
<= 1
), "Only one of optimize_all, replay_test, or file should be provided" ), "Only one of optimize_all, replay_test, or file should be provided"
functions: dict[str, list[FunctionToOptimize]] functions: dict[str, list[FunctionToOptimize]]
if optimize_all: if optimize_all:
logger.info("Finding all functions in the module '%s' ...", optimize_all) logger.info("Finding all functions in the module '%s'", optimize_all)
functions = get_all_files_and_functions(Path(optimize_all)) functions = get_all_files_and_functions(Path(optimize_all))
elif replay_test is not None: elif replay_test is not None:
functions = get_all_replay_test_functions( functions = get_all_replay_test_functions(
replay_test=replay_test, test_cfg=test_cfg, project_root_path=project_root replay_test=replay_test, test_cfg=test_cfg, project_root_path=project_root
) )
elif file is not None: elif file is not None:
logger.info("Finding all functions in the file '%s' ...", file) logger.info("Finding all functions in the file '%s'", file)
functions = find_all_functions_in_file(file) functions = find_all_functions_in_file(file)
if only_get_this_function is not None: if only_get_this_function is not None:
split_function = only_get_this_function.split(".") split_function = only_get_this_function.split(".")

View file

@ -449,7 +449,7 @@ class Optimizer:
[ [
"crosshair", "crosshair",
"diffbehavior", "diffbehavior",
"--max_uninteresting_iterations=128", "--max_uninteresting_iterations=256",
function_to_optimize_optimized_worktree_fqn, function_to_optimize_optimized_worktree_fqn,
function_to_optimize_original_worktree_fqn, function_to_optimize_original_worktree_fqn,
], ],
@ -463,7 +463,7 @@ class Optimizer:
"crosshair", "crosshair",
"cover", "cover",
"--example_output_format=pytest", "--example_output_format=pytest",
"--max_uninteresting_iterations=128", "--max_uninteresting_iterations=256",
function_to_optimize_optimized_worktree_fqn, function_to_optimize_optimized_worktree_fqn,
], ],
capture_output=True, capture_output=True,