ruby-changes:58842
From: Kazuhiro <ko1@a...>
Date: Tue, 19 Nov 2019 17:37:54 +0900 (JST)
Subject: [ruby-changes:58842] 822d7ae316 (master): Add a test
https://git.ruby-lang.org/ruby.git/commit/?id=822d7ae316 From 822d7ae31659e4ab60c4d1aa6d088577d6bc74b0 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA <zn@m...> Date: Tue, 19 Nov 2019 17:34:43 +0900 Subject: Add a test and rename from b.rb [ruby-core:95055] [Bug #16177] diff --git a/test/ruby/test_autoload.rb b/test/ruby/test_autoload.rb index 3b013c1..53510e8 100644 --- a/test/ruby/test_autoload.rb +++ b/test/ruby/test_autoload.rb @@ -323,7 +323,7 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L323 def test_autoload_same_file Dir.mktmpdir('autoload') do |tmpdir| - File.write("#{tmpdir}/b.rb", "#{<<~'begin;'}\n#{<<~'end;'}") + File.write("#{tmpdir}/bug14742.rb", "#{<<~'begin;'}\n#{<<~'end;'}") begin; module Foo; end module Bar; end @@ -331,8 +331,8 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L331 3.times do # timing-dependent, needs a few times to hit [Bug #14742] assert_separately(%W[-I #{tmpdir}], "#{<<-'begin;'}\n#{<<-'end;'}") begin; - autoload :Foo, 'b' - autoload :Bar, 'b' + autoload :Foo, 'bug14742' + autoload :Bar, 'bug14742' t1 = Thread.new do Foo end t2 = Thread.new do Bar end t1.join @@ -345,6 +345,26 @@ p Foo::Bar https://github.com/ruby/ruby/blob/trunk/test/ruby/test_autoload.rb#L345 end end + def test_autoload_same_file_with_raise + Dir.mktmpdir('autoload') do |tmpdir| + File.write("#{tmpdir}/bug16177.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' + t1 = Thread.new do Foo end + t2 = Thread.new do Bar end + t1.join + t2.join + end; + end + end + end + def test_no_leak assert_no_memory_leak([], '', <<~'end;', 'many autoloads', timeout: 60) 200000.times do |i| -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/