Fix minitest spec code lens load path #2706
Merged
+212
−170
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.
Motivation
Fixes #2308 and #2688.
This PR changes the code lens base test command to add
spec
to the load path instead oftest
if the current path is inside aspec
directory (for example tapioca).Implementation
It checks to see whether the current path is inside a
spec
directory or atest
directory and adds an appropriate-I
argument to the base command.This changes the default behavior—if the current path is in neither a
spec
ortest
directory it no longer adds-Itest
. Is this reasonable behavior?There are of course weird edge cases here, for example if the path is inside both a
spec
andtest
directory (liketest/spec/foo_test.rb
). In that case bothtest
andspec
would be added to the load path, but I don't currently see a better way of guessing which directory should be in the load path.Automated Tests
I added a new test case to capture the behavior for minitest spec code lens. I also regenerated the expectation JSON files, which have mostly changed just to remove
-Itest
. We could change the logic so-Itest
is added by default, even if it's not in atest
directory, and only switch to-Ispec
if necessary. That would minimize the expectation JSON changes here.Manual Tests
Use code lens to run specs in the tapioca codebase (upgrade to latest minitest first):
spec-code-lens.mov
Use code lens to make sure non-spec tests still work fine:
test-code-lens.mov