Keep search lifecycle tests on the scoped traversal

This commit is contained in:
Xubin Ren committed 2026-11-14 22:09:21 +08:00
1 parent 5c7ff5b796
commit 360a85bea5
1 file changed
+5 -7
+5 -7
View File
@@ -273,11 +273,11 @@ async def test_find_files_scan_keeps_event_loop_responsive(
started = threading.Event() started = threading.Event()
release = threading.Event() release = threading.Event()
def blocking_iter_paths(root: Path, *, include_dirs: bool, budget): def blocking_iter_paths(tree, **kwargs):
started.set() started.set()
if not release.wait(timeout=1): if not release.wait(timeout=1):
raise TimeoutError("test did not release find_files traversal") raise TimeoutError("test did not release find_files traversal")
yield from original_iter_paths(root, include_dirs=include_dirs, budget=budget) yield from original_iter_paths(tree, **kwargs)
monkeypatch.setattr(tool, "_iter_paths", blocking_iter_paths) monkeypatch.setattr(tool, "_iter_paths", blocking_iter_paths)
task = asyncio.create_task(tool.execute(path=".")) task = asyncio.create_task(tool.execute(path="."))
@@ -397,8 +397,7 @@ async def test_find_files_cancellation_stops_worker_scan(
started = threading.Event() started = threading.Event()
stopped = threading.Event() stopped = threading.Event()
def cancellable_iter_paths(root: Path, *, include_dirs: bool, budget): def cancellable_iter_paths(_tree, *, budget, **_kwargs):
del root, include_dirs
started.set() started.set()
if not budget.cancelled.wait(timeout=1): if not budget.cancelled.wait(timeout=1):
raise TimeoutError("find_files worker did not receive cancellation") raise TimeoutError("find_files worker did not receive cancellation")
@@ -428,12 +427,11 @@ async def test_find_files_path_limit_stops_after_pagination_lookahead(
tool = FindFilesTool(workspace=tmp_path, allowed_dir=tmp_path) tool = FindFilesTool(workspace=tmp_path, allowed_dir=tmp_path)
visited: list[str] = [] visited: list[str] = []
def ordered_iter_paths(tree, *, include_dirs: bool, budget): def ordered_iter_paths(_tree, *, entry_for, budget, **_kwargs):
del include_dirs
for path in paths: for path in paths:
budget.checkpoint() budget.checkpoint()
visited.append(path.name) visited.append(path.name)
yield tool._entry(path, tree.root, is_dir=False) yield entry_for(path, False)
monkeypatch.setattr(tool, "_iter_paths", ordered_iter_paths) monkeypatch.setattr(tool, "_iter_paths", ordered_iter_paths)
result = await tool.execute(path=".", head_limit=1) result = await tool.execute(path=".", head_limit=1)