-
Notifications
You must be signed in to change notification settings - Fork 225
Don't generate test code lenses when the test library is not supported #769
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
…d/unknown Since we want extensions to provide code lenses for libraries like RSpec, we should not generate any code lens ourselves when the test library is not supported/unknown. Otherwise it could create wrong code lenses and mess with with what our extensions generate.
| sig { params(node: SyntaxTree::Node, name: String, command: String, kind: Symbol).void } | ||
| def add_test_code_lens(node, name:, command:, kind:) | ||
| # don't add code lenses if the test library is not supported or unknown | ||
| return unless SUPPORTED_TEST_LIBRARIES.include?(@test_library) |
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.
Just an idea: if we split test code lens listeners into 2, like TestCodeLens and BundlerCodeLens, we can skip registering events in TestCodeLens if the test library is not supported. I think this will save us some unnecessary computation.
If it's preferred, now could be a good time for this before we ship ruby-lsp-rails' code lens support.
WDYT? @vinistock @andyw8
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.
I think it's not critical for now though, we can bump the ruby-lsp-rails dependency later if we refactor things.
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.
I don't think splitting is worth the complexity yet.
|
| sig { params(node: SyntaxTree::Node, name: String, command: String, kind: Symbol).void } | ||
| def add_test_code_lens(node, name:, command:, kind:) | ||
| # don't add code lenses if the test library is not supported or unknown | ||
| return unless SUPPORTED_TEST_LIBRARIES.include?(@test_library) |
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.
I don't think splitting is worth the complexity yet.
| response = listener.response | ||
|
|
||
| assert_equal(0, response.size) |
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.
| response = listener.response | |
| assert_equal(0, response.size) | |
| assert_empty(listener.response) |
| response = listener.response | ||
|
|
||
| assert_equal(0, response.size) |
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.
| response = listener.response | |
| assert_equal(0, response.size) | |
| assert_empty(listener.response) |
| assert_equal(0, response.size) | ||
| end | ||
|
|
||
| def test_no_code_lens_for_rspec |
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.
Does this test verify any behaviour that the unknown one doesn't? Do we need both?
…de-20.5.7 Bump @types/node from 20.5.1 to 20.5.7
Motivation
Since we want extensions to provide code lenses for libraries like RSpec, we should not generate any code lens ourselves when the test library is not supported/unknown. Otherwise it could create wrong code lenses and mess with with what our extensions generate.
Implementation
minitest, we simply returnunknownif it's not a known one.Automated Tests
Added 2 test cases to make sure code lenses will not be generated when the library is
rspecorunknown.Manual Tests