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

Fixes #493 Capture exit exception for reference #639

Merged

Conversation

thomas07vt
Copy link
Contributor

Fixes #493

This stores any exit exception that may have occurred. The idea is to
expose this exception to the user supplied at_exit block.

SimpleCov.at_exit do
  if SimpleCov.exit_exception
    # Do something or nothing due to an exception
  else
    # Do something or nothing due to no exception
  end
end

Another method was added: exit_status_from_exception to reduce the
logic in the at_exit block. I am not sure if it's worth adding this
method though. There is still opportunity to refactor the at_exit
block. I first attempted to refactor the @exit_status logic more but
it will be a bigger change. If you want I can remove the
exit_status_from_exception method from this PR

I also don't love having begin rescue end blocks in tests, but I wasn't sure
if there was a better way to test that. Maybe I could wrap $!/$ERROR_INFO
in another method and mock that in testing.

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

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

Only minor things, looks good to me - thank you very much for your contribution! 👍

but yeah, in general at_exit is due for a refactoring :)

end

context "when an exception has not occurred" do
it "does set the exit_exception" do
Copy link
Collaborator

Choose a reason for hiding this comment

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

has no exit_exception might be better here :)

end

it "returns the exit exception" do
expect(SimpleCov.exit_exception).to be(error)
Copy link
Collaborator

Choose a reason for hiding this comment

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

imo we already tested this basically in the tests before this, so I'd be good without this spec :)

@thomas07vt
Copy link
Contributor Author

Thanks for the feedback. I'll implement the fixes in the next couple days 👍

This stores any exit exception that may have occurred. The idea is to
expose this exception to the user supplied ```at_exit``` block.

```ruby
SimpleCov.at_exit do
  if SimpleCov.exit_exception
    # Do something or nothing due to an exception
  else
    # Do something or nothing due to no exception
  end
end
```

Another method was added: ```exit_status_from_exception``` to reduce the
logic in the at_exit block. I am not sure if it's worth adding this
method though. There is still opportunity to refactor the ```at_exit```
block. I first attempted to refactor the @exit_status logic more but
it will be a bigger change. If you want I can remove the
```exit_status_from_exception``` method from this PR
@thomas07vt thomas07vt force-pushed the issues/493-store_exit_exception branch from eb7e5b8 to ecee188 Compare November 16, 2017 16:37
@thomas07vt
Copy link
Contributor Author

and by next couple of days... i apparently meant the next 10 days.... :) OK, ready for another review.

Copy link
Collaborator

@PragTob PragTob left a comment

Choose a reason for hiding this comment

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

No worries, this is OSS - everyone in their own time!

Thanks a bunch 👍

@PragTob PragTob merged commit 09d530c into simplecov-ruby:master Nov 18, 2017
PragTob added a commit that referenced this pull request Nov 18, 2017
This was referenced Mar 15, 2018
This was referenced Mar 19, 2018
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

2 participants