@@ -9,73 +9,71 @@ module Crytic::Runner
9
9
10
10
describe Sequential do
11
11
describe " #run" do
12
- it " takes a list of subjects" do
13
- reporter = FakeReporter .new
14
- runner = Sequential .new(
15
- threshold: 100.0 ,
16
- generator: FakeGenerator .new,
17
- reporters: [reporter] of Crytic ::Reporter ::Reporter ,
18
- no_mutation_factory: fake_no_mutation_factory)
19
-
20
- runner.run(
21
- subjects([" ./fixtures/require_order/blog.cr" , " ./fixtures/require_order/pages/blog/archive.cr" ]),
22
- [" ./fixtures/simple/bar_spec.cr" ]).should eq false
12
+ it " returns the runs final result" do
13
+ run = FakeRun .new
14
+ run.final_result = true
15
+
16
+ Sequential .new.run(run, side_effects).should eq true
17
+
18
+ run.final_result = false
19
+ Sequential .new.run(run, side_effects).should eq false
23
20
end
24
21
25
- it " doesn't execute mutations if the initial suite run fails" do
26
- reporter = FakeReporter .new
27
- runner = Sequential .new(
28
- threshold: 100.0 ,
29
- generator: FakeGenerator .new,
30
- reporters: [reporter] of Crytic ::Reporter ::Reporter ,
31
- no_mutation_factory: - > (specs : Array (String )) {
32
- process_runner = Crytic ::FakeProcessRunner .new
33
- no_mutation = Crytic ::Mutation ::NoMutation .with(specs, process_runner)
34
- process_runner.exit_code = [1 , 0 ]
35
- no_mutation
36
- })
37
-
38
- runner.run(
39
- subjects([" ./fixtures/require_order/blog.cr" , " ./fixtures/require_order/pages/blog/archive.cr" ]),
40
- [" ./fixtures/simple/bar_spec.cr" ]).should eq false
22
+ it " returns false if the original spec suite fails" do
23
+ run = FakeRun .new
24
+ run.original_exit_code = 1
25
+
26
+ Sequential .new.run(run, side_effects).should eq false
41
27
end
42
28
43
- it " reports events in order" do
44
- reporter = FakeReporter .new
45
- runner = Sequential .new(
46
- threshold: 100.0 ,
47
- generator: FakeGenerator .new([fake_mutation]),
48
- reporters: [reporter] of Crytic ::Reporter ::Reporter ,
49
- no_mutation_factory: fake_no_mutation_factory)
29
+ it " reports neutral results before mutation results" do
30
+ run = FakeRun .new
31
+ run.mutations = [FakeMutation .new.as(Crytic ::Mutation ::Mutation )]
50
32
51
- runner. run(subjects([ " ./fixtures/simple/bar.cr " ]), [ " ./fixtures/simple/bar_spec.cr " ] )
33
+ Sequential .new. run(run, side_effects )
52
34
53
- reporter .events.should eq [" report_original_result " , " report_mutations " , " report_neutral_result" , " report_result" , " report_summary " , " report_msi " ]
35
+ run .events.should eq [" report_neutral_result" , " report_result" ]
54
36
end
55
37
56
38
it " skips the mutations if the neutral result errored" do
57
- reporter = FakeReporter .new
39
+ run = FakeRun .new
58
40
mutation = fake_mutation
59
- runner = Sequential .new(
60
- threshold: 100.0 ,
61
- generator: FakeGenerator .new(
62
- neutral: erroring_mutation,
63
- mutations: [mutation]),
64
- reporters: [reporter] of Crytic ::Reporter ::Reporter ,
65
- no_mutation_factory: fake_no_mutation_factory)
41
+ run.neutral = FakeMutation .new(Crytic ::Mutation ::Status ::Errored )
42
+ run.mutations = [mutation]
66
43
67
- runner. run(subjects([ " ./fixtures/simple/bar.cr " ]), [ " ./fixtures/simple/bar_spec.cr " ] )
44
+ Sequential .new. run(run, side_effects )
68
45
69
- reporter .events.should_not contain(" report_result" )
46
+ run .events.should_not contain(" report_result" )
70
47
mutation.as(FakeMutation ).run_call_count.should eq 0
71
48
end
72
49
end
73
50
end
74
51
end
75
52
76
- private def runner
77
- Crytic ::Runner ::Sequential .new(
78
- threshold: 100.0 ,
79
- reporters: [] of Crytic ::Reporter ::Reporter ,
80
- generator: FakeGenerator .new)
53
+ private class FakeRun
54
+ property mutations = [] of Crytic ::Mutation ::Mutation
55
+ property events = [] of String
56
+ property original_exit_code = 0
57
+ property final_result = true
58
+ property neutral = FakeMutation .new.as(Crytic ::Mutation ::Mutation )
59
+
60
+ def generate_mutations
61
+ [Crytic ::Generator ::MutationSet .new(neutral, mutations)]
62
+ end
63
+
64
+ def report_neutral_result (result )
65
+ events << " report_neutral_result"
66
+ end
67
+
68
+ def report_result (result )
69
+ events << " report_result"
70
+ end
71
+
72
+ def report_final (results )
73
+ final_result
74
+ end
75
+
76
+ def execute_original_test_suite (side_effects )
77
+ Crytic ::Mutation ::OriginalResult .new(exit_code: original_exit_code, output: " " )
78
+ end
81
79
end
0 commit comments