From 1ed0212bcf76ec244ca5b75c65f09e5b04158377 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA 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 --- test/ruby/test_autoload.rb | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'test/ruby/test_autoload.rb') diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index e9e13eef96..2e53c9203d 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -76,12 +76,12 @@ p Foo::Bar 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 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 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 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 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 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 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 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 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 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 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 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 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 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 -- cgit v1.2.3