From 2898d5c5a8a6be42888bdabaf2f812c711bda88a Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 23 Mar 2007 16:53:42 +0000 Subject: * eval.c (ruby_cleanup): exit by SystemExit and SignalException in END block. [ruby-core:10609] * test/ruby/test_beginendblock.rb (test_should_propagate_exit_code): test for exit in END block. [ruby-core:10760] * test/ruby/test_beginendblock.rb (test_should_propagate_signaled): test for signal in END block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_beginendblock.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'test') diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb index b56b596a65..4ac8de10ff 100644 --- a/test/ruby/test_beginendblock.rb +++ b/test/ruby/test_beginendblock.rb @@ -54,4 +54,34 @@ EOW assert_equal(expected, File.read(erroutpath)) # expecting Tempfile to unlink launcher and errout file. end + + def test_raise_in_at_exit + # [ruby-core:09675] + ruby = EnvUtil.rubybin + out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \ + "at_exit{raise %[SomethingBad]};" \ + "raise %[SomethingElse]'") {|f| + f.read + } + assert_match /SomethingBad/, out + assert_match /SomethingElse/, out + end + + def test_should_propagate_exit_code + ruby = EnvUtil.rubybin + assert_equal false, system("#{q(ruby)} -e 'at_exit{exit 2}'") + assert_equal 2, $?.exitstatus + assert_nil $?.termsig + end + + def test_should_propagate_signaled + ruby = EnvUtil.rubybin + out = IO.popen("#{q(ruby)} -e 'STDERR.reopen(STDOUT);" \ + "at_exit{Process.kill(:INT, $$)}'"){|f| + f.read + } + assert_match /Interrupt$/, out + assert_nil $?.exitstatus + assert_equal Signal.list["INT"], $?.termsig + end end -- cgit v1.2.3