Merge pull request #383 from mbj/fix/exit-on-zero-subjects
Change coverage on zero results to be 100%
This commit is contained in:
commit
c0157bf796
8 changed files with 18 additions and 26 deletions
|
@ -1,3 +1,3 @@
|
|||
---
|
||||
threshold: 18
|
||||
total_score: 1196
|
||||
total_score: 1204
|
||||
|
|
|
@ -4,6 +4,8 @@ module Mutant
|
|||
|
||||
# Coverage mixin
|
||||
module Coverage
|
||||
FULL_COVERAGE = Rational(1).freeze
|
||||
private_constant(*constants(false))
|
||||
|
||||
# Observed coverage
|
||||
#
|
||||
|
@ -11,24 +13,12 @@ module Mutant
|
|||
#
|
||||
# @api private
|
||||
def coverage
|
||||
return Rational(0) if amount_mutation_results.zero?
|
||||
|
||||
Rational(amount_mutations_killed, amount_mutation_results)
|
||||
if amount_mutation_results.zero?
|
||||
FULL_COVERAGE
|
||||
else
|
||||
Rational(amount_mutations_killed, amount_mutation_results)
|
||||
end
|
||||
end
|
||||
|
||||
# Hook called when module gets included
|
||||
#
|
||||
# @param [Class, Module] host
|
||||
#
|
||||
# @return [undefined]
|
||||
#
|
||||
# @api private
|
||||
def self.included(host)
|
||||
super
|
||||
|
||||
host.memoize(:coverage)
|
||||
end
|
||||
|
||||
end # Coverage
|
||||
|
||||
# Class level mixin
|
||||
|
@ -53,6 +43,8 @@ module Mutant
|
|||
end
|
||||
end # ClassMethods
|
||||
|
||||
private_constant(*constants(false))
|
||||
|
||||
# Mutant overhead running mutatet tests
|
||||
#
|
||||
# This is NOT the overhead of mutation testing, just an engine specific
|
||||
|
|
|
@ -24,7 +24,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
|
|||
Runtime: 4.00s
|
||||
Killtime: 0.00s
|
||||
Overhead: Inf%
|
||||
Coverage: 0.00%
|
||||
Coverage: 100.00%
|
||||
Expected: 10.00%
|
||||
STR
|
||||
end
|
||||
|
|
|
@ -8,14 +8,14 @@ RSpec.describe Mutant::Reporter::CLI::Printer::StatusProgressive do
|
|||
update(:env_result) { { subject_results: [] } }
|
||||
|
||||
it_reports <<-REPORT
|
||||
(00/02) 0% - killtime: 0.00s runtime: 4.00s overhead: 4.00s
|
||||
(00/02) 100% - killtime: 0.00s runtime: 4.00s overhead: 4.00s
|
||||
REPORT
|
||||
|
||||
context 'on non default coverage expectation' do
|
||||
update(:config) { { expected_coverage: 0.1r } }
|
||||
|
||||
it_reports <<-REPORT
|
||||
(00/02) 0% - killtime: 0.00s runtime: 4.00s overhead: 4.00s
|
||||
(00/02) 100% - killtime: 0.00s runtime: 4.00s overhead: 4.00s
|
||||
REPORT
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do
|
|||
Runtime: 4.00s
|
||||
Killtime: 0.00s
|
||||
Overhead: Inf%
|
||||
Coverage: 0.00%
|
||||
Coverage: 100.00%
|
||||
Expected: 100.00%
|
||||
Active subjects: 0
|
||||
REPORT
|
||||
|
@ -45,7 +45,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Status do
|
|||
Runtime: 4.00s
|
||||
Killtime: 0.00s
|
||||
Overhead: Inf%
|
||||
Coverage: 0.00%
|
||||
Coverage: 100.00%
|
||||
Expected: 10.00%
|
||||
Active subjects: 0
|
||||
REPORT
|
||||
|
|
|
@ -29,7 +29,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::SubjectProgress do
|
|||
|
||||
it_reports <<-'STR'
|
||||
subject-a mutations: 2
|
||||
(00/02) 0% - killtime: 0.00s runtime: 0.00s overhead: 0.00s
|
||||
(00/02) 100% - killtime: 0.00s runtime: 0.00s overhead: 0.00s
|
||||
- test-a
|
||||
STR
|
||||
end
|
||||
|
|
|
@ -208,7 +208,7 @@ RSpec.describe Mutant::Reporter::CLI do
|
|||
|
||||
let(:tty?) { true }
|
||||
|
||||
it_reports Mutant::Color::RED.format('(00/02) 0% - killtime: 0.00s runtime: 4.00s overhead: 4.00s') << "\n"
|
||||
it_reports Mutant::Color::GREEN.format('(00/02) 100% - killtime: 0.00s runtime: 4.00s overhead: 4.00s') << "\n"
|
||||
end
|
||||
|
||||
context 'with last mutation present' do
|
||||
|
|
|
@ -61,7 +61,7 @@ RSpec.describe Mutant::Result::Env do
|
|||
context 'when there are no results' do
|
||||
let(:results) { 0 }
|
||||
|
||||
it { should eql(Rational(0)) }
|
||||
it { should eql(Rational(1)) }
|
||||
end
|
||||
|
||||
context 'when there are no kills' do
|
||||
|
|
Loading…
Reference in a new issue