mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) ddb32e6616
: [Backport #18173]
[Bug #18173] Update loaded_features_index If $LOADED_FEATURES is changed in the just required file, also the index table needs to be updated before loaded_features_snapshot is reset. If the snapshot is reset without updating the table, the name of the added feature will not be found. --- load.c | 1 + test/ruby/test_require.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+)
This commit is contained in:
parent
efa1ba15fd
commit
5341eca588
3 changed files with 20 additions and 2 deletions
1
load.c
1
load.c
|
@ -606,6 +606,7 @@ rb_provide_feature(VALUE feature)
|
|||
}
|
||||
rb_str_freeze(feature);
|
||||
|
||||
get_loaded_features_index();
|
||||
rb_ary_push(features, rb_fstring(feature));
|
||||
features_index_add(feature, INT2FIX(RARRAY_LEN(features)-1));
|
||||
reset_loaded_features_snapshot();
|
||||
|
|
|
@ -839,6 +839,23 @@ class TestRequire < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_provide_in_required_file
|
||||
paths, loaded = $:.dup, $".dup
|
||||
Dir.mktmpdir do |tmp|
|
||||
provide = File.realdirpath("provide.rb", tmp)
|
||||
File.write(File.join(tmp, "target.rb"), "raise __FILE__\n")
|
||||
File.write(provide, '$" << '"'target.rb'\n")
|
||||
$:.replace([tmp])
|
||||
assert(require("provide"))
|
||||
assert(!require("target"))
|
||||
assert_equal($".pop, provide)
|
||||
assert_equal($".pop, "target.rb")
|
||||
end
|
||||
ensure
|
||||
$:.replace(paths)
|
||||
$".replace(loaded)
|
||||
end
|
||||
|
||||
if defined?($LOAD_PATH.resolve_feature_path)
|
||||
def test_resolve_feature_path
|
||||
paths, loaded = $:.dup, $".dup
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||
#define RUBY_VERSION_TEENY 3
|
||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||
#define RUBY_PATCHLEVEL 138
|
||||
#define RUBY_PATCHLEVEL 139
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2021
|
||||
#define RUBY_RELEASE_MONTH 10
|
||||
#define RUBY_RELEASE_DAY 2
|
||||
#define RUBY_RELEASE_DAY 3
|
||||
|
||||
#include "ruby/version.h"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue