evilution 1.5.0 → 1.6.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.
- checksums.yaml +4 -4
- data/.beads/interactions.jsonl +1 -0
- data/.rubocop_todo.yml +30 -0
- data/CHANGELOG.md +59 -0
- data/README.md +285 -45
- data/docs/architecture.md +110 -12
- data/docs/ast_pattern_syntax.md +35 -7
- data/docs/combined_runs_spike.md +407 -0
- data/docs/integrations.md +1 -1
- data/docs/isolation.md +63 -2
- data/docs/migration-from-mutant.md +16 -11
- data/docs/mutant_schemata_spike.md +387 -0
- data/docs/operator_yield_study.md +576 -0
- data/docs/probe_first_spike.md +264 -0
- data/lib/evilution/ast/ancestor_lookup.rb +36 -0
- data/lib/evilution/ast/callback_declaration.rb +36 -3
- data/lib/evilution/ast/class_body.rb +62 -16
- data/lib/evilution/ast/def_region.rb +130 -0
- data/lib/evilution/ast/local_declaration.rb +37 -0
- data/lib/evilution/ast/parent_index.rb +50 -0
- data/lib/evilution/ast/parse_cache.rb +27 -0
- data/lib/evilution/ast/parser.rb +8 -3
- data/lib/evilution/ast/pattern/filter.rb +53 -12
- data/lib/evilution/ast/skip_filter.rb +83 -0
- data/lib/evilution/ast/skip_sites/debug_output.rb +67 -0
- data/lib/evilution/ast/skip_sites/error_messages.rb +74 -0
- data/lib/evilution/ast/skip_sites/logging.rb +93 -0
- data/lib/evilution/ast/skip_sites/message.rb +44 -0
- data/lib/evilution/ast/skip_sites/nodes.rb +105 -0
- data/lib/evilution/ast/skip_sites/presets.rb +31 -0
- data/lib/evilution/ast/skip_sites/purity.rb +69 -0
- data/lib/evilution/ast/skip_sites/requires.rb +40 -0
- data/lib/evilution/ast/skip_sites.rb +9 -0
- data/lib/evilution/ast/source_surgeon.rb +20 -2
- data/lib/evilution/ast/syntax_check.rb +10 -8
- data/lib/evilution/baseline/report.rb +11 -2
- data/lib/evilution/baseline.rb +31 -6
- data/lib/evilution/cache/keys.rb +140 -0
- data/lib/evilution/cache/run_fingerprint.rb +51 -0
- data/lib/evilution/cache/skeleton.rb +57 -0
- data/lib/evilution/cache/spec_digest.rb +39 -0
- data/lib/evilution/cache.rb +145 -42
- data/lib/evilution/class_tree.rb +38 -0
- data/lib/evilution/cli/command.rb +12 -4
- data/lib/evilution/cli/commands/run.rb +12 -3
- data/lib/evilution/cli/commands/subjects.rb +5 -2
- data/lib/evilution/cli/parser/options_builder.rb +67 -3
- data/lib/evilution/cli/printers/environment.rb +34 -4
- data/lib/evilution/cli/printers/session_detail.rb +20 -3
- data/lib/evilution/compare/categorizer.rb +2 -1
- data/lib/evilution/compare/normalizer.rb +3 -2
- data/lib/evilution/config/sources.rb +3 -0
- data/lib/evilution/config/validators/base.rb +9 -0
- data/lib/evilution/config/validators/since.rb +22 -0
- data/lib/evilution/config/validators/skip_sites.rb +24 -0
- data/lib/evilution/config/validators/timeout_ceiling.rb +10 -0
- data/lib/evilution/config/validators/timeout_factor.rb +10 -0
- data/lib/evilution/config/validators/timeout_floor.rb +10 -0
- data/lib/evilution/config.rb +122 -6
- data/lib/evilution/coverage/load_tracker.rb +50 -0
- data/lib/evilution/coverage/map.rb +42 -5
- data/lib/evilution/coverage/map_builder.rb +123 -22
- data/lib/evilution/coverage/map_store.rb +15 -5
- data/lib/evilution/coverage/recorder.rb +42 -3
- data/lib/evilution/coverage_example_filter.rb +35 -0
- data/lib/evilution/equivalent/heuristic/comment_marking.rb +14 -1
- data/lib/evilution/example_filter.rb +20 -0
- data/lib/evilution/git/changed_lines.rb +103 -0
- data/lib/evilution/git/since_scope.rb +77 -0
- data/lib/evilution/git/unified_diff.rb +68 -0
- data/lib/evilution/infra_crash.rb +26 -0
- data/lib/evilution/integration/base.rb +97 -6
- data/lib/evilution/integration/crash_detector.rb +46 -6
- data/lib/evilution/integration/known_failures.rb +4 -0
- data/lib/evilution/integration/loading/body_call_neutralizer.rb +49 -11
- data/lib/evilution/integration/loading/callback_equivalence.rb +62 -0
- data/lib/evilution/integration/loading/callback_redeclaration.rb +151 -36
- data/lib/evilution/integration/loading/concern_redeclaration.rb +16 -12
- data/lib/evilution/integration/loading/concern_registry.rb +87 -0
- data/lib/evilution/integration/loading/concern_state_cleaner.rb +19 -8
- data/lib/evilution/integration/loading/created_modules.rb +56 -0
- data/lib/evilution/integration/loading/frozen_namespaces.rb +80 -0
- data/lib/evilution/integration/loading/mutation_applier.rb +42 -11
- data/lib/evilution/integration/loading/neutralization.rb +41 -0
- data/lib/evilution/integration/loading/redefinition_recovery.rb +5 -3
- data/lib/evilution/integration/loading/superseded_modules.rb +22 -19
- data/lib/evilution/integration/minitest/stop_hook.rb +57 -0
- data/lib/evilution/integration/minitest.rb +22 -2
- data/lib/evilution/integration/minitest_crash_detector.rb +19 -0
- data/lib/evilution/integration/rspec/baseline_runner.rb +3 -2
- data/lib/evilution/integration/rspec/crash_detector_lifecycle.rb +6 -1
- data/lib/evilution/integration/rspec/example_filter_applier.rb +16 -0
- data/lib/evilution/integration/rspec/example_ids.rb +23 -0
- data/lib/evilution/integration/rspec/example_order.rb +86 -0
- data/lib/evilution/integration/rspec/killer_first.rb +72 -0
- data/lib/evilution/integration/rspec/result_builder.rb +7 -0
- data/lib/evilution/integration/rspec/state_guard/example_group_descendants.rb +44 -0
- data/lib/evilution/integration/rspec/state_guard.rb +2 -2
- data/lib/evilution/integration/rspec/target_resolver.rb +42 -0
- data/lib/evilution/integration/rspec/test_file_resolver.rb +4 -2
- data/lib/evilution/integration/rspec.rb +98 -47
- data/lib/evilution/integration/stop_policy.rb +49 -0
- data/lib/evilution/integration/test_unit/dispatcher.rb +20 -1
- data/lib/evilution/integration/test_unit/subject_class_registry.rb +6 -1
- data/lib/evilution/integration/test_unit.rb +28 -2
- data/lib/evilution/isolation/fork.rb +58 -13
- data/lib/evilution/isolation/in_process.rb +12 -1
- data/lib/evilution/line_set.rb +72 -0
- data/lib/evilution/mcp/info_tool/actions/environment.rb +12 -16
- data/lib/evilution/mcp/info_tool/actions/subjects.rb +3 -5
- data/lib/evilution/mcp/info_tool/status_glossary.rb +15 -2
- data/lib/evilution/mcp/info_tool.rb +24 -17
- data/lib/evilution/mcp/mutate_tool/config_builder.rb +13 -1
- data/lib/evilution/mcp/mutate_tool/option_parser.rb +2 -2
- data/lib/evilution/mcp/mutate_tool/progress_streamer.rb +1 -1
- data/lib/evilution/mcp/mutate_tool/report_trimmer.rb +28 -5
- data/lib/evilution/mcp/mutate_tool/survived_enricher.rb +12 -7
- data/lib/evilution/mcp/mutate_tool.rb +32 -7
- data/lib/evilution/mcp/session_tool.rb +1 -2
- data/lib/evilution/mcp.rb +4 -0
- data/lib/evilution/mutation/line_diff.rb +111 -0
- data/lib/evilution/mutation.rb +17 -13
- data/lib/evilution/mutator/base.rb +121 -98
- data/lib/evilution/mutator/constant_value_subjects.rb +29 -1
- data/lib/evilution/mutator/line_range_filter.rb +27 -0
- data/lib/evilution/mutator/load_sources.rb +88 -0
- data/lib/evilution/mutator/operator/alias_removal.rb +2 -5
- data/lib/evilution/mutator/operator/argument_method_call_replacement.rb +3 -0
- data/lib/evilution/mutator/operator/attr_accessor_swap.rb +2 -5
- data/lib/evilution/mutator/operator/constant_namespace_strip.rb +3 -3
- data/lib/evilution/mutator/operator/freeze_removal.rb +29 -11
- data/lib/evilution/mutator/operator/method_call_removal.rb +3 -1
- data/lib/evilution/mutator/operator/mixin_removal.rb +2 -5
- data/lib/evilution/mutator/operator/superclass_removal.rb +2 -5
- data/lib/evilution/mutator/operator/symbol_literal.rb +1 -1
- data/lib/evilution/mutator/operator/visibility_removal.rb +2 -5
- data/lib/evilution/mutator/registry.rb +11 -5
- data/lib/evilution/mutator/restore_source_cache.rb +41 -0
- data/lib/evilution/parallel/pool.rb +11 -4
- data/lib/evilution/parallel/work_queue/dispatcher/result_stream.rb +40 -0
- data/lib/evilution/parallel/work_queue/dispatcher.rb +20 -7
- data/lib/evilution/parallel/work_queue/worker/loop.rb +7 -2
- data/lib/evilution/parallel/work_queue/worker.rb +10 -3
- data/lib/evilution/parallel/work_queue/worker_stat.rb +7 -0
- data/lib/evilution/parallel/work_queue.rb +69 -12
- data/lib/evilution/parallel_db_warning.rb +39 -12
- data/lib/evilution/process_supervisor.rb +22 -2
- data/lib/evilution/reporter/cli/item_formatters/coverage_gap.rb +13 -2
- data/lib/evilution/reporter/cli/item_formatters/subject_score.rb +5 -1
- data/lib/evilution/reporter/cli/line_formatters/mutations.rb +9 -2
- data/lib/evilution/reporter/cli/line_formatters/result_line.rb +9 -1
- data/lib/evilution/reporter/cli/line_formatters/skipped_sites.rb +14 -0
- data/lib/evilution/reporter/cli/line_formatters/uncovered_code.rb +17 -0
- data/lib/evilution/reporter/cli/metrics_block.rb +4 -0
- data/lib/evilution/reporter/cli/trailer.rb +4 -4
- data/lib/evilution/reporter/cli.rb +9 -2
- data/lib/evilution/reporter/html/assets/style.css +8 -0
- data/lib/evilution/reporter/html/sections/file_section.rb +9 -0
- data/lib/evilution/reporter/html/sections/uncovered_details.rb +27 -0
- data/lib/evilution/reporter/html/templates/file_section.html.erb +2 -1
- data/lib/evilution/reporter/html/templates/summary_cards.html.erb +3 -0
- data/lib/evilution/reporter/html/templates/uncovered_details.html.erb +11 -0
- data/lib/evilution/reporter/json/mutation_detail.rb +77 -0
- data/lib/evilution/reporter/json/subjects.rb +1 -0
- data/lib/evilution/reporter/json/timings.rb +42 -0
- data/lib/evilution/reporter/json.rb +13 -50
- data/lib/evilution/result/coverage_gap.rb +5 -0
- data/lib/evilution/result/mutation_result.rb +55 -3
- data/lib/evilution/result/mutation_timings.rb +54 -0
- data/lib/evilution/result/run_timings.rb +20 -0
- data/lib/evilution/result/subject_score.rb +8 -1
- data/lib/evilution/result/subject_scorer.rb +5 -3
- data/lib/evilution/result/summary.rb +49 -12
- data/lib/evilution/runner/baseline_runner.rb +47 -5
- data/lib/evilution/runner/diagnostics.rb +0 -13
- data/lib/evilution/runner/isolation_resolver.rb +16 -4
- data/lib/evilution/runner/mutation_executor/isolated_run.rb +34 -0
- data/lib/evilution/runner/mutation_executor/kill_history.rb +66 -0
- data/lib/evilution/runner/mutation_executor/mutation_runner.rb +31 -12
- data/lib/evilution/runner/mutation_executor/neutralizer/baseline_failed.rb +1 -0
- data/lib/evilution/runner/mutation_executor/neutralizer/infra_error.rb +6 -20
- data/lib/evilution/runner/mutation_executor/probe_first.rb +99 -0
- data/lib/evilution/runner/mutation_executor/probe_first_run.rb +59 -0
- data/lib/evilution/runner/mutation_executor/result_cache.rb +45 -14
- data/lib/evilution/runner/mutation_executor/result_notifier.rb +1 -1
- data/lib/evilution/runner/mutation_executor/result_packer.rb +54 -24
- data/lib/evilution/runner/mutation_executor/runless_verdict.rb +39 -0
- data/lib/evilution/runner/mutation_executor/strategy/parallel/hinted_items.rb +27 -0
- data/lib/evilution/runner/mutation_executor/strategy/parallel/ordered_delivery.rb +97 -0
- data/lib/evilution/runner/mutation_executor/strategy/parallel.rb +102 -83
- data/lib/evilution/runner/mutation_executor/timed_run.rb +33 -0
- data/lib/evilution/runner/mutation_executor/timeout_policy/adaptive.rb +67 -0
- data/lib/evilution/runner/mutation_executor/timeout_policy/base.rb +35 -0
- data/lib/evilution/runner/mutation_executor/timeout_policy/fixed.rb +17 -0
- data/lib/evilution/runner/mutation_executor/timeout_policy.rb +56 -0
- data/lib/evilution/runner/mutation_executor.rb +75 -10
- data/lib/evilution/runner/mutation_planner.rb +29 -21
- data/lib/evilution/runner/phase_clock.rb +22 -0
- data/lib/evilution/runner/report_publisher.rb +1 -1
- data/lib/evilution/runner/subject_pipeline.rb +18 -8
- data/lib/evilution/runner.rb +87 -26
- data/lib/evilution/session/diff.rb +9 -2
- data/lib/evilution/session/store.rb +17 -2
- data/lib/evilution/source_ast_cache.rb +10 -0
- data/lib/evilution/spec_ast_cache.rb +15 -0
- data/lib/evilution/spec_resolver/constant_references.rb +66 -0
- data/lib/evilution/spec_resolver/project_files.rb +50 -0
- data/lib/evilution/spec_resolver/sibling_spec_ranker.rb +111 -0
- data/lib/evilution/spec_resolver/spec_pattern.rb +19 -0
- data/lib/evilution/spec_resolver.rb +76 -65
- data/lib/evilution/spec_selector.rb +17 -13
- data/lib/evilution/subject.rb +7 -2
- data/lib/evilution/version.rb +1 -1
- data/lib/evilution/worker_database/copies.rb +73 -0
- data/lib/evilution/worker_database/schema.rb +39 -0
- data/lib/evilution/worker_database/sqlite_copy.rb +65 -0
- data/lib/evilution/worker_database.rb +214 -0
- data/schema/evilution.config.schema.json +74 -2
- metadata +84 -13
- data/lib/evilution/integration/rspec/state_guard/object_space_example_groups.rb +0 -42
- data/scripts/benchmark_density +0 -262
- data/scripts/benchmark_density.yml +0 -19
- data/scripts/canary_manifest.yml +0 -47
- data/scripts/compare_mutations +0 -421
- data/scripts/compare_mutations.yml +0 -24
- data/scripts/compare_targeting +0 -279
- data/scripts/compare_targeting.example.yml +0 -24
- data/scripts/mutant_json_adapter +0 -227
|
@@ -197,12 +197,18 @@ class Evilution::Mutator::Registry
|
|
|
197
197
|
self
|
|
198
198
|
end
|
|
199
199
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
200
|
+
# file_sources: the run's file sources by path, which a caller mutating
|
|
201
|
+
# several subjects of a file hands over so the file is read once (a Hash
|
|
202
|
+
# that reads a path on first lookup); without it the subject's file is
|
|
203
|
+
# read here, once for all the operators.
|
|
204
|
+
def mutations_for(subject, filter: nil, operator_options: {}, file_sources: nil)
|
|
205
|
+
operators = @operators.select { |operator_class| operator_class.subject_kinds.include?(subject.kind) }
|
|
206
|
+
return [] if operators.empty?
|
|
203
207
|
|
|
204
|
-
|
|
205
|
-
|
|
208
|
+
path = subject.file_path
|
|
209
|
+
file_source = file_sources ? file_sources[path] : File.read(path)
|
|
210
|
+
operators.flat_map do |operator_class|
|
|
211
|
+
build_operator(operator_class, operator_options).call(subject, filter: filter, file_source: file_source)
|
|
206
212
|
end
|
|
207
213
|
end
|
|
208
214
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../mutator"
|
|
4
|
+
|
|
5
|
+
# A file's neutralization, built once for all the mutations of the file: its
|
|
6
|
+
# source is the restore source of every subject with no declaration of its
|
|
7
|
+
# own to keep, and its edits let a mutation be carried into it (see
|
|
8
|
+
# Integration::Loading::Neutralization). A file is neutralized again when
|
|
9
|
+
# its source differs from the cached one; the very source object it was
|
|
10
|
+
# built from is recognised without hashing it again.
|
|
11
|
+
module Evilution::Mutator::RestoreSourceCache
|
|
12
|
+
Entry = Data.define(:file_source, :source_hash, :neutralization)
|
|
13
|
+
private_constant :Entry
|
|
14
|
+
|
|
15
|
+
@entries = {}
|
|
16
|
+
|
|
17
|
+
def self.source_for(file_path, file_source, neutralizer)
|
|
18
|
+
neutralization_for(file_path, file_source, neutralizer).source
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.neutralization_for(file_path, file_source, neutralizer)
|
|
22
|
+
entry = @entries[file_path]
|
|
23
|
+
return entry.neutralization if entry && current?(entry, file_source)
|
|
24
|
+
|
|
25
|
+
neutralization = neutralizer.neutralization(file_source, file_path: file_path)
|
|
26
|
+
neutralization.source.freeze
|
|
27
|
+
@entries[file_path] = Entry.new(file_source: file_source, source_hash: file_source.hash,
|
|
28
|
+
neutralization: neutralization)
|
|
29
|
+
neutralization
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.current?(entry, file_source)
|
|
33
|
+
entry.file_source.equal?(file_source) || entry.source_hash == file_source.hash
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def self.clear!
|
|
37
|
+
@entries = {}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
private_class_method :current?
|
|
41
|
+
end
|
|
@@ -4,12 +4,19 @@ require_relative "../parallel"
|
|
|
4
4
|
require_relative "work_queue"
|
|
5
5
|
|
|
6
6
|
class Evilution::Parallel::Pool
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
# `worker_max_items` is how many items a worker runs before it is replaced by
|
|
8
|
+
# a fresh one; nil keeps every worker for the whole run.
|
|
9
|
+
# `copy_worker_databases` gives each worker its own copy of the preloaded
|
|
10
|
+
# SQLite test database (see WorkQueue).
|
|
11
|
+
def initialize(size:, hooks: nil, item_timeout: nil, worker_max_items: nil, copy_worker_databases: false)
|
|
12
|
+
@queue = Evilution::Parallel::WorkQueue.new(
|
|
13
|
+
size: size, hooks: hooks, item_timeout: item_timeout, worker_max_items: worker_max_items,
|
|
14
|
+
copy_worker_databases: copy_worker_databases
|
|
15
|
+
)
|
|
9
16
|
end
|
|
10
17
|
|
|
11
|
-
def map(items, &)
|
|
12
|
-
@queue.map(items, &)
|
|
18
|
+
def map(items, on_result: nil, on_arrival: nil, &)
|
|
19
|
+
@queue.map(items, on_result: on_result, on_arrival: on_arrival, &)
|
|
13
20
|
end
|
|
14
21
|
|
|
15
22
|
def worker_stats
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../dispatcher"
|
|
4
|
+
|
|
5
|
+
# Hands the Dispatcher's caller each finished item, (index, value), in the
|
|
6
|
+
# order the items finish, and keeps the caller's answer: :stop means no further
|
|
7
|
+
# item is to be sent. The Dispatcher pushes as results come in and flushes
|
|
8
|
+
# once the round's workers have their next item, so the caller's handling never
|
|
9
|
+
# holds a worker idle.
|
|
10
|
+
#
|
|
11
|
+
# A caller that needs a result before the next item goes out -- to build that
|
|
12
|
+
# item from it -- is handed it on arrival as well, as soon as it is pushed.
|
|
13
|
+
class Evilution::Parallel::WorkQueue::Dispatcher::ResultStream
|
|
14
|
+
# Stands in for a caller that takes the results at the end of the run only.
|
|
15
|
+
IGNORE = ->(_index, _value) {}
|
|
16
|
+
private_constant :IGNORE
|
|
17
|
+
|
|
18
|
+
def initialize(on_result, on_arrival = nil)
|
|
19
|
+
@on_result = on_result || IGNORE
|
|
20
|
+
@on_arrival = on_arrival || IGNORE
|
|
21
|
+
@finished = []
|
|
22
|
+
@stopped = false
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def push(index, value)
|
|
26
|
+
@on_arrival.call(index, value)
|
|
27
|
+
@finished << [index, value]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def flush
|
|
31
|
+
until @finished.empty?
|
|
32
|
+
index, value = @finished.shift
|
|
33
|
+
@stopped = true if @on_result.call(index, value) == :stop
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def stopped?
|
|
38
|
+
@stopped
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -8,7 +8,10 @@ class Evilution::Parallel::WorkQueue::Dispatcher
|
|
|
8
8
|
|
|
9
9
|
attr_reader :first_error
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
# on_arrival: told of each finished item as soon as it is read, ahead of
|
|
12
|
+
# on_result, which waits until the round's workers have their next item.
|
|
13
|
+
def initialize(workers:, items:, prefetch:, item_timeout:, worker_max_items:, recycle_factory:,
|
|
14
|
+
on_result: nil, on_arrival: nil)
|
|
12
15
|
@workers = workers
|
|
13
16
|
@items = items
|
|
14
17
|
@prefetch = prefetch
|
|
@@ -17,6 +20,7 @@ class Evilution::Parallel::WorkQueue::Dispatcher
|
|
|
17
20
|
@state = Evilution::Parallel::WorkQueue.send(:const_get, :CollectionState).new(items.length)
|
|
18
21
|
@retired = []
|
|
19
22
|
@deadlines = DeadlineTracker.new(item_timeout:, workers: @workers)
|
|
23
|
+
@stream = ResultStream.new(on_result, on_arrival)
|
|
20
24
|
end
|
|
21
25
|
|
|
22
26
|
def run
|
|
@@ -43,6 +47,10 @@ class Evilution::Parallel::WorkQueue::Dispatcher
|
|
|
43
47
|
# so a single stuck worker is reaped in isolation -- its in-flight item gets
|
|
44
48
|
# the WorkQueue::TIMED_OUT sentinel and the worker is recycled -- instead of
|
|
45
49
|
# the old pool-wide watchdog that SIGKILLed every worker and aborted the run.
|
|
50
|
+
#
|
|
51
|
+
# Finished items are handed to on_result only after the round's workers have
|
|
52
|
+
# been given their next item, so the caller's handling never holds a worker
|
|
53
|
+
# idle.
|
|
46
54
|
def collect
|
|
47
55
|
io_to_worker = @workers.to_h { |w| [w.res_io, w] }
|
|
48
56
|
result_ios = io_to_worker.keys
|
|
@@ -50,14 +58,18 @@ class Evilution::Parallel::WorkQueue::Dispatcher
|
|
|
50
58
|
while @state.in_flight.positive?
|
|
51
59
|
readable, = IO.select(result_ios, nil, nil, @deadlines.select_timeout)
|
|
52
60
|
reap_timed_out(io_to_worker, result_ios)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
readable.each do |io|
|
|
61
|
+
Array(readable).each do |io|
|
|
56
62
|
process_readable(io, io_to_worker, result_ios) if result_ios.include?(io)
|
|
57
63
|
end
|
|
64
|
+
@stream.flush
|
|
58
65
|
end
|
|
59
66
|
end
|
|
60
67
|
|
|
68
|
+
def finish(index, value)
|
|
69
|
+
@state.results[index] = value
|
|
70
|
+
@stream.push(index, value)
|
|
71
|
+
end
|
|
72
|
+
|
|
61
73
|
def reap_timed_out(io_to_worker, result_ios)
|
|
62
74
|
@deadlines.overdue.each { |worker| time_out_worker(worker, io_to_worker, result_ios) }
|
|
63
75
|
end
|
|
@@ -89,7 +101,7 @@ class Evilution::Parallel::WorkQueue::Dispatcher
|
|
|
89
101
|
def record(message, worker)
|
|
90
102
|
index, status, value = message
|
|
91
103
|
@state.first_error = value if status == :error && @state.first_error.nil?
|
|
92
|
-
|
|
104
|
+
finish(index, value) if status == :ok
|
|
93
105
|
@state.in_flight -= 1
|
|
94
106
|
worker.pending -= 1
|
|
95
107
|
worker.items_completed += 1
|
|
@@ -117,7 +129,7 @@ class Evilution::Parallel::WorkQueue::Dispatcher
|
|
|
117
129
|
end
|
|
118
130
|
|
|
119
131
|
def mark_unfinished(worker, sentinel)
|
|
120
|
-
worker.in_flight_indices.each { |index|
|
|
132
|
+
worker.in_flight_indices.each { |index| finish(index, sentinel) }
|
|
121
133
|
@state.in_flight -= worker.pending
|
|
122
134
|
worker.pending = 0
|
|
123
135
|
worker.in_flight_indices.clear
|
|
@@ -190,9 +202,10 @@ class Evilution::Parallel::WorkQueue::Dispatcher
|
|
|
190
202
|
end
|
|
191
203
|
|
|
192
204
|
def more_to_send?
|
|
193
|
-
@state.next_index < @items.length
|
|
205
|
+
!@stream.stopped? && @state.next_index < @items.length
|
|
194
206
|
end
|
|
195
207
|
end
|
|
196
208
|
|
|
197
209
|
require_relative "dispatcher/deadline_tracker"
|
|
198
210
|
require_relative "dispatcher/reply"
|
|
211
|
+
require_relative "dispatcher/result_stream"
|
|
@@ -34,11 +34,16 @@ module Evilution::Parallel::WorkQueue::Worker::Loop
|
|
|
34
34
|
exit!
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
+
# The block gets the item and how long it waited between the dispatcher
|
|
38
|
+
# sending it and this worker starting it (nil when the command carries no
|
|
39
|
+
# send time). CLOCK_MONOTONIC is system-wide, so the parent's stamp and this
|
|
40
|
+
# reading are on the same clock.
|
|
37
41
|
def run_one(res_io, data, &block)
|
|
38
|
-
index, item = data
|
|
42
|
+
index, item, sent_at = data
|
|
39
43
|
t0 = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
44
|
+
waited = sent_at.is_a?(Numeric) ? t0 - sent_at : nil
|
|
40
45
|
begin
|
|
41
|
-
result = block.call(item)
|
|
46
|
+
result = block.call(item, waited)
|
|
42
47
|
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - t0
|
|
43
48
|
Evilution::Parallel::WorkQueue::Channel.write(res_io, [index, :ok, result])
|
|
44
49
|
rescue StandardError, ScriptError, SystemStackError, NoMemoryError, SecurityError => e
|
|
@@ -4,6 +4,7 @@ require_relative "../work_queue"
|
|
|
4
4
|
require_relative "../../child_output"
|
|
5
5
|
require_relative "../../process_supervisor"
|
|
6
6
|
require_relative "../../temp_dir_tracker"
|
|
7
|
+
require_relative "../../worker_database"
|
|
7
8
|
require_relative "channel"
|
|
8
9
|
require_relative "channel/frame"
|
|
9
10
|
|
|
@@ -21,7 +22,8 @@ class Evilution::Parallel::WorkQueue::Worker
|
|
|
21
22
|
# missing from the registry). EV-cnx8 group-leadership (so #kill sweeps the
|
|
22
23
|
# whole subtree) is still established, now by the supervisor's parent-side
|
|
23
24
|
# setpgid.
|
|
24
|
-
def self.spawn(worker_index:, hooks:,
|
|
25
|
+
def self.spawn(worker_index:, hooks:, copies: Evilution::WorkerDatabase::Copies::NONE,
|
|
26
|
+
supervisor: Evilution::ProcessSupervisor.new, &block)
|
|
25
27
|
cmd_read, cmd_write = IO.pipe
|
|
26
28
|
res_read, res_write = IO.pipe
|
|
27
29
|
[cmd_read, cmd_write, res_read, res_write].each(&:binmode)
|
|
@@ -31,6 +33,7 @@ class Evilution::Parallel::WorkQueue::Worker
|
|
|
31
33
|
res_read.close
|
|
32
34
|
install_child_signal_handlers
|
|
33
35
|
ENV["TEST_ENV_NUMBER"] = test_env_number_for(worker_index)
|
|
36
|
+
Evilution::WorkerDatabase.reconnect(copies: copies)
|
|
34
37
|
Evilution::ChildOutput.redirect!
|
|
35
38
|
Loop.run(cmd_read, res_write, hooks: hooks, &block)
|
|
36
39
|
end
|
|
@@ -61,7 +64,10 @@ class Evilution::Parallel::WorkQueue::Worker
|
|
|
61
64
|
# EV-kdns / GH #817: translate 0-based worker slot to parallel_tests'
|
|
62
65
|
# TEST_ENV_NUMBER convention ("" for slot 0, "2" for slot 1, ...). Rails
|
|
63
66
|
# apps interpolating TEST_ENV_NUMBER into database.yml get per-worker
|
|
64
|
-
# SQLite files, avoiding lock contention under jobs > 1.
|
|
67
|
+
# SQLite files, avoiding lock contention under jobs > 1. The app may already
|
|
68
|
+
# be booted by a preload, so spawn re-resolves the ActiveRecord connection
|
|
69
|
+
# after setting it, and with copies moves a worker still on the preloaded
|
|
70
|
+
# SQLite database to a copy of its own (WorkerDatabase).
|
|
65
71
|
def self.test_env_number_for(worker_index)
|
|
66
72
|
worker_index.zero? ? "" : (worker_index + 1).to_s
|
|
67
73
|
end
|
|
@@ -86,7 +92,8 @@ class Evilution::Parallel::WorkQueue::Worker
|
|
|
86
92
|
end
|
|
87
93
|
|
|
88
94
|
def send_item(index, item)
|
|
89
|
-
|
|
95
|
+
sent_at = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
96
|
+
Evilution::Parallel::WorkQueue::Channel.write(@cmd_write, [index, item, sent_at])
|
|
90
97
|
@pending += 1
|
|
91
98
|
@in_flight_indices << index
|
|
92
99
|
end
|
|
@@ -4,6 +4,13 @@ require_relative "../work_queue"
|
|
|
4
4
|
|
|
5
5
|
class Evilution::Parallel::WorkQueue
|
|
6
6
|
WorkerStat = Struct.new(:pid, :items_completed, :busy_time, :wall_time) do
|
|
7
|
+
# One stat per worker process, summed over every pool.map it served.
|
|
8
|
+
def self.aggregate(stats)
|
|
9
|
+
stats.group_by(&:pid).map do |pid, entries|
|
|
10
|
+
new(pid, entries.sum(&:items_completed), entries.sum(&:busy_time), entries.sum(&:wall_time))
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
7
14
|
def idle_time
|
|
8
15
|
wall_time - busy_time
|
|
9
16
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../parallel"
|
|
4
|
+
require_relative "../worker_database"
|
|
4
5
|
|
|
5
6
|
class Evilution::Parallel::WorkQueue
|
|
6
7
|
SHUTDOWN = :__shutdown__
|
|
@@ -18,7 +19,10 @@ class Evilution::Parallel::WorkQueue
|
|
|
18
19
|
DIED = Unfinished.new(reason: :died)
|
|
19
20
|
UNREADABLE = Unfinished.new(reason: :unreadable)
|
|
20
21
|
|
|
21
|
-
|
|
22
|
+
# `copy_worker_databases` gives each worker that would share the preloaded
|
|
23
|
+
# SQLite test database a copy of its own (WorkerDatabase::Copies).
|
|
24
|
+
def initialize(size:, hooks: nil, prefetch: 1, item_timeout: nil, worker_max_items: nil,
|
|
25
|
+
copy_worker_databases: false)
|
|
22
26
|
Validators::PositiveInt.call!(:size, size)
|
|
23
27
|
Validators::PositiveInt.call!(:prefetch, prefetch)
|
|
24
28
|
Validators::OptionalPositiveNumber.call!(:item_timeout, item_timeout)
|
|
@@ -29,18 +33,49 @@ class Evilution::Parallel::WorkQueue
|
|
|
29
33
|
@prefetch = prefetch
|
|
30
34
|
@item_timeout = item_timeout
|
|
31
35
|
@worker_max_items = worker_max_items
|
|
36
|
+
@copy_worker_databases = copy_worker_databases
|
|
32
37
|
@worker_stats = []
|
|
33
38
|
end
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
# Runs the block on every item in the worker processes, which live for the
|
|
41
|
+
# whole call: each takes the next item as soon as it is done with the last.
|
|
42
|
+
# The block gets the item and the seconds it waited between being sent to a
|
|
43
|
+
# worker and that worker starting it.
|
|
44
|
+
#
|
|
45
|
+
# `on_result`, when given, is called in this process with (index, value) as
|
|
46
|
+
# each item finishes, in the order they finish; value is an Unfinished
|
|
47
|
+
# sentinel for an item whose worker gave none. When it answers :stop no
|
|
48
|
+
# further item is sent: the ones in flight finish, the workers shut down,
|
|
49
|
+
# and the slots of the items never sent stay nil.
|
|
50
|
+
#
|
|
51
|
+
# `on_arrival`, when given, is called with the same (index, value) the
|
|
52
|
+
# moment the result is read, before its worker is sent the next item, which
|
|
53
|
+
# can then be built from it (items need only answer #length, #empty? and
|
|
54
|
+
# #[]). It should be quick: the worker waits for it.
|
|
55
|
+
def map(items, on_result: nil, on_arrival: nil, &)
|
|
36
56
|
return [] if items.empty?
|
|
37
57
|
|
|
38
|
-
|
|
39
|
-
|
|
58
|
+
copies = database_copies
|
|
59
|
+
begin
|
|
60
|
+
run_workers(items, copies, on_result, on_arrival, &)
|
|
61
|
+
ensure
|
|
62
|
+
copies.remove
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def worker_stats
|
|
67
|
+
@worker_stats.map { |stat| stat.dup.freeze }
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
private
|
|
71
|
+
|
|
72
|
+
def run_workers(items, copies, on_result, on_arrival, &block)
|
|
73
|
+
workers = (0...[@size, items.length].min).map { |i| spawn_one(i, copies, &block) }
|
|
74
|
+
dispatcher = build_dispatcher(workers, items, copies, on_result, on_arrival, &block)
|
|
40
75
|
|
|
41
76
|
retired = []
|
|
42
77
|
begin
|
|
43
|
-
run_result = dispatcher
|
|
78
|
+
run_result = run_dispatcher(dispatcher, workers)
|
|
44
79
|
retired = run_result.retired
|
|
45
80
|
raise dispatcher.first_error if dispatcher.first_error
|
|
46
81
|
|
|
@@ -50,21 +85,43 @@ class Evilution::Parallel::WorkQueue
|
|
|
50
85
|
end
|
|
51
86
|
end
|
|
52
87
|
|
|
53
|
-
|
|
54
|
-
|
|
88
|
+
# One directory per pass, removed once its workers are gone.
|
|
89
|
+
def database_copies
|
|
90
|
+
@copy_worker_databases ? Evilution::WorkerDatabase::Copies.new : Evilution::WorkerDatabase::Copies::NONE
|
|
55
91
|
end
|
|
56
92
|
|
|
57
|
-
|
|
93
|
+
def spawn_one(worker_index, copies, &)
|
|
94
|
+
Worker.spawn(worker_index: worker_index, hooks: @hooks, copies: copies, &)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# A worker's own failure comes back as first_error, not as a raise. When the
|
|
98
|
+
# dispatcher itself raises (on_result failing, an interrupt, a worker that
|
|
99
|
+
# could not be spawned), no one will take the results of the items in
|
|
100
|
+
# flight, so the workers are killed rather than shut down: a shutdown would
|
|
101
|
+
# wait for each to finish what it holds, up to the item timeout.
|
|
102
|
+
def run_dispatcher(dispatcher, workers)
|
|
103
|
+
dispatcher.run
|
|
104
|
+
rescue Exception # rubocop:disable Lint/RescueException
|
|
105
|
+
workers.each(&:kill)
|
|
106
|
+
raise
|
|
107
|
+
end
|
|
58
108
|
|
|
59
|
-
|
|
60
|
-
|
|
109
|
+
# The dispatcher retires (and reaps) a worker before asking for its
|
|
110
|
+
# replacement, so the old worker's copies can go first: however often
|
|
111
|
+
# workers are replaced, each slot holds one worker's copies at a time. A
|
|
112
|
+
# slot dropped without a replacement keeps its copies until the pass ends,
|
|
113
|
+
# which never puts more on disk than one per slot.
|
|
114
|
+
def replace(old, copies, &)
|
|
115
|
+
copies.discard(old.pid)
|
|
116
|
+
spawn_one(old.worker_index, copies, &)
|
|
61
117
|
end
|
|
62
118
|
|
|
63
|
-
def build_dispatcher(workers, items, &block)
|
|
119
|
+
def build_dispatcher(workers, items, copies, on_result, on_arrival, &block)
|
|
64
120
|
Dispatcher.new(
|
|
65
121
|
workers: workers, items: items, prefetch: @prefetch,
|
|
66
122
|
item_timeout: @item_timeout, worker_max_items: @worker_max_items,
|
|
67
|
-
recycle_factory: ->(old) {
|
|
123
|
+
recycle_factory: ->(old) { replace(old, copies, &block) },
|
|
124
|
+
on_result: on_result, on_arrival: on_arrival
|
|
68
125
|
)
|
|
69
126
|
end
|
|
70
127
|
|
|
@@ -6,7 +6,8 @@ require_relative "version"
|
|
|
6
6
|
|
|
7
7
|
# EV-kdns / GH #817: nudge users running parallel jobs against SQLite to adopt
|
|
8
8
|
# the parallel_tests convention. WorkQueue sets TEST_ENV_NUMBER per worker, but
|
|
9
|
-
# that only helps if config/database.yml interpolates it into the database path
|
|
9
|
+
# that only helps if config/database.yml interpolates it into the database path,
|
|
10
|
+
# so the warning fires only when the test database path does not depend on it.
|
|
10
11
|
# Without per-worker DB files, concurrent workers pile up on one SQLite file and
|
|
11
12
|
# surface ActiveRecord::StatementTimeout / SQLite3::BusyException — noise that
|
|
12
13
|
# MutationExecutor demotes to :neutral but still wastes wall-clock time.
|
|
@@ -15,6 +16,9 @@ module Evilution::ParallelDbWarning
|
|
|
15
16
|
MESSAGE = "[evilution] Parallel run (jobs > 1) detected with SQLite in " \
|
|
16
17
|
"config/database.yml. Interpolate ENV['TEST_ENV_NUMBER'] into the " \
|
|
17
18
|
"test database path for per-worker DB isolation. See README."
|
|
19
|
+
# ":memory:", a "file::memory:" URI or a "file:" URI with mode=memory: each
|
|
20
|
+
# process gets its own database, so workers never share one.
|
|
21
|
+
IN_MEMORY = /\A(?::memory:|file::memory:|file:[^?]*\?(?:[^#]*&)?mode=memory(?:[&#]|\z))/
|
|
18
22
|
|
|
19
23
|
@warned_roots = {}
|
|
20
24
|
@mutex = Mutex.new
|
|
@@ -22,7 +26,7 @@ module Evilution::ParallelDbWarning
|
|
|
22
26
|
class << self
|
|
23
27
|
def warn_if_sqlite_parallel(config, output: $stderr, root: Dir.pwd)
|
|
24
28
|
return unless config.jobs > 1
|
|
25
|
-
return unless
|
|
29
|
+
return unless shared_sqlite_test_database?(root)
|
|
26
30
|
|
|
27
31
|
@mutex.synchronize do
|
|
28
32
|
return if @warned_roots[root]
|
|
@@ -41,28 +45,51 @@ module Evilution::ParallelDbWarning
|
|
|
41
45
|
|
|
42
46
|
# Only the `test` section matters for parallel mutation runs. Scanning the
|
|
43
47
|
# whole file would false-positive when dev/prod use SQLite but test uses
|
|
44
|
-
# Postgres/MySQL.
|
|
45
|
-
#
|
|
46
|
-
|
|
48
|
+
# Postgres/MySQL. The file is rendered for two workers; if the test database
|
|
49
|
+
# comes out the same, every worker shares one database file. An in-memory
|
|
50
|
+
# database is never shared. Parse failures (ERB errors, custom helpers,
|
|
51
|
+
# anchor gymnastics) fall back to "no warning" rather than guessing.
|
|
52
|
+
# Limitation: both renderings run in this process, so a path built from
|
|
53
|
+
# per-process values (Process.pid) looks shared, and one built from
|
|
54
|
+
# per-call values (SecureRandom, Time.now) looks separate.
|
|
55
|
+
def shared_sqlite_test_database?(root)
|
|
47
56
|
path = File.join(root, DATABASE_YML)
|
|
48
57
|
return false unless File.exist?(path)
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
content = File.read(path)
|
|
60
|
+
first_worker = test_section(content, "")
|
|
61
|
+
return false if !sqlite?(first_worker) || in_memory?(first_worker)
|
|
62
|
+
|
|
63
|
+
second_worker = test_section(content, "2")
|
|
64
|
+
second_worker.is_a?(Hash) && first_worker["database"] == second_worker["database"]
|
|
65
|
+
end
|
|
52
66
|
|
|
53
|
-
|
|
67
|
+
def sqlite?(test_config)
|
|
54
68
|
return false unless test_config.is_a?(Hash)
|
|
55
69
|
|
|
56
70
|
adapter = test_config["adapter"]
|
|
57
71
|
adapter.is_a?(String) && adapter.downcase.include?("sqlite")
|
|
58
72
|
end
|
|
59
73
|
|
|
60
|
-
def
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
74
|
+
def in_memory?(test_config)
|
|
75
|
+
database = test_config["database"]
|
|
76
|
+
database.is_a?(String) && IN_MEMORY.match?(database)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def test_section(content, test_env_number)
|
|
80
|
+
parsed = YAML.safe_load(render(content, test_env_number), aliases: true)
|
|
81
|
+
parsed["test"] if parsed.is_a?(Hash)
|
|
64
82
|
rescue StandardError, SyntaxError
|
|
65
83
|
nil
|
|
66
84
|
end
|
|
85
|
+
|
|
86
|
+
# Renders the ERB against a copy of ENV with TEST_ENV_NUMBER set, so the
|
|
87
|
+
# process environment is never touched: ENV inside the template resolves
|
|
88
|
+
# to the scope's own constant before the global one.
|
|
89
|
+
def render(content, test_env_number)
|
|
90
|
+
scope = Module.new
|
|
91
|
+
scope.const_set(:ENV, ENV.to_h.merge("TEST_ENV_NUMBER" => test_env_number))
|
|
92
|
+
ERB.new(content).result(scope.module_eval("binding", __FILE__, __LINE__))
|
|
93
|
+
end
|
|
67
94
|
end
|
|
68
95
|
end
|
|
@@ -4,6 +4,7 @@ require "fileutils"
|
|
|
4
4
|
require_relative "version"
|
|
5
5
|
require_relative "temp_dir_tracker"
|
|
6
6
|
require_relative "diagnostic"
|
|
7
|
+
require_relative "coverage/load_tracker"
|
|
7
8
|
|
|
8
9
|
# Single owner of the process-lifecycle invariant: every pid spawned here is
|
|
9
10
|
# group-isolated, tracked in a signal-safe registry, group-signalled through a
|
|
@@ -32,8 +33,10 @@ class Evilution::ProcessSupervisor
|
|
|
32
33
|
# leader), the parent-side fds to close on reap, and an optional sandbox dir
|
|
33
34
|
# to remove on reap.
|
|
34
35
|
# `status` is filled in when the child is reaped, so a caller that got no
|
|
35
|
-
# payload out of it can still say how it died.
|
|
36
|
-
|
|
36
|
+
# payload out of it can still say how it died. `reaped` is set once it has
|
|
37
|
+
# been: from then on the pid may belong to another process, so it is never
|
|
38
|
+
# signalled or waited on again.
|
|
39
|
+
Handle = Struct.new(:pid, :pgid, :fds, :sandbox_dir, :status, :reaped, keyword_init: true)
|
|
37
40
|
|
|
38
41
|
@registry = [].freeze
|
|
39
42
|
|
|
@@ -124,6 +127,9 @@ class Evilution::ProcessSupervisor
|
|
|
124
127
|
def spawn(sandbox_dir: nil, fds: [], isolate_in_child: true)
|
|
125
128
|
pid = ::Process.fork do
|
|
126
129
|
self.class.reset_for_child!
|
|
130
|
+
# The child runs tests (or forks the children that do), which may start
|
|
131
|
+
# line coverage themselves.
|
|
132
|
+
Evilution::Coverage::LoadTracker.release_inherited
|
|
127
133
|
isolate_self if isolate_in_child
|
|
128
134
|
yield
|
|
129
135
|
end
|
|
@@ -148,7 +154,15 @@ class Evilution::ProcessSupervisor
|
|
|
148
154
|
|
|
149
155
|
# Bounded TERM -> grace -> KILL ladder, then reap. Always ends with the child
|
|
150
156
|
# reaped and its resources released, whichever rung it dies on.
|
|
157
|
+
#
|
|
158
|
+
# A child already reaped was released along with it, and its pid may now
|
|
159
|
+
# belong to another process, so neither the pid is signalled nor waited on.
|
|
160
|
+
# Its group is still swept once: processes the child left behind keep the
|
|
161
|
+
# group alive, and a group id is not handed out again while any member
|
|
162
|
+
# remains (an empty group is a harmless ESRCH).
|
|
151
163
|
def terminate(handle, grace: GRACE_PERIOD)
|
|
164
|
+
return safe_kill("TERM", -handle.pgid) if handle.reaped
|
|
165
|
+
|
|
152
166
|
signal_group("TERM", handle)
|
|
153
167
|
unless exited?(handle.pid)
|
|
154
168
|
sleep(grace)
|
|
@@ -161,7 +175,10 @@ class Evilution::ProcessSupervisor
|
|
|
161
175
|
# release the resources the handle owns: close parent-side fds, remove the
|
|
162
176
|
# sandbox dir, and drop the handle from the registry.
|
|
163
177
|
def reap(handle)
|
|
178
|
+
return if handle.reaped
|
|
179
|
+
|
|
164
180
|
handle.status = safe_wait(handle.pid)
|
|
181
|
+
handle.reaped = true
|
|
165
182
|
ensure
|
|
166
183
|
release(handle)
|
|
167
184
|
end
|
|
@@ -173,10 +190,13 @@ class Evilution::ProcessSupervisor
|
|
|
173
190
|
# it releases the handle in the same step it reaps, so the process-global
|
|
174
191
|
# registry never holds a stale, already-reaped pgid.
|
|
175
192
|
def reap_nonblock(handle)
|
|
193
|
+
return true if handle.reaped
|
|
194
|
+
|
|
176
195
|
outcome = nonblocking_wait(handle.pid)
|
|
177
196
|
return false unless outcome
|
|
178
197
|
|
|
179
198
|
handle.status = outcome if outcome.is_a?(::Process::Status)
|
|
199
|
+
handle.reaped = true
|
|
180
200
|
release(handle)
|
|
181
201
|
true
|
|
182
202
|
end
|
|
@@ -11,9 +11,20 @@ class Evilution::Reporter::CLI::ItemFormatters::CoverageGap
|
|
|
11
11
|
private
|
|
12
12
|
|
|
13
13
|
def format_header(gap, location)
|
|
14
|
-
return " #{gap.primary_operator}: #{location} (#{gap.subject_name})" if gap.single?
|
|
14
|
+
return " #{gap.primary_operator}: #{location} (#{gap.subject_name})#{implied_note(gap)}" if gap.single?
|
|
15
15
|
|
|
16
|
-
" #{location} (#{gap.subject_name}) [#{gap.count} mutations: #{gap.operator_names.join(", ")}]"
|
|
16
|
+
" #{location} (#{gap.subject_name}) [#{gap.count} mutations: #{gap.operator_names.join(", ")}]" \
|
|
17
|
+
"#{implied_note(gap)}"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# A survivor a probe-first sentinel implied did not run, so it is told apart
|
|
21
|
+
# from one whose tests ran and missed.
|
|
22
|
+
def implied_note(gap)
|
|
23
|
+
implied = gap.implied_results
|
|
24
|
+
return "" if implied.empty?
|
|
25
|
+
|
|
26
|
+
share = implied.length == gap.count ? "" : "#{implied.length} "
|
|
27
|
+
" (#{share}implied by #{implied.first.implied_by}, not run)"
|
|
17
28
|
end
|
|
18
29
|
|
|
19
30
|
def format_body(gap)
|
|
@@ -36,7 +36,11 @@ class Evilution::Reporter::CLI::ItemFormatters::SubjectScore
|
|
|
36
36
|
"(#{score.killed}/#{score.verified})"
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
# Mutations no test executes were never run: the row says how many of the
|
|
40
|
+
# misses those are, so a low score is not read as tests that ran and missed.
|
|
39
41
|
def note(score)
|
|
40
|
-
|
|
42
|
+
return " #{UNREACHED_NOTE}" unless score.reached?
|
|
43
|
+
|
|
44
|
+
score.uncovered.positive? ? " #{score.uncovered} uncovered" : ""
|
|
41
45
|
end
|
|
42
46
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require_relative "../line_formatters"
|
|
4
4
|
|
|
5
5
|
class Evilution::Reporter::CLI::LineFormatters::Mutations
|
|
6
|
-
OPTIONAL_FIELDS = %i[neutral equivalent unresolved unparseable skipped].freeze
|
|
6
|
+
OPTIONAL_FIELDS = %i[uncovered neutral equivalent unresolved unparseable skipped].freeze
|
|
7
7
|
|
|
8
8
|
def format(summary)
|
|
9
9
|
base_line(summary) + optional_sections(summary)
|
|
@@ -13,7 +13,14 @@ class Evilution::Reporter::CLI::LineFormatters::Mutations
|
|
|
13
13
|
|
|
14
14
|
def base_line(summary)
|
|
15
15
|
"Mutations: #{summary.total} total, #{summary.killed} killed, " \
|
|
16
|
-
"#{summary.survived} survived, #{summary.timed_out} timed out"
|
|
16
|
+
"#{summary.survived} survived#{implied_note(summary)}, #{summary.timed_out} timed out"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Survivors a probe-first sentinel implied are counted in survived, but did
|
|
20
|
+
# not run, and can be wrong; the line says how many there are.
|
|
21
|
+
def implied_note(summary)
|
|
22
|
+
implied = summary.implied
|
|
23
|
+
implied.positive? ? " (#{implied} implied, not run)" : ""
|
|
17
24
|
end
|
|
18
25
|
|
|
19
26
|
def optional_sections(summary)
|