Test extension binary selection and restart recovery (#4907) - #4907
Open
connernilsen wants to merge 4 commits into
Open
connernilsen wants to merge 4 commits into
connernilsen wants to merge 4 commits into
Conversation
Contributor
|
@connernilsen has exported this pull request. If you are a Meta employee, you can view the originating Diff in D119697409. |
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
connernilsen
force-pushed
the
export-D119697409
branch
from
September 14, 2026 16:04
42546b5 to
e6e7d38
Compare
…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
connernilsen
force-pushed
the
export-D119697409
branch
from
September 14, 2026 18:44
e6e7d38 to
9c794a4
Compare
kinto0
requested changes
Sep 14, 2026
kinto0
left a comment
Contributor
There was a problem hiding this comment.
Review automatically exported from Phabricator review in Meta.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
resolveExecutabledrives the selection table through realsettings, 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 recoverydrives a realLanguageClientat a binary thatcannot 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 ourassumptions about it instead.
activatetherefore returns a small hook so testsdrive restarts directly rather than racing the configuration listener.
Running them per pull request is close to free:
pyrefly.ymlalready builds arelease binary, so the new step copies it into
lsp/binand runs the suite onone platform. Until now nothing about the extension ran before merge — not even
type checking.
Differential Revision: D119697409