Auto resolve first test file of each top level directory #3349
+275
−368
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
We identified a challenge when resolving test commands for entire test directories where not every file has been expanded. How do we know what add-on should resolve the command if we haven't discovered the examples inside?
For example, if an application has a
spec
directory, how do we know if we're dealing with RSpec or Minitest spec style? They require different commands to execute the tests inside the directory.One possible solution would be to discover all tests inside the requested directory, but that would be very slow. A decent compromise proposed by @st0012 was to resolve only 1 test file inside a top level directory and then assume that all tests inside of it belong to the same framework. I think this is reasonable given that mixing test frameworks inside the same directory is not a very common usecase.
This PR starts auto resolving 1 of the test files discovered inside each top level test directory and then associates everything nested under that directory with the same framework tag, so that add-ons can resolve commands only for the items they are interested in.
Implementation
The idea is to keep track of the framework tag during test file discovery. Whenever we find a new top level test dir, we reset the tag to discover it again.
Then we resolve the specific test file, so that the server can return what framework that file is associated with, which we associate to all items under that directory.
Automated Tests
There were some duplicate examples in our tests and quite a bit of duplicate code. I cleaned them up a little bit and adjusted some expectations.