Make sure to only reset "dummy" $LOADED_FEATURES

Namely, those generated under `/tmp`.

The previous approach was brittle and broken in the case of ruby-core,
because under that setup, the current folder is in the original
`$LOAD_PATH`, and dummy features are created under `./tmp`, so they were
failing to be reset.
This commit is contained in:
David Rodríguez 2020-06-16 16:26:31 +02:00 committed by Hiroshi SHIBATA
parent f5459acd79
commit 106d616cc8
Notes: git 2020-06-17 21:17:30 +09:00

View file

@ -429,11 +429,8 @@ class Gem::TestCase < Minitest::Test
$LOAD_PATH.replace @orig_LOAD_PATH if @orig_LOAD_PATH
if @orig_LOADED_FEATURES
if @orig_LOAD_PATH
paths = @orig_LOAD_PATH.map {|path| File.join(File.expand_path(path), "/") }
($LOADED_FEATURES - @orig_LOADED_FEATURES).each do |feat|
unless paths.any? {|path| feat.start_with?(path) }
$LOADED_FEATURES.delete(feat)
end
$LOADED_FEATURES.delete(feat) if feat.start_with?(@tmp)
end
else
$LOADED_FEATURES.replace @orig_LOADED_FEATURES