Skip to content

Commit ae1515e

Browse files
authored
Merge pull request #937 from mbj/improve/reporting
Add env details to start report
2 parents 69a7f96 + 7f63ac5 commit ae1515e

File tree

16 files changed

+190
-114
lines changed

16 files changed

+190
-114
lines changed

docs/mutant-minitest.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ bundle exec mutant --include lib --require auom --use minitest -- 'AUOM*'
6363
This prints a report like:
6464

6565
```sh
66-
Mutant configuration:
66+
Mutant environment:
6767
Matcher: #<Mutant::Matcher::Config match_expressions: [AUOM*]>
6868
Integration: Mutant::Integration::Minitest
6969
Jobs: 8

docs/mutant-rspec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ bundle exec mutant --include lib --require auom --use rspec -- 'AUOM*'
3737
This prints a report like:
3838

3939
```sh
40-
Mutant configuration:
40+
Mutant environment:
4141
Matcher: #<Mutant::Matcher::Config match_expressions: [AUOM*]>
4242
Integration: Mutant::Integration::Rspec
4343
Jobs: 8

lib/mutant.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ module Mutant
169169
require 'mutant/reporter/cli'
170170
require 'mutant/reporter/cli/printer'
171171
require 'mutant/reporter/cli/printer/config'
172+
require 'mutant/reporter/cli/printer/env'
172173
require 'mutant/reporter/cli/printer/env_progress'
173174
require 'mutant/reporter/cli/printer/env_result'
174175
require 'mutant/reporter/cli/printer/isolation_result'

lib/mutant/env.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,54 @@ def warn(message)
7474
self
7575
end
7676

77+
# Selected tests
78+
#
79+
# @return [Set<Test>]
80+
def selected_tests
81+
selections.values.flatten.to_set
82+
end
83+
memoize :selected_tests
84+
85+
# Amount of mutations
86+
#
87+
# @return [Integer]
88+
def amount_mutations
89+
mutations.length
90+
end
91+
memoize :amount_mutations
92+
93+
# Amount of tests reachable by integration
94+
#
95+
# @return [Integer]
96+
def amount_total_tests
97+
integration.all_tests.length
98+
end
99+
memoize :amount_total_tests
100+
101+
# Amount of selected subjects
102+
#
103+
# @return [Integer]
104+
def amount_subjects
105+
subjects.length
106+
end
107+
memoize :amount_subjects
108+
109+
# Amount of selected tests
110+
#
111+
# @return [Integer]
112+
def amount_selected_tests
113+
selected_tests.length
114+
end
115+
memoize :amount_selected_tests
116+
117+
# Ratio between selected tests and subjects
118+
#
119+
# @return [Rational]
120+
def test_subject_ratio
121+
Rational(amount_selected_tests, amount_subjects)
122+
end
123+
memoize :test_subject_ratio
124+
77125
private
78126

79127
# Kill mutation under isolation with integration

lib/mutant/reporter/cli/format.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class Progressive < self
7272
#
7373
# @return [String]
7474
def start(env)
75-
format(Printer::Config, env.config)
75+
format(Printer::Env, env)
7676
end
7777

7878
# Progress representation

lib/mutant/reporter/cli/printer/config.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ class Config < self
1313
#
1414
# @return [undefined]
1515
def run
16-
info 'Mutant configuration:'
1716
info 'Matcher: %s', object.matcher.inspect
1817
info 'Integration: %s', object.integration
1918
info 'Jobs: %d', object.jobs
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
module Mutant
4+
class Reporter
5+
class CLI
6+
class Printer
7+
# Env printer
8+
class Env < self
9+
delegate(
10+
:amount_mutations,
11+
:amount_selected_tests,
12+
:amount_subjects,
13+
:amount_total_tests,
14+
:config,
15+
:test_subject_ratio
16+
)
17+
18+
FORMATS = IceNine.deep_freeze([
19+
[:info, 'Subjects: %s', :amount_subjects ],
20+
[:info, 'Total-Tests: %s', :amount_total_tests ],
21+
[:info, 'Selected-Tests: %s', :amount_selected_tests],
22+
[:info, 'Tests/Subject: %0.2f avg', :test_subject_ratio ],
23+
[:info, 'Mutations: %s', :amount_mutations ]
24+
])
25+
26+
# Run printer
27+
#
28+
# @return [undefined]
29+
def run
30+
info('Mutant environment:')
31+
visit(Config, config)
32+
FORMATS.each do |report, format, value|
33+
__send__(report, format, __send__(value))
34+
end
35+
end
36+
end # EnvProgress
37+
end # Printer
38+
end # CLI
39+
end # Reporter
40+
end # Mutant

lib/mutant/reporter/cli/printer/env_progress.rb

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,31 @@ class Printer
88
class EnvProgress < self
99
delegate(
1010
:amount_mutation_results,
11-
:amount_mutations,
1211
:amount_mutations_alive,
1312
:amount_mutations_killed,
14-
:amount_selected_tests,
15-
:amount_subjects,
16-
:amount_total_tests,
1713
:coverage,
1814
:env,
1915
:killtime,
2016
:overhead,
21-
:runtime,
22-
:test_subject_ratio
17+
:runtime
2318
)
2419

2520
FORMATS = IceNine.deep_freeze([
26-
[:info, 'Subjects: %s', :amount_subjects ],
27-
[:info, 'Total-Tests: %s', :amount_total_tests ],
28-
[:info, 'Selected-Tests: %s', :amount_selected_tests ],
29-
[:info, 'Tests/Subject: %0.2f avg', :test_subject_ratio ],
30-
[:info, 'Mutations: %s', :amount_mutations ],
31-
[:info, 'Results: %s', :amount_mutation_results ],
32-
[:info, 'Kills: %s', :amount_mutations_killed ],
33-
[:info, 'Alive: %s', :amount_mutations_alive ],
34-
[:info, 'Runtime: %0.2fs', :runtime ],
35-
[:info, 'Killtime: %0.2fs', :killtime ],
36-
[:info, 'Overhead: %0.2f%%', :overhead_percent ],
37-
[:info, 'Mutations/s: %0.2f', :mutations_per_second ],
38-
[:status, 'Coverage: %0.2f%%', :coverage_percent ]
21+
[:info, 'Results: %s', :amount_mutation_results],
22+
[:info, 'Kills: %s', :amount_mutations_killed],
23+
[:info, 'Alive: %s', :amount_mutations_alive ],
24+
[:info, 'Runtime: %0.2fs', :runtime ],
25+
[:info, 'Killtime: %0.2fs', :killtime ],
26+
[:info, 'Overhead: %0.2f%%', :overhead_percent ],
27+
[:info, 'Mutations/s: %0.2f', :mutations_per_second ],
28+
[:status, 'Coverage: %0.2f%%', :coverage_percent ]
3929
])
4030

4131
# Run printer
4232
#
4333
# @return [undefined]
4434
def run
45-
visit(Config, env.config)
35+
visit(Env, env)
4636
FORMATS.each do |report, format, value|
4737
__send__(report, format, __send__(value))
4838
end

lib/mutant/result.rb

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -101,35 +101,6 @@ def amount_mutations
101101
env.mutations.length
102102
end
103103

104-
# Amount of subjects
105-
#
106-
# @return [Integer]
107-
def amount_subjects
108-
env.subjects.length
109-
end
110-
111-
# Amount of tests reachable by integration
112-
#
113-
# @return [Integer]
114-
def amount_total_tests
115-
env.integration.all_tests.length
116-
end
117-
118-
# Amount of selected tests
119-
#
120-
# @return [Integer]
121-
def amount_selected_tests
122-
env.selections.values.flatten.to_set.length
123-
end
124-
memoize :amount_selected_tests
125-
126-
# Ratio between selected tests and subjects
127-
#
128-
# @return [Rational]
129-
def test_subject_ratio
130-
Rational(amount_selected_tests, amount_subjects)
131-
end
132-
133104
# Test if processing needs to stop
134105
#
135106
# @return [Boolean]

spec/support/shared_context.rb

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def setup_shared_context
3636
let(:output) { StringIO.new }
3737
let(:subject_a_node) { s(:true) }
3838
let(:test_a) { instance_double(Mutant::Test, identification: 'test-a') }
39+
let(:subjects) { [subject_a] }
3940

4041
let(:job_a) do
4142
Mutant::Parallel::Source::Job.new(
@@ -54,14 +55,24 @@ def setup_shared_context
5455
let(:env) do
5556
instance_double(
5657
Mutant::Env,
57-
config: config,
58-
integration: integration,
59-
mutations: mutations,
60-
selections: { subject_a => [test_a] },
61-
subjects: [subject_a]
58+
amount_mutations: mutations.length,
59+
amount_selected_tests: selections.values.flatten.to_set.length,
60+
amount_subjects: subjects.length,
61+
amount_total_tests: integration.all_tests.length,
62+
config: config,
63+
integration: integration,
64+
mutations: mutations,
65+
selected_tests: [test_a].to_set,
66+
selections: selections,
67+
subjects: subjects,
68+
test_subject_ratio: Rational(1)
6269
)
6370
end
6471

72+
let(:selections) do
73+
{ subject_a => [test_a] }
74+
end
75+
6576
let(:integration) do
6677
instance_double(
6778
Mutant::Integration,

0 commit comments

Comments
 (0)