ruby-changes:59191
From: Kazuhiro <ko1@a...>
Date: Wed, 11 Dec 2019 20:21:36 +0900 (JST)
Subject: [ruby-changes:59191] 1ed0212bcf (master): Do not load files in build directory
https://git.ruby-lang.org/ruby.git/commit/?id=1ed0212bcf From 1ed0212bcf76ec244ca5b75c65f09e5b04158377 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA <zn@m...> Date: Tue, 10 Dec 2019 18:31:01 +0900 Subject: Do not load files in build directory related https://bugs.ruby-lang.org/issues/16177 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index fd3fdf7..8e4cff8 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -87,6 +87,10 @@ jobs: https://github.com/ruby/ruby/blob/trunk/.github/workflows/ubuntu.yml#L87 - name: Extract gems run: make -C build update-gems extract-gems if: matrix.test_task == 'check' + - name: Create dummy files in build dir + run: | + cd build + ./miniruby -e '(("a".."z").to_a+%w[foo bar test zzz]).each{|basename|File.write("#{basename}.rb", "raise %(do not load #{basename}.rb)")}' - name: Tests run: make -C build $JOBS -s ${{ matrix.test_task }} env: diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index e9e13ee..2e53c92 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -76,12 +76,12 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L76 eval <<-END class ::Object module A - autoload :C, 'b' + autoload :C, 'test-ruby-core-69206' end end END - File.open('b.rb', 'w') {|file| file.puts 'module A; class C; end; end'} + File.write("test-ruby-core-69206.rb", 'module A; class C; end; end') assert_kind_of Class, ::A::C end } @@ -257,7 +257,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L257 def test_autoload_private_constant Dir.mktmpdir('autoload') do |tmpdir| - File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}") + File.write(tmpdir+"/test-bug-14469.rb", "#{<<~"begin;"}\n#{<<~'end;'}") begin; class AutoloadTest ZZZ = :ZZZ @@ -268,7 +268,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L268 bug = '[ruby-core:85516] [Bug #14469]' begin; class AutoloadTest - autoload :ZZZ, "zzz.rb" + autoload :ZZZ, "test-bug-14469.rb" end assert_raise(NameError, bug) {AutoloadTest::ZZZ} end; @@ -277,7 +277,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L277 def test_autoload_deprecate_constant Dir.mktmpdir('autoload') do |tmpdir| - File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}") + File.write(tmpdir+"/test-bug-14469.rb", "#{<<~"begin;"}\n#{<<~'end;'}") begin; class AutoloadTest ZZZ = :ZZZ @@ -288,7 +288,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L288 bug = '[ruby-core:85516] [Bug #14469]' begin; class AutoloadTest - autoload :ZZZ, "zzz.rb" + autoload :ZZZ, "test-bug-14469.rb" end assert_warning(/ZZZ is deprecated/, bug) {AutoloadTest::ZZZ} end; @@ -297,7 +297,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L297 def test_autoload_private_constant_before_autoload Dir.mktmpdir('autoload') do |tmpdir| - File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}") + File.write(tmpdir+"/test-bug-11055.rb", "#{<<~"begin;"}\n#{<<~'end;'}") begin; class AutoloadTest ZZZ = :ZZZ @@ -307,7 +307,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L307 bug = '[Bug #11055]' begin; class AutoloadTest - autoload :ZZZ, "zzz.rb" + autoload :ZZZ, "test-bug-11055.rb" private_constant :ZZZ ZZZ end @@ -317,7 +317,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L317 bug = '[Bug #11055]' begin; class AutoloadTest - autoload :ZZZ, "zzz.rb" + autoload :ZZZ, "test-bug-11055.rb" private_constant :ZZZ end assert_raise(NameError, bug) {AutoloadTest::ZZZ} @@ -327,7 +327,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L327 def test_autoload_deprecate_constant_before_autoload Dir.mktmpdir('autoload') do |tmpdir| - File.write(tmpdir+"/zzz.rb", "#{<<~"begin;"}\n#{<<~'end;'}") + File.write(tmpdir+"/test-bug-11055.rb", "#{<<~"begin;"}\n#{<<~'end;'}") begin; class AutoloadTest ZZZ = :ZZZ @@ -337,7 +337,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L337 bug = '[Bug #11055]' begin; class AutoloadTest - autoload :ZZZ, "zzz.rb" + autoload :ZZZ, "test-bug-11055.rb" deprecate_constant :ZZZ end assert_warning(/ZZZ is deprecated/, bug) {class AutoloadTest; ZZZ; end} @@ -347,7 +347,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L347 bug = '[Bug #11055]' begin; class AutoloadTest - autoload :ZZZ, "zzz.rb" + autoload :ZZZ, "test-bug-11055.rb" deprecate_constant :ZZZ end assert_warning(/ZZZ is deprecated/, bug) {AutoloadTest::ZZZ} @@ -383,7 +383,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L383 def test_autoload_same_file Dir.mktmpdir('autoload') do |tmpdir| - File.write("#{tmpdir}/bug14742.rb", "#{<<~'begin;'}\n#{<<~'end;'}") + File.write("#{tmpdir}/test-bug-14742.rb", "#{<<~'begin;'}\n#{<<~'end;'}") begin; module Foo; end module Bar; end @@ -391,8 +391,8 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L391 3.times do # timing-dependent, needs a few times to hit [Bug #14742] assert_separately(%W[-I #{tmpdir}], "#{<<-'begin;'}\n#{<<-'end;'}") begin; - autoload :Foo, 'bug14742' - autoload :Bar, 'bug14742' + autoload :Foo, 'test-bug-14742' + autoload :Bar, 'test-bug-14742' t1 = Thread.new do Foo end t2 = Thread.new do Bar end t1.join @@ -407,15 +407,15 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L407 def test_autoload_same_file_with_raise Dir.mktmpdir('autoload') do |tmpdir| - File.write("#{tmpdir}/bug16177.rb", "#{<<~'begin;'}\n#{<<~'end;'}") + File.write("#{tmpdir}/test-bug-16177.rb", "#{<<~'begin;'}\n#{<<~'end;'}") begin; raise '[ruby-core:95055] [Bug #16177]' end; assert_raise(RuntimeError, '[ruby-core:95055] [Bug #16177]') do assert_separately(%W[-I #{tmpdir}], "#{<<-'begin;'}\n#{<<-'end;'}") begin; - autoload :Foo, 'bug16177' - autoload :Bar, 'bug16177' + autoload :Foo, 'test-bug-16177' + autoload :Bar, 'test-bug-16177' t1 = Thread.new do Foo end t2 = Thread.new do Bar end t1.join diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index e310ac7..05dc18c 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -818,9 +818,9 @@ class TestRequire < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_require.rb#L818 rescue NotImplementedError, Errno::EACCES skip "File.symlink is not implemented" end - File.write(File.join(tmp, "real/a.rb"), "print __FILE__") - result = IO.popen([EnvUtil.rubybin, "-I#{tmp}/symlink", "-e", "require 'a.rb'"], &:read) - assert_operator(result, :end_with?, "/real/a.rb") + File.write(File.join(tmp, "real/test_symlink_load_path.rb"), "print __FILE__") + result = IO.popen([EnvUtil.rubybin, "-I#{tmp}/symlink", "-e", "require 'test_symlink_load_path.rb'"], &:read) + assert_operator(result, :end_with?, "/real/test_symlink_load_path.rb") } end diff --git a/test/rubygems/test_gem.rb b/test/rubygems/test_gem.rb index 859aba6..47ef8a3 100644 --- a/test/rubygems/test_gem.rb +++ b/test/rubygems/test_gem.rb @@ -1388,7 +1388,7 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L1388 a = util_spec "a", "1" b = util_spec "b", "1", "c" => nil c = util_spec "c", "2" - d = util_spec "d", "1", {'e' => '= 1'}, "lib/d.rb" + d = util_spec "d", "1", {'e' => '= 1'}, "lib/d#{$$}.rb" e = util_spec "e", "1" install_specs a, c, b, e, d @@ -1397,7 +1397,7 @@ class TestGem < Gem::TestCase https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem.rb#L1397 r.gem "a" r.gem "b", "= 1" - require 'd' + require "d#{$$}" end assert_equal %w!a-1 b-1 c-2 d-1 e-1!, loaded_spec_names diff --git a/test/rubygems/test_gem_specification.rb b/test/rubygems/test_gem_specification.rb index 8f345f8..dbd45a3 100644 --- a/test/rubygems/test_gem_specification.rb +++ b/test/rubygems/test_gem_specification.rb @@ -126,8 +126,8 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L126 def test_self_activate_ambiguous_direct save_loaded_features do a1 = util_spec "a", "1", "b" => "> 0" - b1 = util_spec("b", "1", { "c" => ">= 1" }, "lib/d.rb") - b2 = util_spec("b", "2", { "c" => ">= 2" }, "lib/d.rb") + b1 = util_spec("b", "1", { "c" => ">= 1" }, "lib/d#{$$}.rb") + b2 = util_spec("b", "2", { "c" => ">= 2" }, "lib/d#{$$}.rb") c1 = util_spec "c", "1" c2 = util_spec "c", "2" @@ -138,7 +138,7 @@ end https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_specification.rb#L138 assert_equal %w(a-1), loaded_spec_names assert_equal ["b (> 0)"], unresolved_names - require "d" + require "d#{$$}" (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/