Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@sunaku

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)

@sunaku sunaku 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)
e7fdaaa
@justinko justinko merged commit 74b170c into rspec:master
@sunaku sunaku referenced this pull request from a commit in sunaku/rspec-core
@sunaku sunaku add to exit status value if exit() already called
This commit fixes a problem that I introduced in pull request #569,
where RSpec won't run any specs if someone explicitly called exit().

This can also happen if someone was using both Test::Unit and RSpec
together and they had loaded RSpec before loading Test::Unit because in
that case, RSpec's at_exit handler would be registered before that of
Test::Unit.  As a result, exit() called in Test::Unit's handler would
prevent RSpec from running any specs --- since $! would be SystemExit.
50c9c7f
@sunaku sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@sunaku sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@sunaku sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@sunaku sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@sunaku sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@sunaku sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@sunaku sunaku referenced this pull request from a commit in sunaku/rspec-core
@sunaku sunaku run specs even if Kernel#exit() was called
This commit fixes a problem that I introduced in pull request #569,
where RSpec won't run any specs if someone explicitly called exit() or
if they were using both Test::Unit and RSpec together and they had
loaded RSpec before loading Test::Unit.  In particular, exit() called in
Test::Unit's at_exit handler would raise SystemExit, thereby defining
$!, whose presence inhibits RSpec's at_exit handler from running specs.
0e39b81
@alindeman alindeman referenced this pull request from a commit in alindeman/rspec-core
@sunaku sunaku run specs even if Kernel#exit() was called
This commit fixes a problem that I introduced in pull request #569,
where RSpec won't run any specs if someone explicitly called exit() or
if they were using both Test::Unit and RSpec together and they had
loaded RSpec before loading Test::Unit.  In particular, exit() called in
Test::Unit's at_exit handler would raise SystemExit, thereby defining
$!, whose presence inhibits RSpec's at_exit handler from running specs.
b1d24e9
@alindeman alindeman referenced this pull request from a commit
@sunaku sunaku run specs even if Kernel#exit() was called
This commit fixes a problem that I introduced in pull request #569,
where RSpec won't run any specs if someone explicitly called exit() or
if they were using both Test::Unit and RSpec together and they had
loaded RSpec before loading Test::Unit.  In particular, exit() called in
Test::Unit's at_exit handler would raise SystemExit, thereby defining
$!, whose presence inhibits RSpec's at_exit handler from running specs.
5e5603c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 3, 2012
  1. @sunaku

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

    sunaku authored
    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)
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/rspec/core/runner.rb
View
2  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
end
AT_EXIT_HOOK_BACKTRACE_LINE = "#{__FILE__}:#{__LINE__ - 2}:in `autorun'"
Something went wrong with that request. Please try again.