Skip to content

Test extension binary selection and restart recovery (#4907) - #4907

Open
connernilsen wants to merge 4 commits into
facebook:mainfrom
connernilsen:export-D119697409
Open

connernilsen wants to merge 4 commits into
facebook:mainfrom
connernilsen:export-D119697409

Conversation

@connernilsen

@connernilsen connernilsen commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary:

The extension now picks its Pyrefly binary at runtime and restarts the language
server when that choice changes. Neither had a test, and review found real bugs
in both: a failed restart left the launch specification pointing at the binary
that had just failed, so no later change was ever seen as a change.

Two suites cover it. resolveExecutable drives the selection table through real
settings, with stubs only for the output channel and the interpreter lookup, so
the fallback reasons that end up in the output channel are asserted directly.
language server recovery drives a real LanguageClient at a binary that
cannot start, and checks that the specification is put back and a server is
still running afterwards — the second half matters because a client whose start
failed cannot be restarted, only replaced, so a running server is the only proof
the replacement path works.

Both need a real extension host rather than mocks, because the behaviour they
depend on belongs to vscode-languageclient. Mocking it would assert our
assumptions about it instead. activate therefore returns a small hook so tests
drive restarts directly rather than racing the configuration listener.

Running them per pull request is close to free: pyrefly.yml already builds a
release binary, so the new step copies it into lsp/bin and runs the suite on
one platform. Until now nothing about the extension ran before merge — not even
type checking.

Differential Revision: D119697409

@meta-codesync

meta-codesync Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

@connernilsen has exported this pull request. If you are a Meta employee, you can view the originating Diff in D119697409.

@meta-codesync meta-codesync Bot changed the title Test extension binary selection and restart recovery Test extension binary selection and restart recovery (#4907) Sep 14, 2026
connernilsen added a commit to connernilsen/pyrefly that referenced this pull request Sep 14, 2026
Summary:
Pull Request resolved: facebook#4907

The extension now picks its Pyrefly binary at runtime and restarts the language
server when that choice changes. Neither had a test, and review found real bugs
in both: a failed restart left the launch specification pointing at the binary
that had just failed, so no later change was ever seen as a change.

Two suites cover it. `resolveExecutable` drives the selection table through real
settings, with stubs only for the output channel and the interpreter lookup, so
the fallback reasons that end up in the output channel are asserted directly.
`language server recovery` drives a real `LanguageClient` at a binary that
cannot start, and checks that the specification is put back and a server is
still running afterwards — the second half matters because a client whose start
failed cannot be restarted, only replaced, so a running server is the only proof
the replacement path works.

Both need a real extension host rather than mocks, because the behaviour they
depend on belongs to `vscode-languageclient`. Mocking it would assert our
assumptions about it instead. `activate` therefore returns a small hook so tests
drive restarts directly rather than racing the configuration listener.

Running them per pull request is close to free: `pyrefly.yml` already builds a
release binary, so the new step copies it into `lsp/bin` and runs the suite on
one platform. Until now nothing about the extension ran before merge — not even
type checking.

Differential Revision: D119697409
@github-actions github-actions Bot added size/xl and removed size/xl labels Sep 14, 2026
connernilsen and others added 4 commits September 14, 2026 11:44
…facebook#4649)

Summary:
Part two addressing facebook#4306

This should make it so we can get the Pyrefly binary from the environment (and do that by default), as well as update how the selections are made.

Not sure if this is going to be a popular decision, but I made `lspPath` only used when set in the `pyreflyExecutable` setting since that makes testing easier, but that behavior may differ from expectations.


Reviewed By: grievejia

Differential Revision: D117314161

Pulled By: connernilsen
…tartup racing with environment changes

Reviewed By: grievejia

Differential Revision: D119722762
Summary:
Add tests validating the interpreter finder Python script and type checking the VSCode extension.


Differential Revision: D118901054
Summary:

The extension now picks its Pyrefly binary at runtime and restarts the language
server when that choice changes. Neither had a test, and review found real bugs
in both: a failed restart left the launch specification pointing at the binary
that had just failed, so no later change was ever seen as a change.

Two suites cover it. `resolveExecutable` drives the selection table through real
settings, with stubs only for the output channel and the interpreter lookup, so
the fallback reasons that end up in the output channel are asserted directly.
`language server recovery` drives a real `LanguageClient` at a binary that
cannot start, and checks that the specification is put back and a server is
still running afterwards — the second half matters because a client whose start
failed cannot be restarted, only replaced, so a running server is the only proof
the replacement path works.

Both need a real extension host rather than mocks, because the behaviour they
depend on belongs to `vscode-languageclient`. Mocking it would assert our
assumptions about it instead. `activate` therefore returns a small hook so tests
drive restarts directly rather than racing the configuration listener.

Running them per pull request is close to free: `pyrefly.yml` already builds a
release binary, so the new step copies it into `lsp/bin` and runs the suite on
one platform. Until now nothing about the extension ran before merge — not even
type checking.

Differential Revision: D119697409

@kinto0 kinto0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review automatically exported from Phabricator review in Meta.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants