Skip to content

Commit

Permalink
test: run end-to-end tests over WebSockets
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Oct 13, 2024
1 parent cc3c076 commit 433087b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ poetry_lock_check = "poetry check"
sequence = [
{ cmd = "pytest --cov" },
{ cmd = "pytest tests/e2e --lsp-transport tcp" },
{ cmd = "pytest tests/e2e --lsp-transport websockets" },
]
ignore_fail = "return_non_zero"

Expand Down
11 changes: 10 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def pytest_addoption(parser):
dest="lsp_transport",
action="store",
default="stdio",
choices=("stdio", "tcp"),
choices=("stdio", "tcp", "websockets"),
help="Choose the transport to use with servers under test.",
)

Expand Down Expand Up @@ -212,6 +212,15 @@ async def fn(
await asyncio.sleep(1)
await client.start_tcp(host, port)

elif transport == "websockets":
# TODO: Make host/port configurable?
host, port = "localhost", 8888
server_cmd.extend(["--ws", "--host", host, "--port", f"{port}"])

server = await asyncio.create_subprocess_exec(*server_cmd)
await asyncio.sleep(1)
await client.start_ws(host, port)

else:
raise NotImplementedError(f"Unsupported transport: {transport!r}")

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/test_threaded_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ async def test_countdown_threaded(
):
"""Ensure that the countdown threaded command is working as expected."""

if IS_WIN and transport == "tcp":
if (IS_WIN and transport == "tcp") or transport == "websockets":
pytest.skip("see https://github.com/openlawlibrary/pygls/issues/502")

client, initialize_result = threaded_handlers
Expand Down

0 comments on commit 433087b

Please sign in to comment.