Skip to content

Write TCP server port to a tempfile instead of using env var #3452

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

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented May 2, 2025

Motivation

The strategy of passing the port to LSP reporter via environment variable is a bit weak. For example, if you reload VS Code and then proceed to run tests manually in a terminal that we set up, you will get a connection refused error because we never updated the port variable in that old terminal.

I think we can be a lot more reliable by writing the port to a file.

Implementation

Every workspace reports test results through the same port, so my idea is to write a temporary file with the port information that the LSP reporter can read on its own.

That way, every time the extension reloads, we update the port in the file and, every time the tests are executed (regardless if it's manual or through the explorer), we will read that value again ensuring that we're using the right port.

Finally, I noticed one more hurdle. When running tests manually through the terminal, we were receiving the connection okay, but there was no run object to use for reporting the items' statuses. We need to create a run object on demand when not running through the explorer, otherwise the statuses won't appear as expected.

@vinistock vinistock added vscode This pull request should be included in the VS Code extension's release notes bugfix This PR will fix an existing bug labels May 2, 2025 — with Graphite App
Copy link
Member Author


How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vinistock vinistock self-assigned this May 2, 2025
@vinistock vinistock requested review from alexcrocha and st0012 May 2, 2025 19:16
@vinistock vinistock marked this pull request as ready for review May 2, 2025 19:21
@vinistock vinistock requested a review from a team as a code owner May 2, 2025 19:21
@vinistock vinistock force-pushed the 05-02-write_tcp_server_port_to_a_tempfile_instead_of_using_env_var branch 2 times, most recently from 17aabe4 to fb817c8 Compare May 2, 2025 19:53
@vinistock vinistock requested a review from amomchilov May 2, 2025 20:08
@vinistock vinistock force-pushed the 05-02-write_tcp_server_port_to_a_tempfile_instead_of_using_env_var branch from fb817c8 to 5fac84e Compare May 2, 2025 21:01
@vinistock vinistock force-pushed the 05-02-write_tcp_server_port_to_a_tempfile_instead_of_using_env_var branch from 5fac84e to 45dae57 Compare May 2, 2025 21:09
Copy link
Contributor

@amomchilov amomchilov left a comment

Choose a reason for hiding this comment

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

Some questions, but LGTM overall

Co-authored-by: Alexander Momchilov <amomchilov@users.noreply.github.com>
@vinistock vinistock merged commit c0f568b into main May 5, 2025
42 checks passed
@vinistock vinistock deleted the 05-02-write_tcp_server_port_to_a_tempfile_instead_of_using_env_var branch May 5, 2025 20:26
st0012 added a commit to st0012/ruby-lsp-rspec that referenced this pull request May 10, 2025
st0012 added a commit to st0012/ruby-lsp-rspec that referenced this pull request May 10, 2025
* WIP

* Implement RSpec command resolution

* Support streaming RSpec results

* Generate ids purely based on locations

This makes sure that we can always match the ids
even for anonymous examples.

* Add tests for the rspec formatter

* Don't fail fast on CI

* Allow RSpecFormatter to not have typed: strict

* Requires ruby-lsp 0.23.17

For Shopify/ruby-lsp#3452
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugfix This PR will fix an existing bug vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants