Add spec for use of :base in Dir#glob and tag it #2377
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.
Issue
We found this exception because it broke the TruffleRuby CI on SFR.
TL;DR: If there are no path entries and the entry type is
EndsWithEntryMatch
, a nil class error will occur with the#end_with?(suffix)
check.I did some digging and it seems like there is no issue if
Dir#glob
is run without a base:Dir.glob('**/*.rake')
. The code path diverges at this line when there is noglob_base_dir
specified. In the problematic case, the@next
isEndsWithEntryMatch
, and when this Entry type is processed with no entry, there is a NilClass exception on#end_with?
Change
This change is just the test case that covers the issue. It passes on Ruby 2.7.3 and returns the exception (as seen above) on TrufleRuby.
Question
I don't have a lot of new context on the new
Dir#glob
changes, but this issue has something to do with the recent changes.I have a branch here at gets rid of the exception but it does not pass the spec I added because the resulting array includes the file path of the mismatched directory.
Any idea to what the issue may be?