fix: TestDiscovery items missing test_case/test_group tags causes Run in Terminal to run entire file#103
Open
tudorbertiean wants to merge 1 commit into
Conversation
… in Terminal to run entire file Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Author
|
@st0012 let me know what you think - open to any feedback on this one |
7317058 to
a7f7db4
Compare
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.
The problem
When clicking "Run in Terminal" on a specific test in the Test Explorer, the generated command runs the entire spec file instead of just that test.
resolve_test_commands(link) usestest_caseandtest_grouptags to decide whether to include a line number in the command. ButTestDiscoverynever sets those tags — items only ever get["framework:rspec"]. So every item falls through to theelsebranch, which adds the full file path with no line number.Other options considered
1. Fix the
elsebranch inresolve_test_commands— infer intent from structure: leaf nodes (no children) are test cases and should include a line number. This works but sidesteps the root cause and leaves thetest_case/test_groupbranches as unreachable dead code.2. Add
add_tagtoTestItemin ruby-lsp — the cleanest fix long-term, sinceTestItemis the right home for this and it would be part of the public addon API. The reason it doesn't exist is that the built-in Minitest listener lives inside ruby-lsp and can access@tagsdirectly, so there was never pressure to expose it.Test plan
test_group/test_casetag assertions totest_discovery_spec.rbadd_tagtest tospec_style_patch_spec.rbbundle exec srb tc— no errorsbundle exec rspec— all examples pass