[rubygems/rubygems] Keep loaded features

Now `$LOADED_FEATURES` list is being maintained by `setup` and
`teardown` and, only libaries under the temporary directory will
be removed.  As `save_loaded_features` removes the rest libraries
other than this test directory, ordinary libraries loaded from
files under rubygems also removed, and often causes constant
redefinition warnings.

https://github.com/rubygems/rubygems/commit/9e1f92aafd
This commit is contained in:
Nobuyoshi Nakada 2021-10-13 22:19:25 +09:00 committed by git
parent 1aa9fcca76
commit 3f0150f2fd

View File

@ -826,13 +826,7 @@ class Gem::TestCase < Test::Unit::TestCase
end
def save_loaded_features
old_loaded_features = $LOADED_FEATURES.dup
yield
ensure
prefix = File.dirname(__FILE__) + "/"
new_features = ($LOADED_FEATURES - old_loaded_features)
old_loaded_features.concat(new_features.select {|f| f.rindex(prefix, 0) })
$LOADED_FEATURES.replace old_loaded_features
end
def new_default_spec(name, version, deps = nil, *files)