@@ -2,21 +2,22 @@ require "./spec_helper"
2
2
3
3
{% unless flag?(" skip-integration" ) % }
4
4
describe Crytic do
5
- describe " the test command" do
6
- describe " --help/-h" do
7
- it " prints usage info" do
8
- result = run_crytic(" --help" )
9
- result.output.should contain(" Usage: crytic [arguments]" )
10
- result.exit_code.should eq 0
11
- result = run_crytic(" -h" )
12
- result.output.should contain(" Usage: crytic [arguments]" )
13
- result.exit_code.should eq 0
14
- end
5
+ describe " --help/-h" do
6
+ it " prints usage info" do
7
+ result = run_crytic(" --help" )
8
+ result.output.should contain(" Usage: crytic [arguments]" )
9
+ result.exit_code.should eq 0
10
+ result = run_crytic(" -h" )
11
+ result.output.should contain(" Usage: crytic [arguments]" )
12
+ result.exit_code.should eq 0
15
13
end
14
+ end
16
15
16
+ {% for command in [" test" , " test-parallel" ] % }
17
+ describe " the {{ command.id }} command" do
17
18
describe " --preamble/-p" do
18
19
it " injects the given custom preamble, failing the neutral mutant" do
19
- result = run_crytic(" test -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr -p 'exit 1'" )
20
+ result = run_crytic(" {{ command.id }} -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr -p 'exit 1'" )
20
21
result.output.should contain(" unmodified subject" )
21
22
result.output.should_not contain(" ConditionFlip" )
22
23
result.exit_code.should eq 1
@@ -25,7 +26,7 @@ require "./spec_helper"
25
26
26
27
describe " with a fully covered subject" do
27
28
it " passes the mutation specs" do
28
- result = run_crytic(" -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/fully_covered_spec.cr" )
29
+ result = run_crytic(" {{ command.id }} -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/fully_covered_spec.cr" )
29
30
result.output.should contain(" ✅ ConditionFlip" )
30
31
result.output.should contain(" ✅ BoolLiteralFlip" )
31
32
result.output.should contain(" 3 covered" )
@@ -35,22 +36,22 @@ require "./spec_helper"
35
36
36
37
describe " with an insufficiently covered subject" do
37
38
it " fails the mutation specs" do
38
- result = run_crytic(" -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr" )
39
+ result = run_crytic(" {{ command.id }} -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr" )
39
40
result.output.should contain(" ❌ ConditionFlip" )
40
41
result.output.should contain(" ❌ BoolLiteralFlip" )
41
42
result.output.should contain(" 3 uncovered" )
42
43
result.exit_code.should be > 0
43
44
end
44
45
45
46
it " exits successfully when the msi threshold is set sufficiently" do
46
- result = run_crytic(" --min-msi=0.0 -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr" )
47
+ result = run_crytic(" {{ command.id }} --min-msi=0.0 -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr" )
47
48
result.exit_code.should eq 0
48
49
end
49
50
end
50
51
51
52
describe " without passing a subject or tests" do
52
53
it " mutates all sources and runs all tests" do
53
- result = run_crytic_in_dir(" ./fixtures/autofind" )
54
+ result = run_crytic_in_dir(" ./fixtures/autofind" , {{ command }} )
54
55
result.output.should contain(" ✅ ConditionFlip" )
55
56
result.output.should contain(" ✅ BoolLiteralFlip" )
56
57
result.output.should contain(" ✅ NumberLiteralSignFlip" )
@@ -64,7 +65,7 @@ require "./spec_helper"
64
65
65
66
describe " subject without any coverage" do
66
67
it " fails all mutants" do
67
- result = run_crytic(" -s ./fixtures/uncovered/without.cr ./fixtures/uncovered/without_spec.cr" )
68
+ result = run_crytic(" {{ command.id }} -s ./fixtures/uncovered/without.cr ./fixtures/uncovered/without_spec.cr" )
68
69
result.output.should contain(" ❌ BoolLiteralFlip" )
69
70
result.output.should contain(" ❌ ConditionFlip" )
70
71
result.output.should contain(" ❌ NumberLiteralSignFlip" )
@@ -76,7 +77,7 @@ require "./spec_helper"
76
77
77
78
describe " a failing initial test suite" do
78
79
it " reports initial failure" do
79
- result = run_crytic(" -s ./fixtures/uncovered/without.cr ./fixtures/failing/failing_spec.cr" )
80
+ result = run_crytic(" {{ command.id }} -s ./fixtures/uncovered/without.cr ./fixtures/failing/failing_spec.cr" )
80
81
result.output.should contain " ❌ Original test suite failed.\n "
81
82
result.output.should contain " no overload matches"
82
83
result.exit_code.should be > 0
@@ -85,13 +86,14 @@ require "./spec_helper"
85
86
86
87
describe " a subject that is mutated into an endless loop" do
87
88
it " finishes and reports a timed out spec" do
88
- result = run_crytic(" -s ./fixtures/timeout/timeout.cr ./fixtures/timeout/timeout_spec.cr" )
89
+ result = run_crytic(" {{ command.id }} -s ./fixtures/timeout/timeout.cr ./fixtures/timeout/timeout_spec.cr" )
89
90
result.output.should contain " ✅ Original test suite passed.\n "
90
91
result.output.should contain " 1 timeout"
91
92
result.exit_code.should be > 0
92
93
end
93
94
end
94
95
end
96
+ {% end % }
95
97
96
98
describe " the noop command" do
97
99
it " outputs the noop'ed code to stdout" do
@@ -103,9 +105,9 @@ require "./spec_helper"
103
105
end
104
106
{% end % }
105
107
106
- def run_crytic_in_dir (dir : String )
108
+ def run_crytic_in_dir (dir : String , args : String )
107
109
io = IO ::Memory .new
108
- result = Process .run(" cd #{ dir } && crystal run ../../src/crytic.cr" ,
110
+ result = Process .run(" cd #{ dir } && crystal run ../../src/crytic.cr -- #{ args } " ,
109
111
output: io,
110
112
error: io,
111
113
shell: true ,
0 commit comments