Skip to content
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

Ensure workspace is fully initialized before discovering tests #3203

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Feb 14, 2025

Motivation

@alexcrocha noticed that when opening the test explorer while the LSP is booting, the test items inside a file wouldn't be populated.

There are two reasons for it:

  1. We need indexing to be completed first before we can discover tests, since discovery requires ancestor linearization and there are no guarantees that we already found all the pieces in the middle of indexing
  2. There was a bug in fetching or lazily activating a workspace that may result in double workspace activation

Implementation

There are a few parts to the solution:

  1. I started capturing the promise for when indexing ends in the client, so that we have a convenient way of checking if it's over. We were already doing it in tests and now we need it for the controller
  2. Our handling with the workspacesBeingLaunched was spread around multiple places, which is a recipe for disaster. I moved all related handling inside the function that activates a workspace, so that no matter from where we're activating, it is guaranteed to be taken into consideration
  3. I also turned workspacesBeingLaunched into a map of workspace index to activation promise. If a workspace is in the middle of being activated, this gives us the opportunity to return that promise so that other parts in the code can await the same activation process
  4. Finally, I started only setting the workspace after we finished awaiting its start. Setting the workspace in the map before invoking start means that invoking getOrActivatedWorskpace will find the non-started workspace and lspClient will be undefined

Automated Tests

Adjusted existing tests.

@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 Feb 14, 2025 — with Graphite App
@vinistock vinistock self-assigned this Feb 14, 2025
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 marked this pull request as ready for review February 14, 2025 21:59
@vinistock vinistock requested a review from a team as a code owner February 14, 2025 21:59
@vinistock vinistock force-pushed the 02-14-ensure_workspace_is_fully_initialized_before_discovering_tests branch from 497ff47 to dfd24c8 Compare February 14, 2025 22:01
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.

1 participant