From 7770ce833e0f162ddb2b0d7205307b50fdd7513d Mon Sep 17 00:00:00 2001 From: Damon Aw Date: Tue, 25 Jun 2019 04:02:07 -0400 Subject: [PATCH] Explicitly print the exit status when SimpleCov fails the build (#688) * Explicitly print the exit status when SimpleCov fails the build * I want those bonus points * It might not be a build, so simplify the wording * Update specs too, I am an idiot :) --- CHANGELOG.md | 8 ++++++++ features/minimum_coverage.feature | 2 ++ lib/simplecov.rb | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44673f37..63d1cad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ + +=================== + +## 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) =================== diff --git a/features/minimum_coverage.feature b/features/minimum_coverage.feature index 1f8dd1c8..f51eccf7 100644 --- a/features/minimum_coverage.feature +++ b/features/minimum_coverage.feature @@ -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 with exit 2" Scenario: Given SimpleCov for Test/Unit is configured with: @@ -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 with exit 2" Scenario: Given SimpleCov for Test/Unit is configured with: diff --git a/lib/simplecov.rb b/lib/simplecov.rb index 4f945685..4784dcc2 100644 --- a/lib/simplecov.rb +++ b/lib/simplecov.rb @@ -205,7 +205,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 with exit %d", exit_status) + Kernel.exit exit_status + end end # @api private