Skip to content
This repository

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

Merged
merged 1 commit into from over 2 years ago

2 participants

Suraj N. Kurapati Justin Ko
Suraj N. Kurapati

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)

Suraj N. Kurapati 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
Justin Ko justinko merged commit 74b170c into from
Suraj N. Kurapati sunaku referenced this pull request from a commit in sunaku/rspec-core
Suraj N. Kurapati 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
Suraj N. Kurapati sunaku referenced this pull request in sunaku/rspec-core
Closed

add to exit status value if exit() already called #1

Suraj N. Kurapati sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Suraj N. Kurapati sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Suraj N. Kurapati sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Suraj N. Kurapati sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Suraj N. Kurapati sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Suraj N. Kurapati sunaku referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Suraj N. Kurapati sunaku referenced this pull request from a commit in sunaku/rspec-core
Suraj N. Kurapati 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
Andy Lindeman alindeman referenced this pull request from a commit in alindeman/rspec-core
Suraj N. Kurapati 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
Andy Lindeman alindeman referenced this pull request from a commit
Suraj N. Kurapati 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

Showing 1 unique commit by 1 author.

Feb 03, 2012
Suraj N. Kurapati 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
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. +1 1  lib/rspec/core/runner.rb
2  lib/rspec/core/runner.rb
@@ -7,7 +7,7 @@ class Runner
7 7 # Register an at_exit hook that runs the suite.
8 8 def self.autorun
9 9 return if autorun_disabled? || installed_at_exit? || running_in_drb?
10   - at_exit { exit run(ARGV, $stderr, $stdout).to_i }
  10 + at_exit { exit run(ARGV, $stderr, $stdout).to_i unless $! }
11 11 @installed_at_exit = true
12 12 end
13 13 AT_EXIT_HOOK_BACKTRACE_LINE = "#{__FILE__}:#{__LINE__ - 2}:in `autorun'"

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.