Skip to content

Codebase intelligence for AI and humans: code health scores, auto-generated docs, git analytics, dead code detection, and architectural decisions via MCP.

perf(test_reach): build changed file-part set once per walk and add rank-free any_reached (#4349) (#4577)

Rishabh Mishra79ebbc4e4f40
diff --git a/packages/core/src/repowise/core/analysis/test_reach/__init__.py b/packages/core/src/repowise/core/analysis/test_reach/__init__.py
index bb0407e43..9092737eb 100644
--- a/packages/core/src/repowise/core/analysis/test_reach/__init__.py
+++ b/packages/core/src/repowise/core/analysis/test_reach/__init__.py
@@ -152,10 +152,10 @@ checkout) or over the stored graph (:mod:`.db`). :func:`reach_states` is the
typed answer, the one that may say "no test reaches this".
"""
-
from ..test_selection import is_runnable_test
from .db import (
always_run_test_files,
+ any_reached,
any_tests_reaching,
cached_files_reached_by_tests,
cached_hub_files,
@@ -220,6 +220,7 @@ __all__ = [
"ReachedVia",
"WalkMaps",
"always_run_test_files",
+ "any_reached",
"any_tests_reaching",
"build_walk_maps",
"cached_files_reached_by_tests",
diff --git a/packages/core/src/repowise/core/analysis/test_reach/db.py b/packages/core/src/repowise/core/analysis/test_reach/db.py
index 876f5de76..c0599b86a 100644
--- a/packages/core/src/repowise/core/analysis/test_reach/db.py
+++ b/packages/core/src/repowise/core/analysis/test_reach/db.py
@@ -224,7 +224,11 @@ async def _file_paths(session: AsyncSession, repo_id: str) -> set[str]:
async def any_tests_reaching(
- session: AsyncSession, repo_id: str, targets: Collection[str]
+ session: AsyncSession,
+ repo_id: str,
+ targets: Collection[str],
+ *,
+ rank: bool = True,
) -> dict[str, ReachRow]:
"""The targets some test reaches, or only tests replacing them reach; others are unreached.
@@ -235,16 +239,26 @@ async def any_tests_reaching(
whole import closure, so absence is a claim. Cached per index state.
"""
seeds = tuple(sorted(set(targets)))
- key = await _cache.key(session, repo_id, "any_reach", seeds)
+ cache_tag = "any_reach" if rank else "any_reach_rankfree"
+ key = await _cache.key(session, repo_id, cache_tag, seeds)
if key in _cache:
return _cache.get(key)
test_files = set(await cached_test_files(session, repo_id))
masks = await cached_test_masks(session, repo_id)
- rows = await drive(states_walk(list(seeds), test_files, masks=masks), session, repo_id)
+ rows = await drive(
+ states_walk(list(seeds), test_files, masks=masks, rank=rank), session, repo_id
+ )
found = {path: row for path, row in rows.items() if row.state in ("reached", "mocked_only")}
return _cache.remember(key, found)
+async def any_reached(
+ session: AsyncSession, repo_id: str, targets: Collection[str]
+) -> dict[str, ReachRow]:
+ """Rank-free reached-ness for tab-level views that only need which files are reached."""
+ return await any_tests_reaching(session, repo_id, targets, rank=False)
+
+
async def reach_states_from_db(
session: AsyncSession,
repo_id: str,
diff --git a/packages/core/src/repowise/core/analysis/test_reach/model.py b/packages/core/src/repowise/core/analysis/test_reach/model.py
index 09f2ab90b..694124f03 100644
--- a/packages/core/src/repowise/core/analysis/test_reach/model.py
+++ b/packages/core/src/repowise/core/analysis/test_reach/model.py
@@ -105,15 +105,26 @@ def capped(
reach: Mapping[str, ReachDistance] | None = None,
direct: Collection[str] = frozenset(),
changed: Collection[str] = frozenset(),
+ edited: Collection[str] | None = None,
entries: Mapping[str, frozenset[str]] | None = None,
transitive: Collection[str] = frozenset(),
+ rank: bool = True,
) -> ReachedBy:
"""*tests* ranked by :func:`rank_reaching`, then cut to ``MAX_TESTS_PER_TARGET``."""
- ordered = tuple(
- rank_reaching(
- target, tests, reach=reach, direct=direct, changed=changed, transitive=transitive
+ if rank:
+ ordered = tuple(
+ rank_reaching(
+ target,
+ tests,
+ reach=reach,
+ direct=direct,
+ changed=changed,
+ edited=edited,
+ transitive=transitive,
+ )
)
- )
+ else:
+ ordered = tuple(sorted(tests))
return ReachedBy(
list(ordered[:MAX_TESTS_PER_TARGET]),
via,
@@ -132,6 +143,7 @@ def rank_reaching(
reach: Mapping[str, ReachDistance] | None = None,
direct: Collection[str] = frozenset(),
changed: Collection[str] = frozenset(),
+ edited: Collection[str] | None = None,
transitive: Collection[str] = frozenset(),
) -> list[str]:
"""*tests* reaching *target*, the likeliest to exercise it first. Cap after this.
@@ -148,7 +160,8 @@ def rank_reaching(
names = paired_test_names(path_of)
dirs = set(path_of.split("/")[:-1])
reach = reach or {}
- edited = {c.split("::", 1)[0] for c in changed}
+ if edited is None:
+ edited = {c.split("::", 1)[0] for c in changed}
def key(test: str) -> tuple[bool, bool, int, bool, int, bool, int, str]:
path = test.split("::", 1)[0]
diff --git a/packages/core/src/repowise/core/analysis/test_reach/walk.py b/packages/core/src/repowise/core/analysis/test_reach/walk.py
index 41a888742..c7ed6c3ba 100644
--- a/packages/core/src/repowise/core/analysis/test_reach/walk.py
+++ b/packages/core/src/repowise/core/analysis/test_reach/walk.py
@@ -119,9 +119,7 @@ def _call_origins(
# so a test reaching an unrelated symbol in the same file does not count.
# An empty entry names no symbol, so that file is unseeded and keeps the
# ``defines`` lookup; treating it as seeded would silence the file entirely.
- seeded = {
- seed: symbol_seeds[seed] for seed in seeds if symbol_seeds and symbol_seeds.get(seed)
- }
+ seeded = {seed: symbol_seeds[seed] for seed in seeds if symbol_seeds and symbol_seeds.get(seed)}
for seed, symbol_ids in seeded.items():
for symbol in symbol_ids:
origins.setdefault(symbol, {})[seed] = 0
@@ -215,7 +213,12 @@ def import_walk(
return found, entries
-def helper_walk(targets: list[str], test_files: Collection[str]) -> Walk[dict[str, ReachedBy]]:
+def helper_walk(
+ targets: list[str],
+ test_files: Collection[str],
+ *,
+ rank: bool = True,
+) -> Walk[dict[str, ReachedBy]]:
"""Tests that import a file only tests import, or a barrel, which imports the target.
A second import hop, kept off hubs: a blanket second hop was measured and
@@ -239,8 +242,9 @@ def helper_walk(targets: list[str], test_files: Collection[str]) -> Walk[dict[st
if tests and (tests == who or PurePosixPath(middle).name in BARREL_FILENAMES):
for target in middles[middle]:
reached.setdefault(target, set()).update(tests)
+ edited = frozenset(c.split("::", 1)[0] for c in targets)
return {
- target: capped(target, tests, "import-graph", changed=targets)
+ target: capped(target, tests, "import-graph", changed=targets, edited=edited, rank=rank)
for target, tests in reached.items()
}
@@ -255,6 +259,7 @@ def tier_walk(
avoid: Collection[str] = frozenset(),
helpers: bool = False,
hubs: Collection[str] = frozenset(),
+ rank: bool = True,
) -> Walk[dict[str, ReachedBy]]:
"""The call walk, then the import walk for what it left, then (*helpers*) the helper hop.
@@ -270,6 +275,7 @@ def tier_walk(
if not seeds or not test_files:
return {}
out: dict[str, ReachedBy] = {}
+ edited = frozenset(c.split("::", 1)[0] for c in seeds)
if call_depth >= 1:
found = yield from call_walk(
seeds, test_files, call_depth, symbol_seeds=symbol_seeds, avoid=avoid
@@ -286,7 +292,9 @@ def tier_walk(
"call-graph",
reach=reach,
changed=seeds,
+ edited=edited,
transitive=tagged.get(seed, ()),
+ rank=rank,
)
unanswered = [seed for seed in seeds if seed not in out]
if unanswered and import_depth >= 1:
@@ -297,11 +305,18 @@ def tier_walk(
# A test importing the target itself, not a file on the way to it.
direct = {t for t, via in by_test.items() if file in via}
out[seed] = capped(
- seed, tests, "import-graph", direct=direct, changed=seeds, entries=by_test
+ seed,
+ tests,
+ "import-graph",
+ direct=direct,
+ changed=seeds,
+ edited=edited,
+ entries=by_test,
+ rank=rank,
)
unanswered = [seed for seed in seeds if seed not in out]
if unanswered and helpers:
- out |= yield from helper_walk(unanswered, test_files)
+ out |= yield from helper_walk(unanswered, test_files, rank=rank)
return out
@@ -371,15 +386,29 @@ def reaching_by_tier(
)
-def closure_walk(targets: list[str], test_files: Collection[str]) -> Walk[dict[str, ReachedBy]]:
+def closure_walk(
+ targets: list[str],
+ test_files: Collection[str],
+ *,
+ rank: bool = True,
+) -> Walk[dict[str, ReachedBy]]:
"""Tests anywhere up the import closure of each target, in batches of ``CLOSURE_SEED_CAP``."""
out: dict[str, ReachedBy] = {}
+ edited = frozenset(c.split("::", 1)[0] for c in targets)
for start in range(0, len(targets), CLOSURE_SEED_CAP):
batch = targets[start : start + CLOSURE_SEED_CAP]
found, entries = yield from import_walk(batch, test_files, CLOSURE_DEPTH)
for seed, tests in found.items():
by_test = {t: frozenset(via) for t, via in entries[seed].items()}
- out[seed] = capped(seed, tests, "import-graph", changed=targets, entries=by_test)
+ out[seed] = capped(
+ seed,
+ tests,
+ "import-graph",
+ changed=targets,
+ edited=edited,
+ entries=by_test,
+ rank=rank,
+ )
return out
@@ -390,6 +419,7 @@ def states_walk(
changed_tests: Collection[str] = frozenset(),
contents: Mapping[str, str | bytes] | None = None,
masks: Mapping[str, Collection[str]] | None = None,
+ rank: bool = True,
) -> Walk[dict[str, ReachRow]]:
"""A :class:`~.model.ReachRow` per path, the negative claim made only when it holds.
@@ -414,9 +444,7 @@ def states_walk(
go_tests.setdefault(str(PurePosixPath(t).parent), []).append(t)
# Only a test a runner collects is evidence; a touched conftest or helper is not.
touched = sorted(
- t
- for t in set(changed_tests)
- if is_runnable_test(t, is_test=(t in test_files) or None)
+ t for t in set(changed_tests) if is_runnable_test(t, is_test=(t in test_files) or None)
)
imported_by = yield from _touched_imports(paths, touched)
for path in dict.fromkeys(paths):
@@ -432,11 +460,13 @@ def states_walk(
mocked.setdefault(path, set()).update(replacing)
named = [t for t in named if t not in replacing]
if named:
- rows[path] = ReachRow("reached", capped(path, named, "changed-test", changed=named))
+ rows[path] = ReachRow(
+ "reached", capped(path, named, "changed-test", changed=named, rank=rank)
+ )
continue
own = inline_tests(path, content, go_tests.get(str(PurePosixPath(path).parent), ()))
if own:
- rows[path] = ReachRow("reached", capped(path, own, "inline"))
+ rows[path] = ReachRow("reached", capped(path, own, "inline", rank=rank))
continue
rest.append(path)
known = (yield Need("known", tuple(rest))) if rest else set()
@@ -446,9 +476,11 @@ def states_walk(
elif not test_files:
rows[path] = ReachRow("no_signal")
rest = [p for p in rest if p not in rows]
- found = _unmasked((yield from tier_walk(rest, test_files, helpers=True)), masks, mocked)
+ found = _unmasked(
+ (yield from tier_walk(rest, test_files, helpers=True, rank=rank)), masks, mocked
+ )
left = [p for p in rest if p not in found]
- found |= _unmasked((yield from closure_walk(left, test_files)), masks, mocked)
+ found |= _unmasked((yield from closure_walk(left, test_files, rank=rank)), masks, mocked)
for path in rest:
hit = found.get(path)
if hit:
@@ -517,6 +549,7 @@ def reach_states(
changed_tests: Collection[str] = frozenset(),
contents: Mapping[str, str | bytes] | None = None,
masks: Mapping[str, Collection[str]] | None = None,
+ rank: bool = True,
) -> dict[str, ReachRow]:
""":func:`states_walk` over *maps*: whether tests reach each path, as a typed claim.
@@ -532,6 +565,7 @@ def reach_states(
changed_tests=changed_tests,
contents=contents,
masks=masks,
+ rank=rank,
),
maps,
)
diff --git a/tests/unit/analysis/test_test_reach_api.py b/tests/unit/analysis/test_test_reach_api.py
index d99f9020d..ac50fea74 100644
--- a/tests/unit/analysis/test_test_reach_api.py
+++ b/tests/unit/analysis/test_test_reach_api.py
@@ -61,7 +61,12 @@ def test_maps_drop_name_guessed_calls_and_the_legacy_conftest_hint() -> None:
{"tests/test_a.py": True, "tests/conftest.py": True, "src/a.py": False},
[
*_call("tests/test_a.py", "src/a.py", origin="global_unique"),
- ("tests/conftest.py", "tests/test_a.py", "dynamic_uses", {"hint_source": "pytest_conftest"}),
+ (
+ "tests/conftest.py",
+ "tests/test_a.py",
+ "dynamic_uses",
+ {"hint_source": "pytest_conftest"},
+ ),
],
)
maps = build_walk_maps(g)
@@ -119,7 +124,10 @@ def test_the_import_tier_answers_where_calls_are_silent() -> None:
def test_the_helper_hop_passes_through_a_module_only_tests_import() -> None:
g = _graph(
{"tests/test_a.py": True, "tests/support.py": False, "src/a.py": False},
- [("tests/test_a.py", "tests/support.py", "imports"), ("tests/support.py", "src/a.py", "imports")],
+ [
+ ("tests/test_a.py", "tests/support.py", "imports"),
+ ("tests/support.py", "src/a.py", "imports"),
+ ],
)
maps = build_walk_maps(g)
assert "src/a.py" not in reaching_by_tier(maps, ["src/a.py"], helpers=False)
@@ -233,14 +241,21 @@ def test_a_file_the_index_lacks_is_new_and_an_index_without_tests_says_nothing()
def test_a_types_only_file_is_type_only_whatever_reaches_it() -> None:
maps = build_walk_maps(_graph({"src/types.py": False, "tests/test_x.py": True}, []))
- content = "from typing import Protocol\n\nclass Store(Protocol):\n def get(self) -> int: ...\n"
+ content = (
+ "from typing import Protocol\n\nclass Store(Protocol):\n def get(self) -> int: ...\n"
+ )
rows = reach_states(maps, ["src/types.py"], contents={"src/types.py": content})
assert rows["src/types.py"].state == "type_only"
def test_a_test_the_change_touches_is_evidence_for_the_file_it_names_or_imports() -> None:
g = _graph(
- {"tests/test_other.py": True, "tests/test_imports.py": True, "src/a.py": False, "src/b.py": False},
+ {
+ "tests/test_other.py": True,
+ "tests/test_imports.py": True,
+ "src/a.py": False,
+ "src/b.py": False,
+ },
[("tests/test_imports.py", "src/b.py", "imports")],
)
maps = build_walk_maps(g)
@@ -248,7 +263,12 @@ def test_a_test_the_change_touches_is_evidence_for_the_file_it_names_or_imports(
maps,
["src/a.py", "src/b.py", "src/new.py"],
# test_a.py is new to the index; conftest.py is support, never evidence.
- changed_tests=["tests/test_a.py", "tests/test_imports.py", "tests/conftest.py", "tests/test_new.py"],
+ changed_tests=[
+ "tests/test_a.py",
+ "tests/test_imports.py",
+ "tests/conftest.py",
+ "tests/test_new.py",
+ ],
)
assert rows["src/a.py"].reached.via == "changed-test"
assert rows["src/a.py"].reached.tests == ["tests/test_a.py"]
@@ -261,7 +281,12 @@ def test_a_test_the_change_touches_is_evidence_for_the_file_it_names_or_imports(
def test_inline_tests_reach_their_own_file() -> None:
g = _graph(
- {"src/lib.rs": False, "pkg/store.go": False, "pkg/store_test.go": True, "other/x.go": False},
+ {
+ "src/lib.rs": False,
+ "pkg/store.go": False,
+ "pkg/store_test.go": True,
+ "other/x.go": False,
+ },
[],
)
rows = reach_states(
@@ -298,8 +323,16 @@ def test_go_inline_tests_are_the_test_files_of_the_same_directory() -> None:
("path", "content", "expected"),
[
("src/api.d.ts", "export const x: number;", True),
- ("src/t.ts", "import type {A} from './a';\nexport type B = A;\nexport interface C {}\n", True),
- ("src/t.ts", "import {A} from './a';\ndeclare const v: A;\nexport type {Q} from './q';\n", True),
+ (
+ "src/t.ts",
+ "import type {A} from './a';\nexport type B = A;\nexport interface C {}\n",
+ True,
+ ),
+ (
+ "src/t.ts",
+ "import {A} from './a';\ndeclare const v: A;\nexport type {Q} from './q';\n",
+ True,
+ ),
("src/t.ts", "export type B = string;\nexport const k = 1;\n", False),
("src/t.ts", "import './polyfill';\nexport type B = string;\n", False),
("src/t.ts", "export enum E { a }\n", False),
@@ -313,7 +346,11 @@ def test_go_inline_tests_are_the_test_files_of_the_same_directory() -> None:
"__all__ = ['Row']\n",
True,
),
- ("src/types.py", "from typing import Protocol\nclass P(Protocol):\n x: int\nLIMIT = 3\n", False),
+ (
+ "src/types.py",
+ "from typing import Protocol\nclass P(Protocol):\n x: int\nLIMIT = 3\n",
+ False,
+ ),
("src/types.py", "def f():\n return 1\n", False),
("src/types.py", "class P(Protocol\n", False),
("src/c.go", "package c\n", False),
@@ -324,7 +361,9 @@ def test_type_only_files(path: str, content: str, expected: bool) -> None:
def test_a_test_file_is_never_type_only() -> None:
- assert not is_type_only("tests/test_types.py", "from typing import TypedDict\nclass R(TypedDict): ...\n")
+ assert not is_type_only(
+ "tests/test_types.py", "from typing import TypedDict\nclass R(TypedDict): ...\n"
+ )
assert not is_type_only("src/types.py", "class R(TypedDict): ...\n", is_test=True)
@@ -464,3 +503,64 @@ def test_read_under_stays_inside_the_checkout(tmp_path) -> None:
assert read("../secret.ts") is None
assert read(str(tmp_path / "secret.ts").replace("\\", "/")) is None
assert read("missing.ts") is None
+
+
+def test_helper_and_closure_rankings_identical() -> None:
+ """Helper and closure walks rank tests consistently without recomputing edited sets."""
+ g = _graph(
+ {
+ "tests/test_h1.py": True,
+ "tests/test_h2.py": True,
+ "tests/helper.py": False,
+ "src/target.py": False,
+ "tests/test_c1.py": True,
+ "src/m1.py": False,
+ "src/m2.py": False,
+ "src/leaf.py": False,
+ },
+ [
+ ("tests/test_h1.py", "tests/helper.py", "imports"),
+ ("tests/test_h2.py", "tests/helper.py", "imports"),
+ ("tests/helper.py", "src/target.py", "imports"),
+ ("tests/test_c1.py", "src/m1.py", "imports"),
+ ("src/m1.py", "src/m2.py", "imports"),
+ ("src/m2.py", "src/leaf.py", "imports"),
+ ],
+ )
+ maps = build_walk_maps(g)
+ rows = reach_states(maps, ["src/target.py", "src/leaf.py"])
+ assert rows["src/target.py"].state == "reached"
+ assert rows["src/target.py"].reached.via == "import-graph"
+ assert rows["src/target.py"].reached.tests == ["tests/test_h1.py", "tests/test_h2.py"]
+
+ assert rows["src/leaf.py"].state == "reached"
+ assert rows["src/leaf.py"].reached.via == "import-graph"
+ assert rows["src/leaf.py"].reached.tests == ["tests/test_c1.py"]
+
+
+def test_rank_free_reached_ness_returns_same_keys_as_reach_states() -> None:
+ """Rank-free reach states returns the same reached keys without paying for ranking."""
+ g = _graph(
+ {
+ "tests/test_a.py": True,
+ "tests/test_b.py": True,
+ "src/a.py": False,
+ "src/b.py": False,
+ "src/unreached.py": False,
+ },
+ [
+ *_call("tests/test_a.py", "src/a.py"),
+ ("tests/test_b.py", "src/b.py", "imports"),
+ ],
+ )
+ maps = build_walk_maps(g)
+ targets = ["src/a.py", "src/b.py", "src/unreached.py"]
+ ranked = reach_states(maps, targets, rank=True)
+ unranked = reach_states(maps, targets, rank=False)
+
+ assert ranked.keys() == unranked.keys()
+ for k in targets:
+ assert ranked[k].state == unranked[k].state
+ assert {k for k, r in ranked.items() if r.state == "reached"} == {
+ k for k, r in unranked.items() if r.state == "reached"
+ }
diff --git a/tests/unit/persistence/test_test_reachability_walk.py b/tests/unit/persistence/test_test_reachability_walk.py
index 677c4c620..1d002aa20 100644
--- a/tests/unit/persistence/test_test_reachability_walk.py
+++ b/tests/unit/persistence/test_test_reachability_walk.py
@@ -512,7 +512,9 @@ async def _hub_repo(session, *, tests=(), edges=()):
nodes = {"tests/test_bystander.py": True, "tests/test_runner.py": True, "src/util.py": False}
nodes |= dict.fromkeys(tests, True)
for path, is_test in nodes.items():
- session.add(GraphNode(repository_id=repo.id, node_id=path, node_type="file", is_test=is_test))
+ session.add(
+ GraphNode(repository_id=repo.id, node_id=path, node_type="file", is_test=is_test)
+ )
for name, start, end in (("walk", 1, 20), ("other", 30, 40), ("lonely", 50, 60)):
session.add(
GraphNode(
@@ -708,7 +710,11 @@ _KY_LIKE = {
async def test_any_reach_passes_through_the_package_entry_tests_import(tmp_path, async_session):
"""A test importing a package's ``index.ts`` reaches the files it imports."""
- from repowise.core.analysis.test_reachability import any_tests_reaching, clear_test_map_cache
+ from repowise.core.analysis.test_reachability import (
+ any_reached,
+ any_tests_reaching,
+ clear_test_map_cache,
+ )
from repowise.core.persistence.crud.graph import batch_upsert_graph_edges
from repowise.core.pipeline.persist import _edge_row, persist_graph_nodes
from tests.unit.analysis.test_public_api_flag import build_fixture
@@ -727,6 +733,9 @@ async def test_any_reach_passes_through_the_package_entry_tests_import(tmp_path,
# closure does not: a test importing pool.ts runs retry.ts, so it is not unreached.
assert found["src/retry.ts"].reached.entries == {"test/x.test.ts": frozenset({"src/pool.ts"})}
+ rank_free = await any_reached(async_session, repo.id, ["src/core/Ky.ts", "src/retry.ts"])
+ assert rank_free.keys() == found.keys()
+
_SWAPPED = {
"app/__init__.py": "",
@@ -981,7 +990,9 @@ async def test_the_stored_walk_and_the_in_memory_walk_return_the_same_rows(tmp_p
asked = [*paths, "app/added.py", "app/types.py"]
evidence = {
"changed_tests": ["tests/test_lonely.py"],
- "contents": {"app/types.py": "from typing import TypedDict\nclass R(TypedDict):\n a: int\n"},
+ "contents": {
+ "app/types.py": "from typing import TypedDict\nclass R(TypedDict):\n a: int\n"
+ },
}
in_memory = reach_states(maps, asked, **evidence)
assert await reach_states_from_db(async_session, repo.id, asked, **evidence) == in_memory
@@ -993,7 +1004,9 @@ async def test_the_stored_walk_and_the_in_memory_walk_return_the_same_rows(tmp_p
# so only replacing tests reach either.
swap = 'from unittest.mock import patch\n\n@patch("app.util")\ndef test_swapped(m): ...\n'
texts = dict.fromkeys(["tests/test_core.py", "tests/test_pkg.py"], swap)
- texts["test/x.test.ts"] = 'import {vi} from "vitest";\nvi.mock("../src/retry", () => ({retry: 1}));\n'
+ texts["test/x.test.ts"] = (
+ 'import {vi} from "vitest";\nvi.mock("../src/retry", () => ({retry: 1}));\n'
+ )
masks = replaced_files(texts, _PARITY)
assert masks == {
**{t: {"app/util.py"} for t in ("tests/test_core.py", "tests/test_pkg.py")},
@@ -1016,7 +1029,10 @@ async def test_stored_call_hubs_match_the_in_memory_ones(async_session):
from repowise.core.analysis.test_reachability import clear_test_map_cache as clear
tests = [f"tests/test_{i:02}.py" for i in range(10)]
- edges = [("src/hub.py", "src/hub.py::run", "defines"), ("src/few.py", "src/few.py::f", "defines")]
+ edges = [
+ ("src/hub.py", "src/hub.py::run", "defines"),
+ ("src/few.py", "src/few.py::f", "defines"),
+ ]
for t in tests:
edges += [(t, f"{t}::t", "defines"), (f"{t}::t", "src/hub.py::run", "calls")]
edges += [(f"{t}::t", "src/few.py::f", "calls", "global_unique") for t in tests]