Created
August 16, 2012 08:35
-
-
Save mhenrixon/3368432 to your computer and use it in GitHub Desktop.
Monkey patch to make ruby exit codes work with continuous integration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monkey Patch ruby because of a bug introduced in ruby versions greater than 1.9.2 | |
# For some reason the exit code is all wrong in later version of ruby and even though | |
# the issue was closed as sorted it's still broken in ruby version 1.9.3-p194. | |
# (see http://redmine.ruby-lang.org/issues/5218 for more information) | |
# Put this in spec_helper.rb or test_helper.rb so that it only affects specs and the CI server. | |
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION >= "1.9" | |
module Kernel | |
alias :__at_exit :at_exit | |
def at_exit(&block) | |
__at_exit do | |
exit_status = $!.status if $!.is_a?(SystemExit) | |
block.call | |
exit exit_status if exit_status | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment