Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #41 #84

Merged
merged 1 commit into from
Sep 28, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions features/rspec_fails_on_initialization.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@rspec
Feature:

Running specs with a failing rspec setup

Scenario: Fail if rspec fails before starting its tests
Given a file named "spec/spec_helper.rb" with:
"""
require 'simplecov'
SimpleCov.start
raise "some exception in the class loading before the tests start"
"""
When I run `bundle exec rspec spec`
Then the exit status should not be 0
8 changes: 6 additions & 2 deletions lib/simplecov/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@
# Exclude files outside of SimpleCov.root
load_adapter 'root_filter'
end

at_exit do
# Store the exit status of the test run since it goes away after calling the at_exit proc...
@exit_status = $!.status if $!.is_a?(SystemExit)
if $! #was an exception thrown?
#if it was a SystemExit, use the accompanying status
#otherwise set a non-zero status representing termination by some other exception
#(see github issue 41)
@exit_status = $!.is_a?(SystemExit) ? $!.status : 1
end
SimpleCov.at_exit.call
exit @exit_status if @exit_status # Force exit with stored status (see github issue #5)
end
Expand Down