Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/covered/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

module Covered
module Minitest
MINIMUM_COVERAGE =
Float(ENV.fetch('MINIMUM_COVERAGE', 100.0))

def run(*)
$covered.start

Expand All @@ -26,5 +29,11 @@ def run(*)
Minitest.after_run do
$covered.finish
$covered.call($stderr)

stats = Covered::Statistics.new

$covered.policy.each { stats << _1 }

stats.validate! Covered::Minitest::MINIMUM_COVERAGE / 100.0
end
end
13 changes: 11 additions & 2 deletions test/covered/minitest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,20 @@

it "can run minitest test suite with coverage" do
input, output = IO.pipe

system({"COVERAGE" => "PartialSummary"}, test_path, out: output, err: output)

env = {
"COVERAGE" => "PartialSummary",
"MINIMUM_COVERAGE" => "100.1"
}

system(env, test_path, out: output, err: output)
output.close

expect($?.exitstatus).not.to be(:zero?)

buffer = input.read

expect(buffer).to be =~ /(.*?) files checked; (.*?) lines executed; (.*?)% covered/
expect(buffer).to be =~ /is less than required minimum of 100.1/
end
end