-
Notifications
You must be signed in to change notification settings - Fork 685
Misc LSP server / fourslash testing improvements #1591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR improves the testing infrastructure for the LSP server and fourslash tests by enhancing lifecycle management and logging capabilities. The changes focus on proper context handling, test cleanup, and error reporting.
Key changes:
- Added context-based lifecycle management to the LSP server
- Improved test logging by directing LSP stderr to test output
- Enhanced test cleanup with proper LSP server shutdown and error handling
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
internal/lsp/server.go | Modified Run method to accept context parameter and removed signal handling |
internal/fourslash/fourslash.go | Added context management, improved error handling, and redirected LSP stderr to test output |
cmd/tsgo/main.go | Added signal context creation at main entry point |
cmd/tsgo/lsp.go | Updated runLSP to accept and pass context to server |
internal/fourslash/fourslash.go
Outdated
select { | ||
case <-ctx.Done(): | ||
// do nothing | ||
case err := <-lspErrChan: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a potential race condition where the LSP server might complete before the test cleanup runs, causing the channel read to block indefinitely. Consider using a select with a timeout or making the channel read non-blocking with a default case.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The channel is buffered above. And if the server never exits, that's a bug and the test should time out / report a deadlock.
This comment was marked as outdated.
This comment was marked as outdated.
No, I just caused a race. Will figure it out. |
t.Output()
, which means tests will actually get logging.I moved the main context all the way up to
main
, since eventually we'll plumb it downward to the other commands. The movement means the LSP tests are not watching signals (which was an oops and caused weirdness).