Skip to content

Commit 92b522e

Browse files
committed
Change incremental to perform an additional AST dirtyness check
* This avoids situations where no semantic change occured to trigger incremental selection.
1 parent 0a7fcc1 commit 92b522e

File tree

11 files changed

+65
-21
lines changed

11 files changed

+65
-21
lines changed

lib/mutant.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ module Mutant
246246
require 'mutant/repository'
247247
require 'mutant/repository/diff'
248248
require 'mutant/repository/diff/ranges'
249+
require 'mutant/repository/file_revision'
249250
require 'mutant/zombifier'
250251
require 'mutant/range'
251252
require 'mutant/license'
@@ -319,6 +320,7 @@ module Mutant
319320
mutex: Mutex,
320321
object_space: ObjectSpace,
321322
open3: Open3,
323+
parser: Parser.new,
322324
pathname: Pathname,
323325
process: Process,
324326
random: Random,

lib/mutant/cli/command/environment.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,13 @@ def add_matcher_options(parser)
102102
parser.on('--start-subject EXPRESSION', 'Start mutation testing at a specific subject') do |pattern|
103103
add_matcher(:start_expressions, @config.expression_parser.call(pattern).from_right)
104104
end
105-
parser.on('--since REVISION', 'Only select subjects touched since REVISION') do |revision|
105+
parser.on('--since REVISION', 'Only select dirty subjects since REVISION') do |revision|
106106
add_matcher(
107107
:subject_filters,
108108
Repository::SubjectFilter.new(
109-
Repository::Diff.new(to: revision, world: world)
109+
diff: Repository::Diff.new(to: revision, world: world),
110+
revision: revision,
111+
world: world
110112
)
111113
)
112114
end

lib/mutant/env.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ class Env
99
:integration,
1010
:matchable_scopes,
1111
:mutations,
12-
:parser,
1312
:selector,
1413
:subjects,
1514
:world
@@ -37,7 +36,6 @@ def self.empty(world, config)
3736
),
3837
matchable_scopes: EMPTY_ARRAY,
3938
mutations: EMPTY_ARRAY,
40-
parser: Parser.new,
4139
selector: Selector::Null.new,
4240
subjects: EMPTY_ARRAY,
4341
world: world
@@ -64,6 +62,13 @@ def cover_index(mutation_index)
6462
)
6563
end
6664

65+
# The parser
66+
#
67+
# @return [Parser]
68+
def parser
69+
world.parser
70+
end
71+
6772
# The test selections
6873
#
6974
# @return Hash{Mutation => Enumerable<Test>}

lib/mutant/repository.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Mutant
44
module Repository
55
# Subject filter based on repository diff
66
class SubjectFilter
7-
include Adamantium, Concord.new(:diff)
7+
include Adamantium, Anima.new(:diff, :revision, :world)
88

99
# Test if subject was touched in diff
1010
#
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
module Mutant
4+
module Repository
5+
class FileRevision
6+
def self.read(world:, revision:, file_name:)
7+
world
8+
.capture_stdout(%w[git show #{revision}:#{file_name}])
9+
end
10+
end # FileRevision
11+
end # Repository
12+
end # Mutant

lib/mutant/world.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class World
1616
:mutex,
1717
:object_space,
1818
:open3,
19+
:parser,
1920
:pathname,
2021
:process,
2122
:random,

spec/spec_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ def fake_world
114114
mutex: class_double(Mutex),
115115
object_space: class_double(ObjectSpace),
116116
open3: class_double(Open3),
117+
parser: class_double(Mutant::Parser),
117118
pathname: class_double(Pathname),
118119
process: class_double(Process),
119120
random: class_double(Random),

spec/unit/mutant/bootstrap_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def require(_); end
5656
kernel: kernel,
5757
load_path: load_path,
5858
object_space: object_space,
59+
parser: Mutant::Parser.new,
5960
pathname: Pathname,
6061
recorder: instance_double(Mutant::Segment::Recorder),
6162
timer: timer

spec/unit/mutant/cli_spec.rb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def self.main_body
301301
Matcher:
302302
--ignore-subject EXPRESSION Ignore subjects that match EXPRESSION as prefix
303303
--start-subject EXPRESSION Start mutation testing at a specific subject
304-
--since REVISION Only select subjects touched since REVISION
304+
--since REVISION Only select dirty subjects since REVISION
305305
MESSAGE
306306

307307
{
@@ -348,7 +348,7 @@ def self.main_body
348348
Matcher:
349349
--ignore-subject EXPRESSION Ignore subjects that match EXPRESSION as prefix
350350
--start-subject EXPRESSION Start mutation testing at a specific subject
351-
--since REVISION Only select subjects touched since REVISION
351+
--since REVISION Only select dirty subjects since REVISION
352352
MESSAGE
353353

354354
{
@@ -395,7 +395,7 @@ def self.main_body
395395
Matcher:
396396
--ignore-subject EXPRESSION Ignore subjects that match EXPRESSION as prefix
397397
--start-subject EXPRESSION Start mutation testing at a specific subject
398-
--since REVISION Only select subjects touched since REVISION
398+
--since REVISION Only select dirty subjects since REVISION
399399
MESSAGE
400400

401401
{
@@ -1290,10 +1290,12 @@ def self.main_body
12901290
matcher: file_config.matcher.with(
12911291
subject_filters: [
12921292
Mutant::Repository::SubjectFilter.new(
1293-
Mutant::Repository::Diff.new(
1293+
diff: Mutant::Repository::Diff.new(
12941294
to: 'reference',
12951295
world: world
1296-
)
1296+
),
1297+
revision: 'reference',
1298+
world: world
12971299
)
12981300
]
12991301
)
@@ -1305,10 +1307,12 @@ def self.main_body
13051307
matcher: file_config.matcher.with(
13061308
subject_filters: [
13071309
Mutant::Repository::SubjectFilter.new(
1308-
Mutant::Repository::Diff.new(
1310+
diff: Mutant::Repository::Diff.new(
13091311
to: 'reference',
13101312
world: world
1311-
)
1313+
),
1314+
revision: 'reference',
1315+
world: world
13121316
)
13131317
]
13141318
)

spec/unit/mutant/env_spec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
integration: integration,
99
matchable_scopes: [],
1010
mutations: [mutation],
11-
parser: Mutant::Parser.new,
1211
selector: selector,
1312
subjects: subjects,
1413
world: world
@@ -239,7 +238,6 @@ def apply
239238
integration: integration,
240239
matchable_scopes: Mutant::EMPTY_ARRAY,
241240
mutations: Mutant::EMPTY_ARRAY,
242-
parser: Mutant::Parser.new,
243241
selector: Mutant::Selector::Null.new,
244242
subjects: Mutant::EMPTY_ARRAY,
245243
world: world
@@ -268,4 +266,10 @@ def apply
268266
expect(events).to eql([%i[test_segment value]])
269267
end
270268
end
269+
270+
describe '#parser' do
271+
it 'returns the world parser' do
272+
expect(subject.parser).to be(world.parser)
273+
end
274+
end
271275
end

0 commit comments

Comments
 (0)