Skip to content

Commit fa653f2

Browse files
committed
Add spec for #exit! in #at_exit
* See #2047
1 parent d6e56aa commit fa653f2

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

spec/ruby/shared/process/exit.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,18 @@
9191
out.should == ""
9292
$?.exitstatus.should == 21
9393
end
94+
95+
it "overrides the original exception and exit status when called from #at_exit" do
96+
code = <<-RUBY
97+
at_exit do
98+
STDERR.puts 'in at_exit'
99+
STDERR.puts "$! is \#{$!.class}:\#{$!.message}"
100+
#{@object}.send(:exit!, 21)
101+
end
102+
raise 'original error'
103+
RUBY
104+
out = ruby_exe(code, args: '2>&1')
105+
out.should == "in at_exit\n$! is RuntimeError:original error\n"
106+
$?.exitstatus.should == 21
107+
end
94108
end

spec/tags/core/kernel/exit_tags.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ slow:Kernel#exit! exits when called from a fiber
44
slow:Kernel.exit! exits with the given status
55
slow:Kernel.exit! exits when called from a thread
66
slow:Kernel.exit! exits when called from a fiber
7+
slow:Kernel#exit! overrides the original exception and exit status when called from #at_exit
8+
slow:Kernel.exit! overrides the original exception and exit status when called from #at_exit

spec/tags/core/process/exit_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
slow:Process.exit! exits with the given status
22
slow:Process.exit! exits when called from a thread
33
slow:Process.exit! exits when called from a fiber
4+
slow:Process.exit! overrides the original exception and exit status when called from #at_exit

0 commit comments

Comments
 (0)