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

Exit with code only if it's Numeric > 0 #302

Merged
merged 3 commits into from
Jun 15, 2014

Conversation

mszyndel
Copy link

Fixes bug (#281) causing simplecov to sometimes return 0 despite tests failing

exit @exit_status # Force exit with stored status (see github issue #5)
# Force exit with stored status (see github issue #5)
# Unless it's nil or 0 (see github issue #281)
exit @exit_status if @exit_status.is_a?(Numeric) && @exit_status > 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or if @exit_status && @exit_status > 0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right, checked just now and SystemExit#status is a Fixnum

colszowka added a commit that referenced this pull request Jun 15, 2014
Exit with code only if it's Numeric > 0
@colszowka colszowka merged commit 7ed18ed into simplecov-ruby:master Jun 15, 2014
@colszowka
Copy link
Collaborator

Very nice, thank you! I had somehow thought this was not complete yet and didn't merge, thanks for pointing out this is a ready fix!

@mszyndel
Copy link
Author

@colszowka I must admit I didn't add any test (and I feel like I should), but have no idea how to write such test do be honest.

@mszyndel mszyndel mentioned this pull request Jun 15, 2014
@colszowka
Copy link
Collaborator

An idea would be to pull the at_exit logic into a class and then unit test that throughly, like this:

class SimpleCov::ExitHandler
  def handle_exit(status)
     if status == 0
       do_exit 0
    end
  end

  def do_exit(status)
      exit status
  end
end

This would allow to verify that any given input to the handle_exit method will call do_exit with the expected status, without actually killing the testing process by expecting the call on do_exit with a correct status without actually executing it.

dleve123 added a commit to dleve123/simplecov that referenced this pull request Dec 7, 2014
I hit the `at_exit` bug in Travis CI that (I think) manifested from the bug fixed in simplecov-ruby#302. The CHANGELOG as it currently stands made me think that the issue was never resolved as it pointed to simplecov-ruby#303! Pointing to the correct PR should appease/help desperate build fixers everywhere :)
jsonn pushed a commit to jsonn/pkgsrc that referenced this pull request Feb 3, 2015
0.9.1, 2014-09-21 ([changes](simplecov-ruby/simplecov@v0.9.0...v0.9.1))
====================

## Bugfixes

 * In 0.9.0, we introduced a regression that made SimpleCov no-op mode fail on Ruby 1.8, while
   dropping 1.8 support altogether is announced only for v1.0. This has been fixed.
   See [#333](simplecov-ruby/simplecov#333) (thanks (@sferik)


0.9.0, 2014-07-17 ([changes](simplecov-ruby/simplecov@v0.8.2...v0.9.0))
====================

**A warm welcome and big thank you to the new contributors [@xaviershay](https://github.com/xaviershay), [@sferik](https://github.com/sferik) and especially [@bf4](https://github.com/bf4) for tackling a whole lot of issues and pull requests for this release!**

## Enhancements

  * New interface to specify multiple formatters.
    See [#317](simplecov-ruby/simplecov#317) (thanks @sferik)
  * Document in the README how to exclude code from coverage reports,
    and that the feature shouldn't be abused for skipping untested
    private code.
    See [#304](simplecov-ruby/simplecov#304)
  * Clarify Ruby version support.
    See [#279](simplecov-ruby/simplecov#279) (thanks @deivid-rodriguez)

## Bugfixes

  * Ensure calculations return Floats, not Fixnum or Rational. Fixes segfaults with mathn.
    See [#245](simplecov-ruby/simplecov#245) (thanks to @bf4)
  * Using `Kernel.exit` instead of exit to avoid uncaught throw :IRB_EXIT when
    exiting irb sessions.
    See [#287](simplecov-ruby/simplecov#287) (thanks @wless1)
    See [#285](simplecov-ruby/simplecov#285)
  * Does not look for .simplecov in ~/ when $HOME is not set.
    See [#311](simplecov-ruby/simplecov#311) (thanks @lasseebert)
  * Exit with code only if it's Numeric > 0.
    See [#302](simplecov-ruby/simplecov#303 @hajder)
  * Make default filter case insensitive.
    See [#280](simplecov-ruby/simplecov#280) (thanks @ryanatball)
  * Improve regexp that matches functional tests.
    See [#276](simplecov-ruby/simplecov#276) (thanks @sferik)
  * Fix TravisCI [#272](simplecov-ruby/simplecov#272) [#278](simplecov-ruby/simplecov#278), [#302](simplecov-ruby/simplecov#302)
  * Fix global config load.
    See [#311](simplecov-ruby/simplecov#311) (thanks @lasseebert)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants