Browse files

at_exit: don't mask nonzero exit status due to $!

This change ensures that RSpec's at_exit handler doesn't mask (override)
any nonzero exit status, which can happen when Ruby is on it's way out
due to an uncaught exception ($!) such as a SyntaxError.

Please see this bug report for more information:

sunaku/tork#31 (comment)
  • Loading branch information...
1 parent 5686c13 commit e7fdaaa44633306f7f0ec150e8a137e009381c2b @sunaku sunaku committed Feb 3, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 lib/rspec/core/runner.rb
@@ -7,7 +7,7 @@ class Runner
# Register an at_exit hook that runs the suite.
def self.autorun
return if autorun_disabled? || installed_at_exit? || running_in_drb?
- at_exit { exit run(ARGV, $stderr, $stdout).to_i }
+ at_exit { exit run(ARGV, $stderr, $stdout).to_i unless $! }
@installed_at_exit = true
AT_EXIT_HOOK_BACKTRACE_LINE = "#{__FILE__}:#{__LINE__ - 2}:in `autorun'"

0 comments on commit e7fdaaa

Please sign in to comment.