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

Add discover tests custom request #3180

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

vinistock
Copy link
Member

@vinistock vinistock commented Feb 11, 2025

Motivation

Closes #3171

Add a new custom request to discover tests in a specific document. This request will instantiate all listeners and collect all of the discovered groups and examples as test items for the editor.

Implementation

  • Created the new request
  • Implement a listener dedicated to the test style syntax only (spec will be a separate listener)
  • Ensured to use ancestor linearization to determine the test framework

Automated Tests

Added tests.

@vinistock vinistock added enhancement New feature or request server This pull request should be included in the server gem's release notes labels Feb 11, 2025
Copy link
Member Author

vinistock commented Feb 11, 2025


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 force-pushed the 01-31-add_discover_tests_custom_request branch from b31b6f4 to 86b8fe1 Compare February 11, 2025 20:21
@vinistock vinistock self-assigned this Feb 11, 2025
@vinistock vinistock marked this pull request as ready for review February 11, 2025 20:24
@vinistock vinistock requested a review from a team as a code owner February 11, 2025 20:24
@vinistock vinistock force-pushed the 01-31-add_discover_tests_custom_request branch from 86b8fe1 to 1290c28 Compare February 11, 2025 21:16
@vinistock vinistock force-pushed the 01-31-add_test_items_collection_builder branch from dfcc5be to b80e1d8 Compare February 11, 2025 21:16
@vinistock vinistock requested a review from st0012 February 11, 2025 21:20
@vinistock vinistock force-pushed the 01-31-add_discover_tests_custom_request branch from 1290c28 to 7676523 Compare February 12, 2025 14:24
@vinistock vinistock force-pushed the 01-31-add_test_items_collection_builder branch from b80e1d8 to 90ea02f Compare February 12, 2025 14:24
@vinistock vinistock force-pushed the 01-31-add_test_items_collection_builder branch 2 times, most recently from e9cbf36 to debbee7 Compare February 12, 2025 16:54
@vinistock vinistock force-pushed the 01-31-add_discover_tests_custom_request branch 2 times, most recently from 1170bf3 to 4760446 Compare February 12, 2025 18:48
@vinistock vinistock force-pushed the 01-31-add_test_items_collection_builder branch from debbee7 to 675fbff Compare February 12, 2025 18:48
@vinistock vinistock force-pushed the 01-31-add_discover_tests_custom_request branch from 4760446 to 8f68f57 Compare February 12, 2025 21:32
@vinistock vinistock force-pushed the 01-31-add_discover_tests_custom_request branch from 8f68f57 to 8dcf69e Compare February 13, 2025 14:25
@vinistock vinistock force-pushed the 01-31-add_test_items_collection_builder branch from 675fbff to aff14cb Compare February 13, 2025 14:25
@vinistock vinistock force-pushed the 01-31-add_discover_tests_custom_request branch from 8dcf69e to f4582ce Compare February 13, 2025 15:42
@vinistock vinistock force-pushed the 01-31-add_test_items_collection_builder branch 2 times, most recently from 3c2c02a to f5093ce Compare February 13, 2025 17:48
@vinistock vinistock force-pushed the 01-31-add_discover_tests_custom_request branch from f4582ce to dcd90c6 Compare February 13, 2025 17:48
@vinistock vinistock changed the base branch from 01-31-add_test_items_collection_builder to graphite-base/3180 February 13, 2025 18:23
@vinistock vinistock force-pushed the 01-31-add_discover_tests_custom_request branch from dcd90c6 to 4e5dceb Compare February 13, 2025 18:55
@vinistock vinistock changed the base branch from graphite-base/3180 to main February 13, 2025 18:55
Copy link

graphite-app bot commented Feb 13, 2025

Merge activity

  • Feb 13, 2:32 PM EST: A user added this pull request to the Graphite merge queue.
  • Feb 13, 2:42 PM EST: The Graphite merge queue couldn't merge this PR because it was not satisfying all requirements (Failed CI: 'Ruby 3.2 on macos-latest').

### Motivation

Closes #3171

Add a new custom request to discover tests in a specific document. This request will instantiate all listeners and collect all of the discovered groups and examples as test items for the editor.

### Implementation

- Created the new request
- Implement a listener dedicated to the test style syntax only (spec will be a separate listener)
- Ensured to use ancestor linearization to determine the test framework

### Automated Tests

Added tests.
@graphite-app graphite-app bot force-pushed the 01-31-add_discover_tests_custom_request branch from 4e5dceb to 7d66850 Compare February 13, 2025 19:33
@vinistock vinistock merged commit 7db4a9f into main Feb 13, 2025
41 of 42 checks passed
@vinistock vinistock deleted the 01-31-add_discover_tests_custom_request branch February 13, 2025 20:00
vinistock added a commit that referenced this pull request Feb 13, 2025
* Add discover tests custom request (#3180)

### Motivation

Closes #3171

Add a new custom request to discover tests in a specific document. This request will instantiate all listeners and collect all of the discovered groups and examples as test items for the editor.

### Implementation

- Created the new request
- Implement a listener dedicated to the test style syntax only (spec will be a separate listener)
- Ensured to use ancestor linearization to determine the test framework

### Automated Tests

Added tests.

* Resolve test items with server request (#3186)

### Motivation

Closes #3173

Start firing our new custom request to discover which tests are available in a given file.

### Implementation

We fire the request and then recursively add test items to their respective collections. If a document is saved, we check to see if we created a test item for it and then we clear its children (the tests defined inside of the file) and re-trigger the request.

I chose to use on save because on change would put a lot of pressure on the server.

### Automated Tests

Added tests.

---------

Co-authored-by: vinistock <[email protected]>
Copy link
Contributor

@andyw8 andyw8 left a comment

Choose a reason for hiding this comment

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

I had started reviewing before it was merged but there's nothing critcal.


sig { params(node: Prism::ClassNode).void }
def on_class_node_enter(node)
@visibility_stack << :public
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to use symbols here rather than VisibilityScope?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's what we were using before in the original implementation in code lens. I think the bigger refactor here is realizing that many listeners need to keep track of scopes, so maybe we can implement our own Prism::Dispatcher subclass that automatically tracks this, so that we don't need to duplicate the logic in multiple places.

lib/ruby_lsp/listeners/test_style.rb Show resolved Hide resolved
lib/ruby_lsp/listeners/test_style.rb Show resolved Hide resolved
end
def initialize(response_builder, global_state, dispatcher, uri)
@response_builder = response_builder
@global_state = global_state
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like ivar is unused?

test/requests/discover_tests_test.rb Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request server This pull request should be included in the server gem's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement custom request to discovery all test groups and examples in a file
3 participants