Use a number regex for running spec examples #3514
Merged
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
Since we cannot guarantee that we will discover spec examples at the exact order Minitest will (because of the runtime vs static analysis difference), we use line numbers to ensure that the discovery and result reporting IDs will match.
However, for running the tests, we cannot use the line number information as that may not match the spec ID Minitest has assigned to that particular example. We can fix that by substituting that part of the command for a regex.
Implementation
Minitest formats the spec count with 4 digits, so I started replacing the
test_XXXX
for the regextest_\d{4}
. Note that this is still specific enough to run the right tests since we include the group's name and the rest of the example name.Automated Tests
Updated our tests.