ruby-changes:68220
From: nagachika <ko1@a...>
Date: Sun, 3 Oct 2021 16:33:21 +0900 (JST)
Subject: [ruby-changes:68220] 5341eca588 (ruby_3_0): merge revision(s) ddb32e66160ab50849419ef7c7ac584913b79c34: [Backport #18173]
https://git.ruby-lang.org/ruby.git/commit/?id=5341eca588 From 5341eca588e738cd5031ab7d8bb5c300471c00e9 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sun, 3 Oct 2021 16:10:01 +0900 Subject: merge revision(s) ddb32e66160ab50849419ef7c7ac584913b79c34: [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(+) --- load.c | 1 + test/ruby/test_require.rb | 17 +++++++++++++++++ version.h | 4 ++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/load.c b/load.c index 2d931b91f0..e5b0ff435d 100644 --- a/load.c +++ b/load.c @@ -606,6 +606,7 @@ rb_provide_feature(VALUE feature) https://github.com/ruby/ruby/blob/trunk/load.c#L606 } 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(); diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 4c8faadbc7..52566ecbfb 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -839,6 +839,23 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L839 } 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 diff --git a/version.h b/version.h index 7a107b85fe..43799945f5 100644 --- a/version.h +++ b/version.h @@ -12,11 +12,11 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L12 # 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" -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/