module SimpleCov
def result_exit_status(result, covered_percent)
- Api: - private
def result_exit_status(result, covered_percent) covered_percentages = result.covered_percentages.map { |percentage| percentage.floor(2) } if (minimum_violations = minimum_coverage_violated(result)).any? report_minimum_violated(minimum_violations) SimpleCov::ExitCodes::MINIMUM_COVERAGE elsif covered_percentages.any? { |p| p < SimpleCov.minimum_coverage_by_file } $stderr.printf( "File (%<file>s) is only (%<least_covered_percentage>.2f%%) covered. This is below the expected minimum coverage per file of (%<min_coverage>.2f%%).\n", file: result.least_covered_file, least_covered_percentage: covered_percentages.min, min_coverage: SimpleCov.minimum_coverage_by_file ) SimpleCov::ExitCodes::MINIMUM_COVERAGE elsif (last_run = SimpleCov::LastRun.read) coverage_diff = last_run[:result][:covered_percent] - covered_percent if coverage_diff > SimpleCov.maximum_coverage_drop $stderr.printf( "Coverage has dropped by %<drop_percent>.2f%% since the last time (maximum allowed: %<max_drop>.2f%%).\n", drop_percent: coverage_diff, max_drop: SimpleCov.maximum_coverage_drop ) SimpleCov::ExitCodes::MAXIMUM_COVERAGE_DROP else SimpleCov::ExitCodes::SUCCESS end else SimpleCov::ExitCodes::SUCCESS end end