active_mutator 0.6.1 → 0.7.0

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.
@@ -7,17 +7,32 @@ module ActiveMutator
7
7
 
8
8
  def self.parse(diff_text)
9
9
  changed = Hash.new { |h, k| h[k] = [] }
10
+ each_hunk(diff_text) do |file, start, count|
11
+ count.times { |i| changed[file] << start + i }
12
+ end
13
+ changed.reject { |_, lines| lines.empty? }
14
+ end
15
+
16
+ # New-side line each pure deletion follows (0 = top of file), per file.
17
+ # The deletion sits between that line and the next, so it is inside a
18
+ # subject only when the subject spans both.
19
+ def self.deletion_gaps(diff_text)
20
+ gaps = Hash.new { |h, k| h[k] = [] }
21
+ each_hunk(diff_text) do |file, start, count|
22
+ gaps[file] << start if count.zero?
23
+ end
24
+ gaps
25
+ end
26
+
27
+ def self.each_hunk(diff_text)
10
28
  current = nil
11
29
  diff_text.each_line do |line|
12
30
  if line.start_with?("+++ b/")
13
31
  current = line.delete_prefix("+++ b/").strip
14
32
  elsif current && (match = HUNK.match(line))
15
- start = match[1].to_i
16
- count = (match[2] || "1").to_i
17
- count.times { |i| changed[current] << start + i }
33
+ yield current, match[1].to_i, (match[2] || "1").to_i
18
34
  end
19
35
  end
20
- changed.reject { |_, lines| lines.empty? }
21
36
  end
22
37
 
23
38
  # Every file the diff touched on the new side, including deletion-only
@@ -66,6 +81,7 @@ module ActiveMutator
66
81
  raise Error, "git diff #{ref} failed" unless $?.success?
67
82
 
68
83
  @changed = self.class.parse(diff)
84
+ @gaps = self.class.deletion_gaps(diff)
69
85
  @touched = self.class.touched_files(diff)
70
86
  untracked = IO.popen(
71
87
  ["git", "-C", root, "ls-files", "--others", "--exclude-standard", "--", "*.rb"], &:read
@@ -91,12 +107,19 @@ module ActiveMutator
91
107
  self.class.same_code?(old_source, File.read(File.join(@root, path)))
92
108
  end
93
109
 
110
+ # Whether the file only lost lines since the ref: touched, but with no
111
+ # added or changed lines (untracked files count as all added).
112
+ def deletion_only?(path) = !@changed.key?(path)
113
+
94
114
  def cover?(subject)
95
- lines = @changed[subject.file.delete_prefix("#{@root}/")]
96
- return false unless lines
115
+ rel = subject.file.delete_prefix("#{@root}/")
116
+ lines = @changed[rel]
97
117
  return true if lines == :all
98
118
 
99
- lines.any? { |line| subject.line_range.cover?(line) }
119
+ range = subject.line_range
120
+ return true if lines&.any? { |line| range.cover?(line) }
121
+
122
+ @gaps.fetch(rel, []).any? { |gap| range.cover?(gap) && range.cover?(gap + 1) }
100
123
  end
101
124
  end
102
125
  end
@@ -1,3 +1,3 @@
1
1
  module ActiveMutator
2
- VERSION = "0.6.1"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -25,6 +25,11 @@ require_relative "active_mutator/operators/negation_removal"
25
25
  require_relative "active_mutator/mutation"
26
26
  require_relative "active_mutator/analysis"
27
27
  require_relative "active_mutator/engine"
28
+ require_relative "active_mutator/abort_flag"
29
+ require_relative "active_mutator/memory_ceiling"
30
+ require_relative "active_mutator/events"
31
+ require_relative "active_mutator/diagnostics/text"
32
+ require_relative "active_mutator/diagnostics/ndjson"
28
33
  require_relative "active_mutator/atomic_file"
29
34
  require_relative "active_mutator/coverage_map"
30
35
  require_relative "active_mutator/baseline"
@@ -32,6 +37,8 @@ require_relative "active_mutator/baseline_delta"
32
37
  require_relative "active_mutator/defined_constants"
33
38
  require_relative "active_mutator/inserter"
34
39
  require_relative "active_mutator/closure_reload"
40
+ require_relative "active_mutator/memory_probe"
41
+ require_relative "active_mutator/sampler"
35
42
  require_relative "active_mutator/worker"
36
43
  require_relative "active_mutator/result"
37
44
  require_relative "active_mutator/work_item"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_mutator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel John
@@ -70,6 +70,7 @@ files:
70
70
  - README.md
71
71
  - exe/active_mutator
72
72
  - lib/active_mutator.rb
73
+ - lib/active_mutator/abort_flag.rb
73
74
  - lib/active_mutator/accepted_ledger.rb
74
75
  - lib/active_mutator/analysis.rb
75
76
  - lib/active_mutator/atomic_file.rb
@@ -83,10 +84,15 @@ files:
83
84
  - lib/active_mutator/config_file.rb
84
85
  - lib/active_mutator/coverage_map.rb
85
86
  - lib/active_mutator/defined_constants.rb
87
+ - lib/active_mutator/diagnostics/ndjson.rb
88
+ - lib/active_mutator/diagnostics/text.rb
86
89
  - lib/active_mutator/edit.rb
87
90
  - lib/active_mutator/engine.rb
91
+ - lib/active_mutator/events.rb
88
92
  - lib/active_mutator/fingerprint.rb
89
93
  - lib/active_mutator/inserter.rb
94
+ - lib/active_mutator/memory_ceiling.rb
95
+ - lib/active_mutator/memory_probe.rb
90
96
  - lib/active_mutator/mutation.rb
91
97
  - lib/active_mutator/operators/base.rb
92
98
  - lib/active_mutator/operators/call_swap.rb
@@ -104,6 +110,7 @@ files:
104
110
  - lib/active_mutator/reporter/terminal.rb
105
111
  - lib/active_mutator/result.rb
106
112
  - lib/active_mutator/runner.rb
113
+ - lib/active_mutator/sampler.rb
107
114
  - lib/active_mutator/scheduler.rb
108
115
  - lib/active_mutator/since_filter.rb
109
116
  - lib/active_mutator/source_location.rb