Module: Kernel
- Defined in:
- lib/golly-utils/ruby_ext/kernel.rb
Instance Method Summary collapse
-
#at_exit_preserving_exit_status(&block) ⇒ Proc
Alternate implementation of
at_exitthat preserves the exit status (unless you callexityourself and an error is raised).
Instance Method Details
#at_exit_preserving_exit_status(&block) ⇒ Proc
Alternate implementation of at_exit that preserves the exit status (unless you call exit yourself and an error
is raised).
The initial driver for this was that using at_exit to clean up global resources in RSpec tests, RSpec's exit
status would be lost which means CI processes and such were unable to tell whether there were test failures.
10 11 12 13 14 15 16 |
# File 'lib/golly-utils/ruby_ext/kernel.rb', line 10 def at_exit_preserving_exit_status(&block) at_exit { status= $!.is_a?(::SystemExit) ? $!.status : nil block.() exit status if status } end |