## Summary - Extract shared test utilities into `tests/integration/utils/` (client, workspace, assertions, wait, cache) - Migrate 12 test files into categorized subdirectories: `lifecycle/`, `compilation/`, `features/`, `modules/`, `extensions/`, `stress/` - Merge `test_include_completion.py` + `test_import_completion.py` → `features/test_completion.py` - Remove stale directory-tree comments and section divider comments ## Test plan - [x] `pytest --collect-only` collects all 113 tests - [x] All test module imports verified - [x] `pixi run format` applied 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Reorganized integration suites: added new feature tests (completion, server) and removed older duplicated modules. * Centralized shared test utilities and assertion helpers for diagnostics, workspace operations, waiting/synchronization, and cache inspection. * **Chores / Refactor** * Standardized test client lifecycle and helper usage across suites for more reliable test flows. * Improved server session lifecycle handling for more predictable document/session resets during tests. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.6 KiB
Python
57 lines
1.6 KiB
Python
"""Wait and polling helpers for integration tests."""
|
|
|
|
import asyncio
|
|
|
|
from lsprotocol.types import (
|
|
HoverParams,
|
|
Position,
|
|
TextDocumentIdentifier,
|
|
WorkspaceSymbolParams,
|
|
)
|
|
|
|
|
|
async def wait_for_recompile(client, uri: str, *, timeout: float = 60.0) -> None:
|
|
"""Trigger recompilation via hover and wait for fresh diagnostics.
|
|
|
|
Useful after didChange or on-disk file modifications. Sends a hover
|
|
request at (0,0) to trigger ensure_compiled(), then waits for the
|
|
resulting diagnostics notification.
|
|
"""
|
|
event = client.wait_for_diagnostics(uri)
|
|
await client.text_document_hover_async(
|
|
HoverParams(
|
|
text_document=TextDocumentIdentifier(uri=uri),
|
|
position=Position(line=0, character=0),
|
|
)
|
|
)
|
|
await asyncio.wait_for(event.wait(), timeout=timeout)
|
|
|
|
|
|
async def wait_for_index(
|
|
client,
|
|
uri: str,
|
|
symbol_name: str = "add",
|
|
*,
|
|
timeout: int = 30,
|
|
) -> bool:
|
|
"""Poll workspace/symbol until a specific symbol appears in the index.
|
|
|
|
Sends a hover to trigger compilation/indexing, then polls every second.
|
|
Returns True if the symbol was found, False on timeout.
|
|
"""
|
|
await client.text_document_hover_async(
|
|
HoverParams(
|
|
text_document=TextDocumentIdentifier(uri=uri),
|
|
position=Position(line=0, character=0),
|
|
)
|
|
)
|
|
|
|
for _ in range(timeout):
|
|
result = await client.workspace_symbol_async(
|
|
WorkspaceSymbolParams(query=symbol_name)
|
|
)
|
|
if result and any(s.name == symbol_name for s in result):
|
|
return True
|
|
await asyncio.sleep(1)
|
|
return False
|