Replace silent null returns with proper LSP errors (kota::fail) for feature requests on closed documents, failed compilations, invalid positions, and unresolvable hierarchy items. Add client notifications (window/logMessage) for key failures so integration tests can observe errors without reading server logs. Expand logging coverage in compilation pipeline (compile args, compilation phases, worker results). Improve test infrastructure: conditional log dump on failure, yield-based workspace fixture with post-test cleanup, named timing constants replacing hardcoded sleeps, and log message capture/assertion helpers. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
"""File operation tests for the clice LSP server."""
|
|
|
|
import asyncio
|
|
|
|
import pytest
|
|
from lsprotocol.types import (
|
|
CompletionParams,
|
|
DidCloseTextDocumentParams,
|
|
HoverParams,
|
|
Position,
|
|
SignatureHelpParams,
|
|
VersionedTextDocumentIdentifier,
|
|
)
|
|
|
|
from tests.integration.utils import doc
|
|
from tests.integration.utils.wait import IDLE_TIMEOUT
|
|
from tests.integration.utils.workspace import did_change
|
|
|
|
|
|
@pytest.mark.workspace("hello_world")
|
|
async def test_did_open(client, workspace):
|
|
client.open(workspace / "main.cpp")
|
|
await asyncio.sleep(IDLE_TIMEOUT)
|
|
|
|
|
|
@pytest.mark.workspace("hello_world")
|
|
async def test_did_change(client, workspace):
|
|
uri, content = client.open(workspace / "main.cpp")
|
|
for i in range(20):
|
|
content += "\n"
|
|
await asyncio.sleep(0.2)
|
|
did_change(client, uri, i + 1, content)
|
|
await asyncio.sleep(IDLE_TIMEOUT)
|
|
|
|
|
|
@pytest.mark.workspace("clang_tidy")
|
|
async def test_clang_tidy(client, workspace):
|
|
client.open(workspace / "main.cpp")
|
|
await asyncio.sleep(IDLE_TIMEOUT)
|
|
|
|
|
|
@pytest.mark.workspace("hello_world")
|
|
async def test_hover_save_close(client, workspace):
|
|
main_cpp = workspace / "main.cpp"
|
|
uri, content = client.open(main_cpp)
|
|
hover = await client.text_document_hover_async(
|
|
HoverParams(text_document=doc(uri), position=Position(line=2, character=4))
|
|
)
|
|
assert hover is not None
|
|
assert hover.contents is not None
|
|
await client.text_document_completion_async(
|
|
CompletionParams(text_document=doc(uri), position=Position(line=0, character=0))
|
|
)
|
|
await client.text_document_signature_help_async(
|
|
SignatureHelpParams(
|
|
text_document=doc(uri), position=Position(line=0, character=0)
|
|
)
|
|
)
|
|
client.text_document_did_close(DidCloseTextDocumentParams(text_document=doc(uri)))
|
|
with pytest.raises(Exception, match="Document not open"):
|
|
await client.text_document_hover_async(
|
|
HoverParams(text_document=doc(uri), position=Position(line=0, character=0))
|
|
)
|