mutant 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/Changelog.md +5 -0
- data/TODO +0 -8
- data/config/flay.yml +1 -1
- data/config/reek.yml +4 -1
- data/lib/mutant.rb +1 -1
- data/lib/mutant/actor/env.rb +8 -8
- data/lib/mutant/actor/mailbox.rb +16 -31
- data/lib/mutant/actor/receiver.rb +7 -9
- data/lib/mutant/actor/sender.rb +3 -3
- data/lib/mutant/line_trace.rb +34 -0
- data/lib/mutant/reporter/cli.rb +17 -0
- data/lib/mutant/reporter/cli/format.rb +16 -17
- data/lib/mutant/reporter/cli/printer.rb +64 -17
- data/lib/mutant/reporter/trace.rb +12 -0
- data/lib/mutant/result.rb +3 -3
- data/lib/mutant/runner.rb +2 -5
- data/lib/mutant/runner/worker.rb +4 -6
- data/lib/mutant/subject.rb +23 -11
- data/lib/mutant/subject/method/instance.rb +3 -38
- data/lib/mutant/subject/method/singleton.rb +1 -1
- data/lib/mutant/version.rb +1 -1
- data/mutant.gemspec +1 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/support/fake_actor.rb +17 -11
- data/spec/support/shared_context.rb +0 -2
- data/spec/unit/mutant/actor/env_spec.rb +5 -25
- data/spec/unit/mutant/actor/mailbox_spec.rb +29 -0
- data/spec/unit/mutant/actor/receiver_spec.rb +24 -28
- data/spec/unit/mutant/actor/sender_spec.rb +9 -9
- data/spec/unit/mutant/line_trace_spec.rb +38 -0
- data/spec/unit/mutant/reporter/cli_spec.rb +154 -157
- data/spec/unit/mutant/runner/master_spec.rb +11 -11
- data/spec/unit/mutant/runner/worker_spec.rb +2 -3
- data/spec/unit/mutant/runner_spec.rb +13 -10
- data/spec/unit/mutant/subject_spec.rb +17 -2
- metadata +51 -50
- data/lib/mutant/actor/actor.rb +0 -50
- data/spec/unit/mutant/actor/actor_spec.rb +0 -35
- 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(
|
2
|
+
let(:object) { described_class.new(condition_variable, mutex, messages) }
|
3
3
|
|
4
|
-
let(:
|
5
|
-
let(:mutex)
|
6
|
-
let(:
|
7
|
-
let(:type)
|
8
|
-
let(:payload)
|
9
|
-
let(:_message)
|
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(
|
17
|
-
expect(
|
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:
|
97
|
-
Integration:
|
98
|
-
Expect Coverage:
|
99
|
-
Jobs:
|
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
|
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:
|
143
|
-
Integration:
|
144
|
-
Expect Coverage:
|
145
|
-
Jobs:
|
146
|
-
Includes:
|
147
|
-
Requires:
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
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:
|
169
|
-
Integration:
|
170
|
-
Expect Coverage:
|
171
|
-
Jobs:
|
172
|
-
Includes:
|
173
|
-
Requires:
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
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:
|
197
|
-
Integration:
|
198
|
-
Expect Coverage:
|
199
|
-
Jobs:
|
200
|
-
Includes:
|
201
|
-
Requires:
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
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:
|
226
|
-
Integration:
|
227
|
-
Expect Coverage:
|
228
|
-
Jobs:
|
229
|
-
Includes:
|
230
|
-
Requires:
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
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:
|
261
|
-
Integration:
|
262
|
-
Expect Coverage:
|
263
|
-
Jobs:
|
264
|
-
Includes:
|
265
|
-
Requires:
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
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:
|
294
|
-
Integration:
|
295
|
-
Expect Coverage:
|
296
|
-
Jobs:
|
297
|
-
Includes:
|
298
|
-
Requires:
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
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:
|
327
|
-
Integration:
|
328
|
-
Expect Coverage:
|
329
|
-
Jobs:
|
330
|
-
Includes:
|
331
|
-
Requires:
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
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:
|
386
|
-
Integration:
|
387
|
-
Expect Coverage:
|
388
|
-
Jobs:
|
389
|
-
Includes:
|
390
|
-
Requires:
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
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:
|
436
|
-
Integration:
|
437
|
-
Expect Coverage:
|
438
|
-
Jobs:
|
439
|
-
Includes:
|
440
|
-
Requires:
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
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
|