mutant 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +0 -1
  3. data/Changelog.md +5 -0
  4. data/TODO +0 -8
  5. data/config/flay.yml +1 -1
  6. data/config/reek.yml +4 -1
  7. data/lib/mutant.rb +1 -1
  8. data/lib/mutant/actor/env.rb +8 -8
  9. data/lib/mutant/actor/mailbox.rb +16 -31
  10. data/lib/mutant/actor/receiver.rb +7 -9
  11. data/lib/mutant/actor/sender.rb +3 -3
  12. data/lib/mutant/line_trace.rb +34 -0
  13. data/lib/mutant/reporter/cli.rb +17 -0
  14. data/lib/mutant/reporter/cli/format.rb +16 -17
  15. data/lib/mutant/reporter/cli/printer.rb +64 -17
  16. data/lib/mutant/reporter/trace.rb +12 -0
  17. data/lib/mutant/result.rb +3 -3
  18. data/lib/mutant/runner.rb +2 -5
  19. data/lib/mutant/runner/worker.rb +4 -6
  20. data/lib/mutant/subject.rb +23 -11
  21. data/lib/mutant/subject/method/instance.rb +3 -38
  22. data/lib/mutant/subject/method/singleton.rb +1 -1
  23. data/lib/mutant/version.rb +1 -1
  24. data/mutant.gemspec +1 -1
  25. data/spec/spec_helper.rb +2 -0
  26. data/spec/support/fake_actor.rb +17 -11
  27. data/spec/support/shared_context.rb +0 -2
  28. data/spec/unit/mutant/actor/env_spec.rb +5 -25
  29. data/spec/unit/mutant/actor/mailbox_spec.rb +29 -0
  30. data/spec/unit/mutant/actor/receiver_spec.rb +24 -28
  31. data/spec/unit/mutant/actor/sender_spec.rb +9 -9
  32. data/spec/unit/mutant/line_trace_spec.rb +38 -0
  33. data/spec/unit/mutant/reporter/cli_spec.rb +154 -157
  34. data/spec/unit/mutant/runner/master_spec.rb +11 -11
  35. data/spec/unit/mutant/runner/worker_spec.rb +2 -3
  36. data/spec/unit/mutant/runner_spec.rb +13 -10
  37. data/spec/unit/mutant/subject_spec.rb +17 -2
  38. metadata +51 -50
  39. data/lib/mutant/actor/actor.rb +0 -50
  40. data/spec/unit/mutant/actor/actor_spec.rb +0 -35
  41. data/spec/unit/mutant/mailbox_spec.rb +0 -33
@@ -1,20 +1,20 @@
1
1
  RSpec.describe Mutant::Actor::Sender do
2
- let(:object) { described_class.new(thread, mutex, mailbox) }
2
+ let(:object) { described_class.new(condition_variable, mutex, messages) }
3
3
 
4
- let(:thread) { double('Thread') }
5
- let(:mutex) { double('Mutex') }
6
- let(:mailbox) { double('Mailbox') }
7
- let(:type) { double('Type') }
8
- let(:payload) { double('Payload') }
9
- let(:_message) { message(type, payload) }
4
+ let(:condition_variable) { double('Condition Variable') }
5
+ let(:mutex) { double('Mutex') }
6
+ let(:messages) { double('Messages') }
7
+ let(:type) { double('Type') }
8
+ let(:payload) { double('Payload') }
9
+ let(:_message) { message(type, payload) }
10
10
 
11
11
  describe '#call' do
12
12
  subject { object.call(_message) }
13
13
 
14
14
  before do
15
15
  expect(mutex).to receive(:synchronize).ordered.and_yield
16
- expect(mailbox).to receive(:<<).with(_message)
17
- expect(thread).to receive(:run)
16
+ expect(messages).to receive(:<<).with(_message).ordered
17
+ expect(condition_variable).to receive(:signal).ordered
18
18
  end
19
19
 
20
20
  it_should_behave_like 'a command method'
@@ -0,0 +1,38 @@
1
+ RSpec.describe Mutant::LineTrace do
2
+ let(:object) { described_class }
3
+
4
+ test_a_line = __LINE__ + 2
5
+ def test_a
6
+ test_b
7
+ end
8
+
9
+ test_b_line = __LINE__ + 2
10
+ def test_b
11
+ end
12
+
13
+ test_c_line = __LINE__ + 2
14
+ def test_c
15
+ end
16
+
17
+ shared_examples_for 'line trace' do
18
+ it 'returns correct trace results' do
19
+ expect(subject.cover?(__FILE__, test_a_line)).to be(true)
20
+ expect(subject.cover?(__FILE__, test_b_line)).to be(true)
21
+ expect(subject.cover?(__FILE__, test_c_line)).to be(false)
22
+ expect(subject.cover?(__FILE__, __LINE__)).to be(false)
23
+ expect(subject.cover?('/dev/null', test_a_line)).to be(false)
24
+ end
25
+ end
26
+
27
+ describe '.cover?' do
28
+ subject { object.call { test_a } }
29
+
30
+ include_examples 'line trace'
31
+ end
32
+
33
+ describe '.call' do
34
+ subject { object.call { test_a } }
35
+
36
+ include_examples 'line trace'
37
+ end
38
+ end
@@ -85,6 +85,12 @@ RSpec.describe Mutant::Reporter::CLI do
85
85
  it_reports("message\n")
86
86
  end
87
87
 
88
+ describe '#delay' do
89
+ subject { object.delay }
90
+
91
+ it { should eql(0.05) }
92
+ end
93
+
88
94
  describe '#start' do
89
95
  subject { object.start(env) }
90
96
 
@@ -93,12 +99,12 @@ RSpec.describe Mutant::Reporter::CLI do
93
99
 
94
100
  it_reports(<<-REPORT)
95
101
  Mutant configuration:
96
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
97
- Integration: null
98
- Expect Coverage: 100.00%
99
- Jobs: 1
100
- Includes: []
101
- Requires: []
102
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
103
+ Integration: null
104
+ Expect Coverage: 100.00%
105
+ Jobs: 1
106
+ Includes: []
107
+ Requires: []
102
108
  REPORT
103
109
  end
104
110
 
@@ -116,19 +122,19 @@ RSpec.describe Mutant::Reporter::CLI do
116
122
  context 'with empty scheduler' do
117
123
  update(:env_result) { { subject_results: [] } }
118
124
 
119
- it_reports ''
125
+ it_reports "(00/02) 0% - killtime: 0.00s runtime: 4.00s overhead: 4.00s\n"
120
126
  end
121
127
 
122
128
  context 'with last mutation present' do
123
129
  update(:env_result) { { subject_results: [subject_a_result] } }
124
130
 
125
131
  context 'when mutation is successful' do
126
- it_reports '..'
132
+ it_reports "(02/02) 100% - killtime: 2.00s runtime: 4.00s overhead: 2.00s\n"
127
133
  end
128
134
 
129
135
  context 'when mutation is NOT successful' do
130
136
  update(:mutation_a_test_result) { { passed: true } }
131
- it_reports 'F.'
137
+ it_reports "(01/02) 50% - killtime: 2.00s runtime: 4.00s overhead: 2.00s\n"
132
138
  end
133
139
  end
134
140
  end
@@ -139,23 +145,22 @@ RSpec.describe Mutant::Reporter::CLI do
139
145
 
140
146
  it_reports <<-REPORT
141
147
  Mutant configuration:
142
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
143
- Integration: null
144
- Expect Coverage: 100.00%
145
- Jobs: 1
146
- Includes: []
147
- Requires: []
148
- Available Subjects: 1
149
- Subjects: 1
150
- Mutations: 2
151
- Kills: 0
152
- Alive: 0
153
- Runtime: 4.00s
154
- Killtime: 0.00s
155
- Overhead: Inf%
156
- Coverage: 0.00%
157
- Expected: 100.00%
158
- Active subjects: 0
148
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
149
+ Integration: null
150
+ Expect Coverage: 100.00%
151
+ Jobs: 1
152
+ Includes: []
153
+ Requires: []
154
+ Subjects: 1
155
+ Mutations: 2
156
+ Kills: 0
157
+ Alive: 0
158
+ Runtime: 4.00s
159
+ Killtime: 0.00s
160
+ Overhead: Inf%
161
+ Coverage: 0.00%
162
+ Expected: 100.00%
163
+ Active subjects: 0
159
164
  REPORT
160
165
  end
161
166
 
@@ -165,23 +170,22 @@ RSpec.describe Mutant::Reporter::CLI do
165
170
 
166
171
  it_reports(<<-REPORT)
167
172
  Mutant configuration:
168
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
169
- Integration: null
170
- Expect Coverage: 100.00%
171
- Jobs: 1
172
- Includes: []
173
- Requires: []
174
- Available Subjects: 1
175
- Subjects: 1
176
- Mutations: 2
177
- Kills: 2
178
- Alive: 0
179
- Runtime: 4.00s
180
- Killtime: 2.00s
181
- Overhead: 100.00%
182
- Coverage: 100.00%
183
- Expected: 100.00%
184
- Active subjects: 0
173
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
174
+ Integration: null
175
+ Expect Coverage: 100.00%
176
+ Jobs: 1
177
+ Includes: []
178
+ Requires: []
179
+ Subjects: 1
180
+ Mutations: 2
181
+ Kills: 2
182
+ Alive: 0
183
+ Runtime: 4.00s
184
+ Killtime: 2.00s
185
+ Overhead: 100.00%
186
+ Coverage: 100.00%
187
+ Expected: 100.00%
188
+ Active subjects: 0
185
189
  REPORT
186
190
  end
187
191
 
@@ -193,23 +197,22 @@ RSpec.describe Mutant::Reporter::CLI do
193
197
 
194
198
  it_reports(<<-REPORT)
195
199
  Mutant configuration:
196
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
197
- Integration: null
198
- Expect Coverage: 100.00%
199
- Jobs: 1
200
- Includes: []
201
- Requires: []
202
- Available Subjects: 1
203
- Subjects: 1
204
- Mutations: 2
205
- Kills: 1
206
- Alive: 1
207
- Runtime: 4.00s
208
- Killtime: 2.00s
209
- Overhead: 100.00%
210
- Coverage: 50.00%
211
- Expected: 100.00%
212
- Active subjects: 1
200
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
201
+ Integration: null
202
+ Expect Coverage: 100.00%
203
+ Jobs: 1
204
+ Includes: []
205
+ Requires: []
206
+ Subjects: 1
207
+ Mutations: 2
208
+ Kills: 1
209
+ Alive: 1
210
+ Runtime: 4.00s
211
+ Killtime: 2.00s
212
+ Overhead: 100.00%
213
+ Coverage: 50.00%
214
+ Expected: 100.00%
215
+ Active subjects: 1
213
216
  subject-a mutations: 2
214
217
  - test-a
215
218
  F.
@@ -222,23 +225,22 @@ RSpec.describe Mutant::Reporter::CLI do
222
225
  context 'on success' do
223
226
  it_reports(<<-REPORT)
224
227
  Mutant configuration:
225
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
226
- Integration: null
227
- Expect Coverage: 100.00%
228
- Jobs: 1
229
- Includes: []
230
- Requires: []
231
- Available Subjects: 1
232
- Subjects: 1
233
- Mutations: 2
234
- Kills: 2
235
- Alive: 0
236
- Runtime: 4.00s
237
- Killtime: 2.00s
238
- Overhead: 100.00%
239
- Coverage: 100.00%
240
- Expected: 100.00%
241
- Active subjects: 1
228
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
229
+ Integration: null
230
+ Expect Coverage: 100.00%
231
+ Jobs: 1
232
+ Includes: []
233
+ Requires: []
234
+ Subjects: 1
235
+ Mutations: 2
236
+ Kills: 2
237
+ Alive: 0
238
+ Runtime: 4.00s
239
+ Killtime: 2.00s
240
+ Overhead: 100.00%
241
+ Coverage: 100.00%
242
+ Expected: 100.00%
243
+ Active subjects: 1
242
244
  subject-a mutations: 2
243
245
  - test-a
244
246
  ..
@@ -257,22 +259,21 @@ RSpec.describe Mutant::Reporter::CLI do
257
259
  context 'with full coverage' do
258
260
  it_reports(<<-REPORT)
259
261
  Mutant configuration:
260
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
261
- Integration: null
262
- Expect Coverage: 100.00%
263
- Jobs: 1
264
- Includes: []
265
- Requires: []
266
- Available Subjects: 1
267
- Subjects: 1
268
- Mutations: 2
269
- Kills: 2
270
- Alive: 0
271
- Runtime: 4.00s
272
- Killtime: 2.00s
273
- Overhead: 100.00%
274
- Coverage: 100.00%
275
- Expected: 100.00%
262
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
263
+ Integration: null
264
+ Expect Coverage: 100.00%
265
+ Jobs: 1
266
+ Includes: []
267
+ Requires: []
268
+ Subjects: 1
269
+ Mutations: 2
270
+ Kills: 2
271
+ Alive: 0
272
+ Runtime: 4.00s
273
+ Killtime: 2.00s
274
+ Overhead: 100.00%
275
+ Coverage: 100.00%
276
+ Expected: 100.00%
276
277
  REPORT
277
278
  end
278
279
 
@@ -290,22 +291,21 @@ RSpec.describe Mutant::Reporter::CLI do
290
291
  +false
291
292
  -----------------------
292
293
  Mutant configuration:
293
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
294
- Integration: null
295
- Expect Coverage: 100.00%
296
- Jobs: 1
297
- Includes: []
298
- Requires: []
299
- Available Subjects: 1
300
- Subjects: 1
301
- Mutations: 2
302
- Kills: 1
303
- Alive: 1
304
- Runtime: 4.00s
305
- Killtime: 2.00s
306
- Overhead: 100.00%
307
- Coverage: 50.00%
308
- Expected: 100.00%
294
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
295
+ Integration: null
296
+ Expect Coverage: 100.00%
297
+ Jobs: 1
298
+ Includes: []
299
+ Requires: []
300
+ Subjects: 1
301
+ Mutations: 2
302
+ Kills: 1
303
+ Alive: 1
304
+ Runtime: 4.00s
305
+ Killtime: 2.00s
306
+ Overhead: 100.00%
307
+ Coverage: 50.00%
308
+ Expected: 100.00%
309
309
  REPORT
310
310
  end
311
311
 
@@ -323,22 +323,21 @@ RSpec.describe Mutant::Reporter::CLI do
323
323
  BUG: Mutation NOT resulted in exactly one diff hunk. Please report a reproduction!
324
324
  -----------------------
325
325
  Mutant configuration:
326
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
327
- Integration: null
328
- Expect Coverage: 100.00%
329
- Jobs: 1
330
- Includes: []
331
- Requires: []
332
- Available Subjects: 1
333
- Subjects: 1
334
- Mutations: 2
335
- Kills: 1
336
- Alive: 1
337
- Runtime: 4.00s
338
- Killtime: 2.00s
339
- Overhead: 100.00%
340
- Coverage: 50.00%
341
- Expected: 100.00%
326
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
327
+ Integration: null
328
+ Expect Coverage: 100.00%
329
+ Jobs: 1
330
+ Includes: []
331
+ Requires: []
332
+ Subjects: 1
333
+ Mutations: 2
334
+ Kills: 1
335
+ Alive: 1
336
+ Runtime: 4.00s
337
+ Killtime: 2.00s
338
+ Overhead: 100.00%
339
+ Coverage: 50.00%
340
+ Expected: 100.00%
342
341
  REPORT
343
342
  end
344
343
  end
@@ -382,22 +381,21 @@ RSpec.describe Mutant::Reporter::CLI do
382
381
  mutation b test result output
383
382
  -----------------------
384
383
  Mutant configuration:
385
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
386
- Integration: null
387
- Expect Coverage: 100.00%
388
- Jobs: 1
389
- Includes: []
390
- Requires: []
391
- Available Subjects: 1
392
- Subjects: 1
393
- Mutations: 2
394
- Kills: 0
395
- Alive: 2
396
- Runtime: 4.00s
397
- Killtime: 2.00s
398
- Overhead: 100.00%
399
- Coverage: 0.00%
400
- Expected: 100.00%
384
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
385
+ Integration: null
386
+ Expect Coverage: 100.00%
387
+ Jobs: 1
388
+ Includes: []
389
+ Requires: []
390
+ Subjects: 1
391
+ Mutations: 2
392
+ Kills: 0
393
+ Alive: 2
394
+ Runtime: 4.00s
395
+ Killtime: 2.00s
396
+ Overhead: 100.00%
397
+ Coverage: 0.00%
398
+ Expected: 100.00%
401
399
  REPORT
402
400
  end
403
401
 
@@ -432,22 +430,21 @@ RSpec.describe Mutant::Reporter::CLI do
432
430
  mutation b test result output
433
431
  -----------------------
434
432
  Mutant configuration:
435
- Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
436
- Integration: null
437
- Expect Coverage: 100.00%
438
- Jobs: 1
439
- Includes: []
440
- Requires: []
441
- Available Subjects: 1
442
- Subjects: 1
443
- Mutations: 2
444
- Kills: 0
445
- Alive: 2
446
- Runtime: 4.00s
447
- Killtime: 2.00s
448
- Overhead: 100.00%
449
- Coverage: 0.00%
450
- Expected: 100.00%
433
+ Matcher: #<Mutant::Matcher::Config match_expressions=[] subject_ignores=[] subject_selects=[]>
434
+ Integration: null
435
+ Expect Coverage: 100.00%
436
+ Jobs: 1
437
+ Includes: []
438
+ Requires: []
439
+ Subjects: 1
440
+ Mutations: 2
441
+ Kills: 0
442
+ Alive: 2
443
+ Runtime: 4.00s
444
+ Killtime: 2.00s
445
+ Overhead: 100.00%
446
+ Coverage: 0.00%
447
+ Expected: 100.00%
451
448
  REPORT
452
449
  end
453
450
  end