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

Explicitly print the exit status when SimpleCov fails the build #688

Merged
merged 4 commits into from Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,11 @@
<Version> <Date>
===================

## Enhancements

* Print the exit status explicitly when it's not a successful build so it's easier figure out SimpleCov failed the build in the output.


0.16.1 (2018-03-16)
===================

Expand Down
2 changes: 2 additions & 0 deletions features/minimum_coverage.feature
Expand Up @@ -17,6 +17,7 @@ Feature:
When I run `bundle exec rake test`
Then the exit status should not be 0
And the output should contain "Coverage (88.10%) is below the expected minimum coverage (90.00%)."
And the output should contain "SimpleCov failed build with exit 2"

Scenario:
Given SimpleCov for Test/Unit is configured with:
Expand All @@ -31,6 +32,7 @@ Feature:
When I run `bundle exec rake test`
Then the exit status should not be 0
And the output should contain "Coverage (88.10%) is below the expected minimum coverage (88.11%)."
And the output should contain "SimpleCov failed build with exit 2"

Scenario:
Given SimpleCov for Test/Unit is configured with:
Expand Down
5 changes: 4 additions & 1 deletion lib/simplecov.rb
Expand Up @@ -203,7 +203,10 @@ def run_exit_tasks!

# Force exit with stored status (see github issue #5)
# unless it's nil or 0 (see github issue #281)
Kernel.exit exit_status if exit_status && exit_status > 0
if exit_status && exit_status > 0
$stderr.printf("SimpleCov failed build with exit %d", exit_status)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since this affects all failure modes, it should probably be tested at a more fundamental level than the minimum_coverage.feature cuke. Will be glad to take advice from maintainers on testing this

Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to test all permutations, that we hit this branch once and that it prints seems a good enough test for me 👍

Choose a reason for hiding this comment

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

A line feed would have been prettier

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I like the wording here - it's not always a build I run simplecov locally all the time. How about we remove the build and jsut say SimpleCov failed with exit %d ?

Kernel.exit exit_status
end
end

# @api private
Expand Down