mutant 0.8.24 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +3 -3
  3. data/Changelog.md +14 -654
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +59 -64
  6. data/LICENSE +271 -20
  7. data/README.md +73 -140
  8. data/Rakefile +0 -21
  9. data/bin/mutant +7 -2
  10. data/config/reek.yml +2 -1
  11. data/config/rubocop.yml +5 -9
  12. data/docs/incremental.md +76 -0
  13. data/docs/known-problems.md +0 -14
  14. data/docs/mutant-minitest.md +1 -1
  15. data/docs/mutant-rspec.md +2 -24
  16. data/lib/mutant.rb +45 -53
  17. data/lib/mutant/ast/nodes.rb +0 -2
  18. data/lib/mutant/ast/types.rb +1 -117
  19. data/lib/mutant/base.rb +192 -0
  20. data/lib/mutant/bootstrap.rb +145 -0
  21. data/lib/mutant/cli.rb +68 -54
  22. data/lib/mutant/config.rb +119 -6
  23. data/lib/mutant/env.rb +94 -8
  24. data/lib/mutant/expression.rb +6 -1
  25. data/lib/mutant/expression/parser.rb +9 -31
  26. data/lib/mutant/integration.rb +64 -36
  27. data/lib/mutant/isolation.rb +16 -1
  28. data/lib/mutant/isolation/fork.rb +105 -40
  29. data/lib/mutant/license.rb +34 -0
  30. data/lib/mutant/license/subscription.rb +47 -0
  31. data/lib/mutant/license/subscription/commercial.rb +57 -0
  32. data/lib/mutant/license/subscription/opensource.rb +77 -0
  33. data/lib/mutant/loader.rb +27 -4
  34. data/lib/mutant/matcher.rb +48 -1
  35. data/lib/mutant/matcher/chain.rb +1 -1
  36. data/lib/mutant/matcher/config.rb +0 -2
  37. data/lib/mutant/matcher/filter.rb +1 -1
  38. data/lib/mutant/matcher/method.rb +11 -7
  39. data/lib/mutant/matcher/methods.rb +1 -1
  40. data/lib/mutant/matcher/namespace.rb +1 -1
  41. data/lib/mutant/matcher/null.rb +1 -1
  42. data/lib/mutant/matcher/scope.rb +1 -1
  43. data/lib/mutant/meta/example/dsl.rb +0 -8
  44. data/lib/mutant/mutation.rb +1 -2
  45. data/lib/mutant/mutator/node.rb +2 -9
  46. data/lib/mutant/mutator/node/arguments.rb +1 -1
  47. data/lib/mutant/mutator/node/class.rb +0 -8
  48. data/lib/mutant/mutator/node/define.rb +0 -12
  49. data/lib/mutant/mutator/node/generic.rb +30 -44
  50. data/lib/mutant/mutator/node/index.rb +4 -4
  51. data/lib/mutant/mutator/node/literal/regex.rb +0 -39
  52. data/lib/mutant/mutator/node/send.rb +13 -12
  53. data/lib/mutant/parallel.rb +61 -40
  54. data/lib/mutant/parallel/driver.rb +59 -0
  55. data/lib/mutant/parallel/source.rb +6 -2
  56. data/lib/mutant/parallel/worker.rb +63 -45
  57. data/lib/mutant/range.rb +15 -0
  58. data/lib/mutant/reporter/cli.rb +5 -11
  59. data/lib/mutant/reporter/cli/format.rb +3 -46
  60. data/lib/mutant/reporter/cli/printer/config.rb +5 -6
  61. data/lib/mutant/reporter/cli/printer/env.rb +40 -0
  62. data/lib/mutant/reporter/cli/printer/env_progress.rb +13 -17
  63. data/lib/mutant/reporter/cli/printer/isolation_result.rb +17 -3
  64. data/lib/mutant/reporter/cli/printer/mutation_result.rb +2 -3
  65. data/lib/mutant/reporter/cli/printer/status_progressive.rb +19 -10
  66. data/lib/mutant/repository.rb +0 -65
  67. data/lib/mutant/repository/diff.rb +104 -0
  68. data/lib/mutant/repository/diff/ranges.rb +52 -0
  69. data/lib/mutant/result.rb +16 -7
  70. data/lib/mutant/runner.rb +38 -47
  71. data/lib/mutant/runner/sink.rb +1 -1
  72. data/lib/mutant/selector/null.rb +19 -0
  73. data/lib/mutant/subject.rb +3 -1
  74. data/lib/mutant/subject/method/instance.rb +3 -1
  75. data/lib/mutant/transform.rb +511 -0
  76. data/lib/mutant/variable.rb +282 -0
  77. data/lib/mutant/version.rb +1 -1
  78. data/lib/mutant/warnings.rb +113 -0
  79. data/meta/case.rb +1 -0
  80. data/meta/class.rb +0 -9
  81. data/meta/def.rb +1 -26
  82. data/meta/regexp.rb +10 -20
  83. data/meta/send.rb +14 -46
  84. data/mutant-minitest.gemspec +1 -1
  85. data/mutant-rspec.gemspec +2 -2
  86. data/mutant.gemspec +15 -16
  87. data/mutant.yml +6 -0
  88. data/spec/integration/mutant/isolation/fork_spec.rb +22 -5
  89. data/spec/integration/mutant/minitest_spec.rb +3 -2
  90. data/spec/integration/mutant/rspec_spec.rb +4 -3
  91. data/spec/integrations.yml +16 -13
  92. data/spec/shared/base_behavior.rb +45 -0
  93. data/spec/shared/framework_integration_behavior.rb +43 -14
  94. data/spec/spec_helper.rb +21 -17
  95. data/spec/support/corpus.rb +56 -95
  96. data/spec/support/shared_context.rb +37 -14
  97. data/spec/support/xspec.rb +7 -3
  98. data/spec/unit/mutant/bootstrap_spec.rb +216 -0
  99. data/spec/unit/mutant/cli_spec.rb +173 -117
  100. data/spec/unit/mutant/config_spec.rb +126 -0
  101. data/spec/unit/mutant/either_spec.rb +247 -0
  102. data/spec/unit/mutant/env_spec.rb +162 -40
  103. data/spec/unit/mutant/expression/method_spec.rb +16 -0
  104. data/spec/unit/mutant/expression/parser_spec.rb +29 -33
  105. data/spec/unit/mutant/expression_spec.rb +5 -7
  106. data/spec/unit/mutant/integration_spec.rb +100 -9
  107. data/spec/unit/mutant/isolation/fork_spec.rb +125 -67
  108. data/spec/unit/mutant/isolation/result_spec.rb +33 -1
  109. data/spec/unit/mutant/license_spec.rb +257 -0
  110. data/spec/unit/mutant/loader_spec.rb +50 -11
  111. data/spec/unit/mutant/matcher/compiler_spec.rb +0 -78
  112. data/spec/unit/mutant/matcher/method/instance_spec.rb +55 -11
  113. data/spec/unit/mutant/matcher/method/singleton_spec.rb +12 -2
  114. data/spec/unit/mutant/matcher_spec.rb +102 -0
  115. data/spec/unit/mutant/maybe_spec.rb +60 -0
  116. data/spec/unit/mutant/meta/example/dsl_spec.rb +1 -17
  117. data/spec/unit/mutant/mutation_spec.rb +13 -6
  118. data/spec/unit/mutant/parallel/driver_spec.rb +112 -14
  119. data/spec/unit/mutant/parallel/source/array_spec.rb +25 -17
  120. data/spec/unit/mutant/parallel/worker_spec.rb +182 -44
  121. data/spec/unit/mutant/parallel_spec.rb +105 -8
  122. data/spec/unit/mutant/range_spec.rb +141 -0
  123. data/spec/unit/mutant/reporter/cli/printer/config_spec.rb +7 -21
  124. data/spec/unit/mutant/reporter/cli/printer/env_progress_spec.rb +15 -6
  125. data/spec/unit/mutant/reporter/cli/printer/env_result_spec.rb +10 -2
  126. data/spec/unit/mutant/reporter/cli/printer/isolation_result_spec.rb +12 -4
  127. data/spec/unit/mutant/reporter/cli/printer/mutation_result_spec.rb +31 -2
  128. data/spec/unit/mutant/reporter/cli/printer/status_progressive_spec.rb +4 -4
  129. data/spec/unit/mutant/reporter/cli/printer/subject_result_spec.rb +5 -0
  130. data/spec/unit/mutant/reporter/cli_spec.rb +46 -123
  131. data/spec/unit/mutant/repository/diff/ranges_spec.rb +180 -0
  132. data/spec/unit/mutant/repository/diff_spec.rb +84 -71
  133. data/spec/unit/mutant/require_highjack_spec.rb +1 -1
  134. data/spec/unit/mutant/result/env_spec.rb +39 -9
  135. data/spec/unit/mutant/result/test_spec.rb +14 -0
  136. data/spec/unit/mutant/runner_spec.rb +88 -41
  137. data/spec/unit/mutant/selector/expression_spec.rb +11 -10
  138. data/spec/unit/mutant/selector/null_spec.rb +17 -0
  139. data/spec/unit/mutant/subject/method/instance_spec.rb +44 -5
  140. data/spec/unit/mutant/subject/method/singleton_spec.rb +9 -2
  141. data/spec/unit/mutant/subject_spec.rb +9 -1
  142. data/spec/unit/mutant/transform/array_spec.rb +92 -0
  143. data/spec/unit/mutant/transform/bool_spec.rb +63 -0
  144. data/spec/unit/mutant/transform/error_spec.rb +132 -0
  145. data/spec/unit/mutant/transform/exception_spec.rb +44 -0
  146. data/spec/unit/mutant/transform/hash_spec.rb +236 -0
  147. data/spec/unit/mutant/transform/index_spec.rb +92 -0
  148. data/spec/unit/mutant/transform/named_spec.rb +49 -0
  149. data/spec/unit/mutant/transform/primitive_spec.rb +56 -0
  150. data/spec/unit/mutant/transform/sequence_spec.rb +98 -0
  151. data/spec/unit/mutant/variable_spec.rb +618 -0
  152. data/spec/unit/mutant/warnings_spec.rb +89 -0
  153. data/spec/unit/mutant/world_spec.rb +63 -0
  154. data/test_app/Gemfile.minitest +0 -2
  155. metadata +79 -113
  156. data/.gitattributes +0 -1
  157. data/.ruby-gemset +0 -1
  158. data/config/triage.yml +0 -2
  159. data/lib/mutant/actor.rb +0 -57
  160. data/lib/mutant/actor/env.rb +0 -31
  161. data/lib/mutant/actor/mailbox.rb +0 -34
  162. data/lib/mutant/actor/receiver.rb +0 -42
  163. data/lib/mutant/actor/sender.rb +0 -26
  164. data/lib/mutant/ast/meta/restarg.rb +0 -19
  165. data/lib/mutant/ast/regexp.rb +0 -42
  166. data/lib/mutant/ast/regexp/transformer.rb +0 -187
  167. data/lib/mutant/ast/regexp/transformer/direct.rb +0 -123
  168. data/lib/mutant/ast/regexp/transformer/named_group.rb +0 -59
  169. data/lib/mutant/ast/regexp/transformer/options_group.rb +0 -83
  170. data/lib/mutant/ast/regexp/transformer/quantifier.rb +0 -114
  171. data/lib/mutant/ast/regexp/transformer/recursive.rb +0 -58
  172. data/lib/mutant/ast/regexp/transformer/root.rb +0 -31
  173. data/lib/mutant/ast/regexp/transformer/text.rb +0 -60
  174. data/lib/mutant/env/bootstrap.rb +0 -160
  175. data/lib/mutant/matcher/compiler.rb +0 -60
  176. data/lib/mutant/mutator/node/regexp.rb +0 -35
  177. data/lib/mutant/mutator/node/regexp/alternation_meta.rb +0 -23
  178. data/lib/mutant/mutator/node/regexp/capture_group.rb +0 -28
  179. data/lib/mutant/mutator/node/regexp/character_type.rb +0 -32
  180. data/lib/mutant/mutator/node/regexp/end_of_line_anchor.rb +0 -23
  181. data/lib/mutant/mutator/node/regexp/end_of_string_or_before_end_of_line_anchor.rb +0 -23
  182. data/lib/mutant/mutator/node/regexp/greedy_zero_or_more.rb +0 -27
  183. data/lib/mutant/parallel/master.rb +0 -181
  184. data/lib/mutant/reporter/cli/printer/status.rb +0 -53
  185. data/lib/mutant/reporter/cli/tput.rb +0 -46
  186. data/lib/mutant/warning_filter.rb +0 -61
  187. data/meta/regexp/character_types.rb +0 -23
  188. data/meta/regexp/regexp_alternation_meta.rb +0 -13
  189. data/meta/regexp/regexp_bol_anchor.rb +0 -10
  190. data/meta/regexp/regexp_bos_anchor.rb +0 -18
  191. data/meta/regexp/regexp_capture_group.rb +0 -19
  192. data/meta/regexp/regexp_eol_anchor.rb +0 -10
  193. data/meta/regexp/regexp_eos_anchor.rb +0 -8
  194. data/meta/regexp/regexp_eos_ob_eol_anchor.rb +0 -10
  195. data/meta/regexp/regexp_greedy_zero_or_more.rb +0 -12
  196. data/meta/regexp/regexp_root_expression.rb +0 -10
  197. data/meta/restarg.rb +0 -10
  198. data/spec/support/fake_actor.rb +0 -111
  199. data/spec/support/warning.rb +0 -66
  200. data/spec/unit/mutant/actor/binding_spec.rb +0 -34
  201. data/spec/unit/mutant/actor/env_spec.rb +0 -31
  202. data/spec/unit/mutant/actor/mailbox_spec.rb +0 -28
  203. data/spec/unit/mutant/actor/message_spec.rb +0 -25
  204. data/spec/unit/mutant/actor/receiver_spec.rb +0 -58
  205. data/spec/unit/mutant/actor/sender_spec.rb +0 -24
  206. data/spec/unit/mutant/ast/regexp/parse_spec.rb +0 -19
  207. data/spec/unit/mutant/ast/regexp/transformer/lookup_table/table_spec.rb +0 -21
  208. data/spec/unit/mutant/ast/regexp/transformer/lookup_table_spec.rb +0 -35
  209. data/spec/unit/mutant/ast/regexp/transformer_spec.rb +0 -21
  210. data/spec/unit/mutant/ast/regexp_spec.rb +0 -704
  211. data/spec/unit/mutant/env/bootstrap_spec.rb +0 -188
  212. data/spec/unit/mutant/matcher/compiler/subject_prefix_spec.rb +0 -26
  213. data/spec/unit/mutant/parallel/master_spec.rb +0 -338
  214. data/spec/unit/mutant/reporter/cli/printer/status_spec.rb +0 -121
  215. data/spec/unit/mutant/reporter/cli/tput_spec.rb +0 -50
  216. data/spec/unit/mutant/warning_filter_spec.rb +0 -106
  217. data/spec/unit/mutant_spec.rb +0 -17
  218. data/test_app/Gemfile.rspec3.7 +0 -7
@@ -6,26 +6,12 @@ RSpec.describe Mutant::Reporter::CLI::Printer::Config do
6
6
  let(:reportable) { config }
7
7
 
8
8
  describe '.call' do
9
- context 'on default config' do
10
- it_reports(<<~REPORT)
11
- Mutant configuration:
12
- Matcher: #<Mutant::Matcher::Config empty>
13
- Integration: Mutant::Integration::Null
14
- Jobs: 1
15
- Includes: []
16
- Requires: []
17
- REPORT
18
- end
19
-
20
- context 'with non default coverage expectation' do
21
- it_reports(<<~REPORT)
22
- Mutant configuration:
23
- Matcher: #<Mutant::Matcher::Config empty>
24
- Integration: Mutant::Integration::Null
25
- Jobs: 1
26
- Includes: []
27
- Requires: []
28
- REPORT
29
- end
9
+ it_reports(<<~'REPORT')
10
+ Matcher: #<Mutant::Matcher::Config empty>
11
+ Integration: null
12
+ Jobs: 1
13
+ Includes: []
14
+ Requires: []
15
+ REPORT
30
16
  end
31
17
  end
@@ -10,13 +10,16 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
10
10
  with(:subject_a_result) { { mutation_results: [] } }
11
11
 
12
12
  it_reports <<~'STR'
13
- Mutant configuration:
13
+ Mutant environment:
14
14
  Matcher: #<Mutant::Matcher::Config empty>
15
- Integration: Mutant::Integration::Null
15
+ Integration: null
16
16
  Jobs: 1
17
17
  Includes: []
18
18
  Requires: []
19
19
  Subjects: 1
20
+ Total-Tests: 1
21
+ Selected-Tests: 1
22
+ Tests/Subject: 1.00 avg
20
23
  Mutations: 2
21
24
  Results: 0
22
25
  Kills: 0
@@ -31,13 +34,16 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
31
34
 
32
35
  context 'on full coverage' do
33
36
  it_reports <<~'STR'
34
- Mutant configuration:
37
+ Mutant environment:
35
38
  Matcher: #<Mutant::Matcher::Config empty>
36
- Integration: Mutant::Integration::Null
39
+ Integration: null
37
40
  Jobs: 1
38
41
  Includes: []
39
42
  Requires: []
40
43
  Subjects: 1
44
+ Total-Tests: 1
45
+ Selected-Tests: 1
46
+ Tests/Subject: 1.00 avg
41
47
  Mutations: 2
42
48
  Results: 2
43
49
  Kills: 2
@@ -54,13 +60,16 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvProgress do
54
60
  with(:mutation_a_test_result) { { passed: true } }
55
61
 
56
62
  it_reports <<~'STR'
57
- Mutant configuration:
63
+ Mutant environment:
58
64
  Matcher: #<Mutant::Matcher::Config empty>
59
- Integration: Mutant::Integration::Null
65
+ Integration: null
60
66
  Jobs: 1
61
67
  Includes: []
62
68
  Requires: []
63
69
  Subjects: 1
70
+ Total-Tests: 1
71
+ Selected-Tests: 1
72
+ Tests/Subject: 1.00 avg
64
73
  Mutations: 2
65
74
  Results: 2
66
75
  Kills: 1
@@ -16,13 +16,21 @@ RSpec.describe Mutant::Reporter::CLI::Printer::EnvResult do
16
16
  -true
17
17
  +false
18
18
  -----------------------
19
- Mutant configuration:
19
+ - 1 @ runtime: 1.0
20
+ - test-a
21
+ Test Output:
22
+ mutation a test result output
23
+ -----------------------
24
+ Mutant environment:
20
25
  Matcher: #<Mutant::Matcher::Config empty>
21
- Integration: Mutant::Integration::Null
26
+ Integration: null
22
27
  Jobs: 1
23
28
  Includes: []
24
29
  Requires: []
25
30
  Subjects: 1
31
+ Total-Tests: 1
32
+ Selected-Tests: 1
33
+ Tests/Subject: 1.00 avg
26
34
  Mutations: 2
27
35
  Results: 2
28
36
  Kills: 1
@@ -77,13 +77,17 @@ RSpec.describe Mutant::Reporter::CLI::Printer::IsolationResult do
77
77
  instance_double(
78
78
  Process::Status,
79
79
  'unsuccessful status'
80
- )
80
+ ),
81
+ 'log message'
81
82
  )
82
83
  end
83
84
 
84
85
  it_reports <<~'STR'
85
- Killfork exited nonzero. Its result (if any) was ignored:
86
+ Killfork exited nonzero. Its result (if any) was ignored.
87
+ Process status:
86
88
  #<InstanceDouble(Process::Status) "unsuccessful status">
89
+ Log messages (combined stderr and stdout):
90
+ log message
87
91
  STR
88
92
  end
89
93
 
@@ -97,7 +101,8 @@ RSpec.describe Mutant::Reporter::CLI::Printer::IsolationResult do
97
101
  instance_double(
98
102
  Process::Status,
99
103
  'unsuccessful status'
100
- )
104
+ ),
105
+ 'log message'
101
106
  )
102
107
  end
103
108
 
@@ -116,8 +121,11 @@ RSpec.describe Mutant::Reporter::CLI::Printer::IsolationResult do
116
121
  Possible solutions are:
117
122
  * Reduce concurrency
118
123
  * Reduce locks
119
- Killfork exited nonzero. Its result (if any) was ignored:
124
+ Killfork exited nonzero. Its result (if any) was ignored.
125
+ Process status:
120
126
  #<InstanceDouble(Process::Status) "unsuccessful status">
127
+ Log messages (combined stderr and stdout):
128
+ log message
121
129
  STR
122
130
  end
123
131
  end
@@ -12,7 +12,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do
12
12
  end
13
13
 
14
14
  let(:mutation_a_isolation_result) do
15
- Mutant::Isolation::Fork::ChildError.new(status)
15
+ Mutant::Isolation::Fork::ChildError.new(status, 'log message')
16
16
  end
17
17
 
18
18
  it_reports(<<~'REPORT')
@@ -20,8 +20,12 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do
20
20
  @@ -1,2 +1,2 @@
21
21
  -true
22
22
  +false
23
- Killfork exited nonzero. Its result (if any) was ignored:
23
+ -----------------------
24
+ Killfork exited nonzero. Its result (if any) was ignored.
25
+ Process status:
24
26
  #<InstanceDouble(Process::Status) (anonymous)>
27
+ Log messages (combined stderr and stdout):
28
+ log message
25
29
  -----------------------
26
30
  REPORT
27
31
  end
@@ -42,6 +46,11 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do
42
46
  [Mutant::Color::NONE, "@@ -1,2 +1,2 @@\n"],
43
47
  [Mutant::Color::RED, "-true\n"],
44
48
  [Mutant::Color::GREEN, "+false\n"],
49
+ [Mutant::Color::NONE, "-----------------------\n"],
50
+ [Mutant::Color::NONE, "- 1 @ runtime: 1.0\n"],
51
+ [Mutant::Color::NONE, " - test-a\n"],
52
+ [Mutant::Color::NONE, "Test Output:\n"],
53
+ [Mutant::Color::NONE, "mutation a test result output\n"],
45
54
  [Mutant::Color::NONE, "-----------------------\n"]
46
55
  ].map { |color, text| color.format(text) }.join
47
56
  )
@@ -54,6 +63,11 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do
54
63
  -true
55
64
  +false
56
65
  -----------------------
66
+ - 1 @ runtime: 1.0
67
+ - test-a
68
+ Test Output:
69
+ mutation a test result output
70
+ -----------------------
57
71
  STR
58
72
  end
59
73
  end
@@ -80,6 +94,11 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do
80
94
  Mutated AST:
81
95
  s(:zsuper)
82
96
  -----------------------
97
+ - 1 @ runtime: 1.0
98
+ - test-a
99
+ Test Output:
100
+ mutation a test result output
101
+ -----------------------
83
102
  REPORT
84
103
  end
85
104
  end
@@ -101,6 +120,11 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do
101
120
  Unparsed Source:
102
121
  true
103
122
  -----------------------
123
+ - 1 @ runtime: 1.0
124
+ - test-a
125
+ Test Output:
126
+ mutation a test result output
127
+ -----------------------
104
128
  REPORT
105
129
  end
106
130
 
@@ -117,6 +141,11 @@ RSpec.describe Mutant::Reporter::CLI::Printer::MutationResult do
117
141
  No code was inserted. And the test did NOT PASS.
118
142
  This is typically a problem of your specs not passing unmutated.
119
143
  -----------------------
144
+ - 1 @ runtime: 1.0
145
+ - test-a
146
+ Test Output:
147
+ mutation a test result output
148
+ -----------------------
120
149
  REPORT
121
150
  end
122
151
  end
@@ -10,7 +10,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::StatusProgressive do
10
10
  with(:env_result) { { subject_results: [] } }
11
11
 
12
12
  it_reports <<~REPORT
13
- (00/02) 100% - killtime: 0.00s runtime: 4.00s overhead: 4.00s
13
+ progress: 00/02 alive: 0 runtime: 4.00s killtime: 0.00s mutations/s: 0.00
14
14
  REPORT
15
15
  end
16
16
 
@@ -19,7 +19,7 @@ RSpec.describe Mutant::Reporter::CLI::Printer::StatusProgressive do
19
19
  with(:status) { { active_jobs: [].to_set } }
20
20
 
21
21
  it_reports(<<~REPORT)
22
- (02/02) 100% - killtime: 2.00s runtime: 4.00s overhead: 2.00s
22
+ progress: 02/02 alive: 0 runtime: 4.00s killtime: 2.00s mutations/s: 0.50
23
23
  REPORT
24
24
  end
25
25
 
@@ -30,13 +30,13 @@ RSpec.describe Mutant::Reporter::CLI::Printer::StatusProgressive do
30
30
  with(:mutation_a_test_result) { { passed: true } }
31
31
 
32
32
  it_reports(<<~REPORT)
33
- (01/02) 50% - killtime: 2.00s runtime: 4.00s overhead: 2.00s
33
+ progress: 02/02 alive: 1 runtime: 4.00s killtime: 2.00s mutations/s: 0.50
34
34
  REPORT
35
35
  end
36
36
 
37
37
  context 'on success' do
38
38
  it_reports(<<~REPORT)
39
- (02/02) 100% - killtime: 2.00s runtime: 4.00s overhead: 2.00s
39
+ progress: 02/02 alive: 0 runtime: 4.00s killtime: 2.00s mutations/s: 0.50
40
40
  REPORT
41
41
  end
42
42
  end
@@ -24,6 +24,11 @@ RSpec.describe Mutant::Reporter::CLI::Printer::SubjectResult do
24
24
  -true
25
25
  +false
26
26
  -----------------------
27
+ - 1 @ runtime: 1.0
28
+ - test-a
29
+ Test Output:
30
+ mutation a test result output
31
+ -----------------------
27
32
  STR
28
33
  end
29
34
 
@@ -4,30 +4,12 @@ RSpec.describe Mutant::Reporter::CLI do
4
4
  setup_shared_context
5
5
 
6
6
  let(:object) { described_class.new(output, format) }
7
+ let(:tty?) { false }
7
8
 
8
- let(:tput) do
9
- instance_double(
10
- Mutant::Reporter::CLI::Tput,
11
- restore: '[tput-restore]',
12
- prepare: '[tput-prepare]'
13
- )
9
+ let(:format) do
10
+ described_class::Format::Progressive.new(tty?)
14
11
  end
15
12
 
16
- let(:framed_format) do
17
- described_class::Format::Framed.new(
18
- tty: false,
19
- tput: tput
20
- )
21
- end
22
-
23
- let(:tty?) { false }
24
-
25
- let(:progressive_format) do
26
- described_class::Format::Progressive.new(tty: tty?)
27
- end
28
-
29
- let(:format) { framed_format }
30
-
31
13
  def contents
32
14
  output.rewind
33
15
  output.read
@@ -47,56 +29,23 @@ RSpec.describe Mutant::Reporter::CLI do
47
29
  describe '.build' do
48
30
  subject { described_class.build(output) }
49
31
 
50
- let(:progressive_format) do
51
- described_class::Format::Progressive.new(tty: tty?)
52
- end
53
-
54
- let(:framed_format) do
55
- described_class::Format::Framed.new(
56
- tty: true,
57
- tput: tput
58
- )
59
- end
32
+ context 'when output is a tty' do
33
+ let(:tty?) { true }
34
+ let(:output) { instance_double(IO, tty?: true) }
60
35
 
61
- before do
62
- expect(ENV).to receive(:key?).with('CI').and_return(ci?)
36
+ it { should eql(described_class.new(output, format)) }
63
37
  end
64
38
 
65
- let(:output) { instance_double(IO, tty?: tty?) }
66
- let(:tty?) { true }
67
- let(:ci?) { false }
39
+ context 'when output is not a tty' do
40
+ context 'and does not respond to #tty?' do
41
+ let(:output) { nil }
68
42
 
69
- context 'when not on CI and on a tty' do
70
- before do
71
- expect(described_class::Tput).to receive(:detect).and_return(tput)
43
+ it { should eql(described_class.new(output, format)) }
72
44
  end
73
45
 
74
- context 'and tput is available' do
75
- it { should eql(described_class.new(output, framed_format)) }
46
+ context 'and does respond to #tty?' do
47
+ it { should eql(described_class.new(output, format)) }
76
48
  end
77
-
78
- context 'and tput is not available' do
79
- let(:tput) { nil }
80
-
81
- it { should eql(described_class.new(output, progressive_format)) }
82
- end
83
- end
84
-
85
- context 'when on CI' do
86
- let(:ci?) { true }
87
- it { should eql(described_class.new(output, progressive_format)) }
88
- end
89
-
90
- context 'when output is not a tty?' do
91
- let(:tty?) { false }
92
- it { should eql(described_class.new(output, progressive_format)) }
93
- end
94
-
95
- context 'when output does not respond to #tty?' do
96
- let(:output) { instance_double(IO) }
97
- let(:tty?) { false }
98
-
99
- it { should eql(described_class.new(output, progressive_format)) }
100
49
  end
101
50
  end
102
51
 
@@ -111,41 +60,41 @@ RSpec.describe Mutant::Reporter::CLI do
111
60
  describe '#delay' do
112
61
  subject { object.delay }
113
62
 
114
- it { should eql(0.05) }
63
+ it { should eql(1.0) }
115
64
  end
116
65
 
117
66
  describe '#start' do
118
67
  subject { object.start(env) }
119
68
 
120
- context 'on progressive format' do
121
- let(:format) { progressive_format }
122
-
123
- it_reports(<<~REPORT)
124
- Mutant configuration:
125
- Matcher: #<Mutant::Matcher::Config empty>
126
- Integration: Mutant::Integration::Null
127
- Jobs: 1
128
- Includes: []
129
- Requires: []
130
- REPORT
131
- end
132
-
133
- context 'on framed format' do
134
- it_reports '[tput-prepare]'
135
- end
69
+ it_reports(<<~REPORT)
70
+ Mutant environment:
71
+ Matcher: #<Mutant::Matcher::Config empty>
72
+ Integration: null
73
+ Jobs: 1
74
+ Includes: []
75
+ Requires: []
76
+ Subjects: 1
77
+ Total-Tests: 1
78
+ Selected-Tests: 1
79
+ Tests/Subject: 1.00 avg
80
+ Mutations: 2
81
+ REPORT
136
82
  end
137
83
 
138
84
  describe '#report' do
139
85
  subject { object.report(env_result) }
140
86
 
141
87
  it_reports(<<~REPORT)
142
- Mutant configuration:
88
+ Mutant environment:
143
89
  Matcher: #<Mutant::Matcher::Config empty>
144
- Integration: Mutant::Integration::Null
90
+ Integration: null
145
91
  Jobs: 1
146
92
  Includes: []
147
93
  Requires: []
148
94
  Subjects: 1
95
+ Total-Tests: 1
96
+ Selected-Tests: 1
97
+ Tests/Subject: 1.00 avg
149
98
  Mutations: 2
150
99
  Results: 2
151
100
  Kills: 2
@@ -161,53 +110,27 @@ RSpec.describe Mutant::Reporter::CLI do
161
110
  describe '#progress' do
162
111
  subject { object.progress(status) }
163
112
 
164
- context 'on framed format' do
165
- let(:format) { framed_format }
166
-
167
- it_reports(<<~REPORT)
168
- [tput-restore]Mutant configuration:
169
- Matcher: #<Mutant::Matcher::Config empty>
170
- Integration: Mutant::Integration::Null
171
- Jobs: 1
172
- Includes: []
173
- Requires: []
174
- Subjects: 1
175
- Mutations: 2
176
- Results: 2
177
- Kills: 2
178
- Alive: 0
179
- Runtime: 4.00s
180
- Killtime: 2.00s
181
- Overhead: 100.00%
182
- Mutations/s: 0.50
183
- Coverage: 100.00%
184
- Active subjects: 0
185
- REPORT
186
- end
113
+ context 'with empty scheduler' do
114
+ with(:env_result) { { subject_results: [] } }
187
115
 
188
- context 'on progressive format' do
189
- let(:format) { progressive_format }
116
+ let(:tty?) { true }
190
117
 
191
- context 'with empty scheduler' do
192
- with(:env_result) { { subject_results: [] } }
118
+ # rubocop:disable Metrics/LineLength
119
+ it_reports Mutant::Color::GREEN.format('progress: 00/02 alive: 0 runtime: 4.00s killtime: 0.00s mutations/s: 0.00') + "\n"
120
+ # rubocop:enable Metrics/LineLength
121
+ end
193
122
 
194
- let(:tty?) { true }
123
+ context 'with last mutation present' do
124
+ with(:env_result) { { subject_results: [subject_a_result] } }
195
125
 
196
- it_reports Mutant::Color::GREEN.format('(00/02) 100% - killtime: 0.00s runtime: 4.00s overhead: 4.00s') + "\n"
126
+ context 'when mutation is successful' do
127
+ it_reports "progress: 02/02 alive: 0 runtime: 4.00s killtime: 2.00s mutations/s: 0.50\n"
197
128
  end
198
129
 
199
- context 'with last mutation present' do
200
- with(:env_result) { { subject_results: [subject_a_result] } }
201
-
202
- context 'when mutation is successful' do
203
- it_reports "(02/02) 100% - killtime: 2.00s runtime: 4.00s overhead: 2.00s\n"
204
- end
205
-
206
- context 'when mutation is NOT successful' do
207
- with(:mutation_a_test_result) { { passed: true } }
130
+ context 'when mutation is NOT successful' do
131
+ with(:mutation_a_test_result) { { passed: true } }
208
132
 
209
- it_reports "(01/02) 50% - killtime: 2.00s runtime: 4.00s overhead: 2.00s\n"
210
- end
133
+ it_reports "progress: 02/02 alive: 1 runtime: 4.00s killtime: 2.00s mutations/s: 0.50\n"
211
134
  end
212
135
  end
213
136
  end