Skip to content

Test both TCP modes#2866

Open
rwols wants to merge 1 commit intomainfrom
chore/add-tests
Open

Test both TCP modes#2866
rwols wants to merge 1 commit intomainfrom
chore/add-tests

Conversation

@rwols
Copy link
Copy Markdown
Member

@rwols rwols commented Apr 13, 2026

Add a test that checks that "tcp server mode" works. Server meaning that this plugin acts as the TCP server and the langserver connects as TCP client.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 13, 2026

Deploy Preview for sublime-lsp ready!

Name Link
🔨 Latest commit 8d2e9eb
🔍 Latest deploy log https://app.netlify.com/projects/sublime-lsp/deploys/69dd64220a999e0009b3d773
😎 Deploy Preview https://deploy-preview-2866--sublime-lsp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Add a test that checks that "tcp server mode" works. Server meaning
that this plugin acts as the TCP server and the langserver connects as
TCP client.
@rwols rwols force-pushed the chore/add-tests branch from 8d2e9eb to 699dad3 Compare April 13, 2026 21:50


async def main(tcp_port: int | None = None) -> bool:
async def main(tcp_port: int | None = None, mode: str | None = None) -> bool:
Copy link
Copy Markdown
Member

@rchl rchl Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you set type for mode to Literal['client', 'server'] | None so that it self-documents allowed values?

await server.serve_forever()
return callback.received_shutdown

if mode is not None and mode == "client":
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if mode is not None and mode == "client":
if mode == "client":

parser = ArgumentParser(prog=__package__, description=__doc__)
parser.add_argument("-v", "--version", action="store_true", help="print version and exit")
parser.add_argument("-p", "--tcp-port", type=int)
parser.add_argument("--mode", help="one of 'client' or 'server'", default="server")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can validate the argument early and then also doesn't really need a redundant help:

Suggested change
parser.add_argument("--mode", help="one of 'client' or 'server'", default="server")
parser.add_argument("--mode", help="one of 'client' or 'server'", default="server", choices=["client", "server"])

Comment on lines +46 to +53
config = ClientConfig(
name=name,
command=["python3", join("$packages", "LSP", "tests", "server.py")],
selector="text.plain",
enabled=True,
)
config.initialization_options.assign(init_options)
return config
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pass init_options to the constructor and save lines?

Suggested change
config = ClientConfig(
name=name,
command=["python3", join("$packages", "LSP", "tests", "server.py")],
selector="text.plain",
enabled=True,
)
config.initialization_options.assign(init_options)
return config
return ClientConfig(
name=name,
command=["python3", join("$packages", "LSP", "tests", "server.py")],
selector="text.plain",
initialization_options=DottedDict(init_options),
enabled=True,
)

Same below.

def make_stdio_test_config() -> ClientConfig:
return ClientConfig(
name="TEST",
def make_stdio_test_config(name: str, init_options: dict[str, Any]) -> ClientConfig:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe make init_options optional since it's not always needed?

Suggested change
def make_stdio_test_config(name: str, init_options: dict[str, Any]) -> ClientConfig:
def make_stdio_test_config(name: str, init_options: dict[str, Any] | None = None) -> ClientConfig:

return ClientConfig(
name="TEST",
def make_stdio_test_config(name: str, init_options: dict[str, Any]) -> ClientConfig:
"""Start the fake language server in STDIO mode."""
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicking but the function doesn't really start the server. It just creates a config for starting a server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants