Skip to content

Commit 541ea23

Browse files
Actually we just need one runner
1 parent 4151c18 commit 541ea23

File tree

10 files changed

+19
-126
lines changed

10 files changed

+19
-126
lines changed

bin/test-mutations

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
list=(`find spec -name '*_spec.cr' -and -not -name 'integration_spec.cr'`)
44
printf '%s\n' "${list[@]}" | sort
5-
./bin/crytic test-parallel --min-msi=70.0 --reporters=Console,Stryker,ConsoleFileSummary "${list[@]}"
5+
./bin/crytic test --min-msi=70.0 --reporters=Console,Stryker,ConsoleFileSummary "${list[@]}"

bin/test-unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env bash
22

3-
crystal spec -D skip-integration
3+
crystal spec -Dpreview-mt -D skip-integration

spec/integration_spec.cr

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,10 @@ require "./spec_helper"
1313
end
1414
end
1515

16-
{% for command in ["test", "test-parallel"] %}
17-
describe "the {{ command.id }} command" do
16+
describe "the test command" do
1817
describe "--preamble/-p" do
1918
it "injects the given custom preamble, failing the neutral mutant" do
20-
result = run_crytic("{{ command.id }} -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr -p 'exit 1'")
19+
result = run_crytic("test -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr -p 'exit 1'")
2120
result.output.should contain("unmodified subject")
2221
result.output.should_not contain("ConditionFlip")
2322
result.exit_code.should eq 1
@@ -26,7 +25,7 @@ require "./spec_helper"
2625

2726
describe "with a fully covered subject" do
2827
it "passes the mutation specs" do
29-
result = run_crytic("{{ command.id }} -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/fully_covered_spec.cr")
28+
result = run_crytic("test -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/fully_covered_spec.cr")
3029
result.output.should contain("✅ ConditionFlip")
3130
result.output.should contain("✅ BoolLiteralFlip")
3231
result.output.should contain("3 covered")
@@ -36,22 +35,22 @@ require "./spec_helper"
3635

3736
describe "with an insufficiently covered subject" do
3837
it "fails the mutation specs" do
39-
result = run_crytic("{{ command.id }} -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr")
38+
result = run_crytic("test -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr")
4039
result.output.should contain("❌ ConditionFlip")
4140
result.output.should contain("❌ BoolLiteralFlip")
4241
result.output.should contain("3 uncovered")
4342
result.exit_code.should be > 0
4443
end
4544

4645
it "exits successfully when the msi threshold is set sufficiently" do
47-
result = run_crytic("{{ command.id }} --min-msi=0.0 -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr")
46+
result = run_crytic("test --min-msi=0.0 -s ./fixtures/conditionals/fully_covered.cr ./fixtures/conditionals/uncovered_spec.cr")
4847
result.exit_code.should eq 0
4948
end
5049
end
5150

5251
describe "without passing a subject or tests" do
5352
it "mutates all sources and runs all tests" do
54-
result = run_crytic_in_dir("./fixtures/autofind", {{ command }})
53+
result = run_crytic_in_dir("./fixtures/autofind", "test")
5554
result.output.should contain("✅ ConditionFlip")
5655
result.output.should contain("✅ BoolLiteralFlip")
5756
result.output.should contain("✅ NumberLiteralSignFlip")
@@ -65,7 +64,7 @@ require "./spec_helper"
6564

6665
describe "subject without any coverage" do
6766
it "fails all mutants" do
68-
result = run_crytic("{{ command.id }} -s ./fixtures/uncovered/without.cr ./fixtures/uncovered/without_spec.cr")
67+
result = run_crytic("test -s ./fixtures/uncovered/without.cr ./fixtures/uncovered/without_spec.cr")
6968
result.output.should contain("❌ BoolLiteralFlip")
7069
result.output.should contain("❌ ConditionFlip")
7170
result.output.should contain("❌ NumberLiteralSignFlip")
@@ -77,7 +76,7 @@ require "./spec_helper"
7776

7877
describe "a failing initial test suite" do
7978
it "reports initial failure" do
80-
result = run_crytic("{{ command.id }} -s ./fixtures/uncovered/without.cr ./fixtures/failing/failing_spec.cr")
79+
result = run_crytic("test -s ./fixtures/uncovered/without.cr ./fixtures/failing/failing_spec.cr")
8180
result.output.should contain "❌ Original test suite failed.\n"
8281
result.output.should contain "no overload matches"
8382
result.exit_code.should be > 0
@@ -86,14 +85,13 @@ require "./spec_helper"
8685

8786
describe "a subject that is mutated into an endless loop" do
8887
it "finishes and reports a timed out spec" do
89-
result = run_crytic("{{ command.id }} -s ./fixtures/timeout/timeout.cr ./fixtures/timeout/timeout_spec.cr")
88+
result = run_crytic("test -s ./fixtures/timeout/timeout.cr ./fixtures/timeout/timeout_spec.cr")
9089
result.output.should contain "✅ Original test suite passed.\n"
9190
result.output.should contain "1 timeout"
9291
result.exit_code.should be > 0
9392
end
9493
end
9594
end
96-
{% end %}
9795

9896
describe "the noop command" do
9997
it "outputs the noop'ed code to stdout" do

spec/runner/sequential_spec.cr

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/crytic/cli.cr

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require "./command/*"
22
require "./runner/parallel"
3-
require "./runner/sequential"
43
require "./side_effects"
54

65
module Crytic
@@ -12,15 +11,13 @@ module Crytic
1211
def run(args)
1312
case args.first?
1413
when "test"
15-
Command::Test.new(Runner::Sequential.new, @side_effects).execute(args.tap(&.shift))
16-
when "test-parallel"
17-
Command::Test.new(Runner::Parallel.new, @side_effects).execute(args.tap(&.shift))
14+
Command::Test.new(@side_effects).execute(args.tap(&.shift))
1815
when "noop"
1916
Command::Noop
2017
.new(@side_effects, Command::Noop::DEFAULT_SPEC_FILES_GLOB)
2118
.execute(args.tap(&.shift))
2219
else
23-
Command::Test.new(Runner::Sequential.new, @side_effects).execute(args)
20+
Command::Test.new(@side_effects).execute(args)
2421
end
2522
end
2623
end

src/crytic/cli_options.cr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module Crytic
1414
@preamble = Generator::Generator::DEFAULT_PREAMBLE
1515
@spec_files = [] of String
1616
@subject = [] of String
17-
getter multi_threaded : Bool = false
1817

1918
def initialize(@side_effects : SideEffects, @spec_files_glob : String)
2019
@reporters << Reporter::IoReporter.new(@side_effects.std_out)

src/crytic/command/test.cr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ require "../cli_options"
22
require "../generator/in_memory_generator"
33
require "../generator/isolated_mutation_factory"
44
require "../mutation/no_mutation"
5+
require "../runner/parallel"
56
require "../runner/run"
6-
require "../runner/runner"
77
require "../side_effects"
88
require "../subject"
99

1010
class Crytic::Command::Test
11-
def initialize(@runner : Runner::Runner, @side_effects : SideEffects)
11+
def initialize(@side_effects : SideEffects)
1212
end
1313

1414
def execute(args)
@@ -18,7 +18,7 @@ class Crytic::Command::Test
1818
Mutation::NoMutation.with(specs)
1919
}
2020

21-
@runner.run(Crytic::Runner::Run.from_options(options, generator, factory), @side_effects)
21+
Crytic::Runner::Parallel.run(Crytic::Runner::Run.from_options(options, generator, factory), @side_effects)
2222
end
2323

2424
private def parse_options(args)

src/crytic/runner/parallel.cr

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
require "../mutation/result_set"
2-
require "./runner"
32

43
module Crytic::Runner
5-
class Parallel < Runner
6-
private SLICE_SIZE = 2
4+
class Parallel
5+
private SLICE_SIZE = 5
76

87
def run(run, side_effects) : Bool
98
original_result = run.execute_original_test_suite(side_effects)
@@ -28,22 +27,16 @@ module Crytic::Runner
2827
mutation_sets.each_slice(SLICE_SIZE) do |slice|
2928
channel = Channel(Array(Mutation::Result)).new(SLICE_SIZE)
3029

31-
slice.each_with_index do |set, idx|
32-
STDOUT.puts "--- Mutant ##{idx}"
30+
slice.each do |set|
3331
spawn do
34-
STDOUT.puts "Run neutral mutant ##{idx}"
3532
neutral_result = set.run_neutral(run)
36-
STDOUT.puts "Finished neutral mutant ##{idx}"
3733

3834
if neutral_result.errored?
3935
channel.send(discard_further_mutations_for_single_subject)
4036
else
41-
STDOUT.puts "Run mutant ##{idx}"
4237
channel.send(set.run_mutated(run))
43-
STDOUT.puts "Finished mutant ##{idx}"
4438
end
4539
rescue exc
46-
STDOUT.puts exc
4740
run.report_exception(exc)
4841
channel.send(discard_further_mutations_for_single_subject)
4942
end

src/crytic/runner/runner.cr

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/crytic/runner/sequential.cr

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)