henitai 0.6.0 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +111 -1
- data/README.md +23 -6
- data/assets/schema/henitai.schema.json +6 -0
- data/lib/henitai/bootstrap_error_message.rb +20 -2
- data/lib/henitai/checkpoint_reporter.rb +5 -0
- data/lib/henitai/cli/operator_command.rb +10 -3
- data/lib/henitai/cli.rb +2 -1
- data/lib/henitai/composite_progress_reporter.rb +15 -2
- data/lib/henitai/configuration.rb +6 -1
- data/lib/henitai/configuration_validator/rules.rb +1 -0
- data/lib/henitai/configuration_validator/scalars.rb +13 -0
- data/lib/henitai/configuration_validator.rb +2 -1
- data/lib/henitai/control_gate.rb +78 -0
- data/lib/henitai/control_run.rb +37 -43
- data/lib/henitai/coverage_bootstrapper.rb +12 -3
- data/lib/henitai/execution_engine/env_scope.rb +3 -3
- data/lib/henitai/execution_engine/fork_server_scope.rb +6 -6
- data/lib/henitai/execution_engine.rb +74 -99
- data/lib/henitai/execution_provenance.rb +67 -0
- data/lib/henitai/flaky_detection_baseline.rb +5 -3
- data/lib/henitai/fork_server/client.rb +0 -9
- data/lib/henitai/fork_server/mutant_runner.rb +14 -45
- data/lib/henitai/fork_server.rb +0 -1
- data/lib/henitai/history_checkpointer.rb +72 -0
- data/lib/henitai/integration/base.rb +6 -14
- data/lib/henitai/integration/child_report_store.rb +34 -5
- data/lib/henitai/integration/minitest.rb +1 -8
- data/lib/henitai/integration/minitest_fail_fast.rb +43 -0
- data/lib/henitai/integration/minitest_outcome_reporter.rb +17 -1
- data/lib/henitai/integration/minitest_test_runner.rb +16 -4
- data/lib/henitai/integration/mutant_run_support.rb +11 -8
- data/lib/henitai/integration/rspec_child_runner.rb +12 -7
- data/lib/henitai/integration/rspec_file_order.rb +37 -0
- data/lib/henitai/integration/rspec_process_runner.rb +0 -19
- data/lib/henitai/integration.rb +2 -3
- data/lib/henitai/kill_history/store.rb +67 -0
- data/lib/henitai/kill_history.rb +85 -0
- data/lib/henitai/mutant.rb +5 -0
- data/lib/henitai/mutant_history_store/database.rb +61 -0
- data/lib/henitai/mutant_history_store/sql.rb +9 -3
- data/lib/henitai/mutant_history_store/subject_scans.rb +101 -0
- data/lib/henitai/mutant_history_store/verdict_cache.rb +40 -11
- data/lib/henitai/mutant_history_store.rb +66 -50
- data/lib/henitai/operator.rb +6 -2
- data/lib/henitai/operators/equality_identity_operator.rb +2 -2
- data/lib/henitai/operators/hash_key_type.rb +11 -1
- data/lib/henitai/operators/hash_literal.rb +30 -5
- data/lib/henitai/operators/string_literal.rb +17 -4
- data/lib/henitai/process_worker_runner.rb +23 -3
- data/lib/henitai/reuse_context.rb +4 -2
- data/lib/henitai/rspec_outcomes.rb +3 -1
- data/lib/henitai/runner.rb +54 -2
- data/lib/henitai/runner_dependencies.rb +23 -3
- data/lib/henitai/scenario_execution_result.rb +27 -4
- data/lib/henitai/signal_deferral.rb +25 -0
- data/lib/henitai/slot_scheduler/control_slots.rb +58 -0
- data/lib/henitai/slot_scheduler/draining.rb +25 -6
- data/lib/henitai/slot_scheduler/retry_policy.rb +13 -1
- data/lib/henitai/slot_scheduler.rb +18 -14
- data/lib/henitai/test_file_outcomes.rb +15 -1
- data/lib/henitai/test_prioritizer.rb +10 -2
- data/lib/henitai/version.rb +1 -1
- data/lib/henitai.rb +5 -1
- data/sig/henitai.rbs +42 -24
- metadata +21 -6
- data/lib/henitai/flaky_mutant_retrier.rb +0 -43
- data/lib/henitai/fork_server/group_terminator.rb +0 -47
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 656b11a422036d85c179982cc35ef056288e27198be4867cb860566cd77405fb
|
|
4
|
+
data.tar.gz: a49ae867dc83272fad2988e6fc771f8673a7015ab9b6b7c6618e0d8845bc8ef5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 145b510c9396f5373d4e65bb9a7c2aa37814545c763a4d57116e8deda72ddb7b8ba88f706653eabb113f7ed42e28cbe6c559ae3ba35e9ebe6afacc4938d85443
|
|
7
|
+
data.tar.gz: 4d081f6082f5beceed0d8650466223fe241e573231241fe1805fa3e8f8a942ec7b3dac50724ee7a6670260c5b920987228b4b0fd5244adcde4ba8e9909052013
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,115 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.0] - 2026-11-24
|
|
11
|
+
|
|
12
|
+
Minor release. Interrupted runs can be resumed, `jobs: 1` runs through the
|
|
13
|
+
same scheduler as parallel runs, a mutant's test run stops at its first
|
|
14
|
+
failure, and test files are ordered by what earlier runs learned (kills,
|
|
15
|
+
hangs). Expect shorter runs and a higher MSI: mutants that a test killed
|
|
16
|
+
before a later test hung used to be reported as `Timeout`. Custom
|
|
17
|
+
integrations must implement `#spawn_mutant` and `#build_result`;
|
|
18
|
+
`Integration#run_mutant` is gone.
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- `mutation.suite_timeout` (default `900.0` seconds) sets the limit for one
|
|
23
|
+
baseline suite run (coverage bootstrap and flaky detection).
|
|
24
|
+
- The test order learned in a run (kill counts per test file and the test files
|
|
25
|
+
that hung per subject) is saved to `henitai_test_order.json` in the reports
|
|
26
|
+
directory and seeds the next run, so a hang is paid once rather than in every
|
|
27
|
+
run. `henitai clean` removes the file and so resets the learned order. A
|
|
28
|
+
save failure (for example a read-only reports dir) only warns and never
|
|
29
|
+
fails the run.
|
|
30
|
+
- Interrupted runs can be resumed with `henitai run --incremental`
|
|
31
|
+
(ADR-19). Verdicts are written to the history store in batches while the
|
|
32
|
+
run goes on; on Ctrl-C, `TERM` or `HUP` henitai saves what it has, prints
|
|
33
|
+
`interrupted; N verdicts saved, resume with --incremental` and exits.
|
|
34
|
+
After a hard kill at most the last unsaved batch is lost. Detections are
|
|
35
|
+
saved only after their control run passed: the control now runs at a
|
|
36
|
+
group's first detection instead of after the last mutant. A verdict is
|
|
37
|
+
cached only if the files it ran against are unchanged since the run
|
|
38
|
+
started, and a kill whose flaky retry was cut short by the shutdown is
|
|
39
|
+
never cached. Aborted runs add no trend point; each run writes one
|
|
40
|
+
history entry per mutant. Toggling `mutation.control_runs` now
|
|
41
|
+
invalidates cached verdicts. `rake oracle:resume` checks the resume end
|
|
42
|
+
to end
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
|
|
46
|
+
- The default limit for a baseline suite run went from 300 s to 900 s; it is
|
|
47
|
+
now configurable as `mutation.suite_timeout`.
|
|
48
|
+
- `jobs: 1` runs through the same scheduler as `jobs: N` (ADR-20); `jobs`
|
|
49
|
+
only sets how many mutants run at once. One-job runs now handle INT, TERM
|
|
50
|
+
and HUP like parallel runs (drain the running child, then stop with
|
|
51
|
+
`Interrupt`), mark kills whose flaky retry a shutdown cut short, and run
|
|
52
|
+
control runs as scheduler jobs. `jobs: 0` means one job. Verdicts are
|
|
53
|
+
unchanged. Removed the synchronous mutant API `Integration#run_mutant`
|
|
54
|
+
(and its RSpec, Minitest and fork-server variants); integrations implement
|
|
55
|
+
`#spawn_mutant` and `#build_result`
|
|
56
|
+
- A mutant's test run stops at its first failure (RSpec: `fail_fast = 1`,
|
|
57
|
+
overriding the project's setting; Minitest: no further test class starts).
|
|
58
|
+
Killed mutants finish sooner. A mutant that one test kills before another
|
|
59
|
+
test hangs, exits or crashes is now `Killed` instead of `Timeout` or
|
|
60
|
+
`RuntimeError` (MSI rises; MS is unchanged with the default
|
|
61
|
+
`coverage_criteria`). With `flaky_detection`, a kill whose first failing
|
|
62
|
+
file is flaky is retried, and ends `Survived` if no retry fails
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- A baseline suite run that exceeds its limit is reported as a timeout that
|
|
67
|
+
names `mutation.suite_timeout`, instead of "Configured test suite failed
|
|
68
|
+
while generating coverage".
|
|
69
|
+
- Test prioritization works. Kill counts never reached `TestPrioritizer`
|
|
70
|
+
(it read a `config.history` that does not exist), and with
|
|
71
|
+
`config.order = :random` the RSpec child reshuffled the spec files anyway.
|
|
72
|
+
Now a test file that hung (timed out) for an earlier mutant of the same
|
|
73
|
+
subject runs last; the others run by kills earlier in the run, then
|
|
74
|
+
fastest first, and the RSpec child keeps that file order (random order
|
|
75
|
+
still applies within a file). On the dogfood benchmark this cut wall time
|
|
76
|
+
by 20-46% and timeouts by more than half. Minitest shuffles test classes
|
|
77
|
+
and is unaffected
|
|
78
|
+
- `StringLiteral` no longer emits an equivalent mutant for strings without
|
|
79
|
+
interpolation that parse as `dstr` (adjacent literals such as
|
|
80
|
+
`"a " "b"`, multi-line heredocs). It used to "remove the interpolation"
|
|
81
|
+
and reproduce the original string, which survived every time. Such
|
|
82
|
+
strings now get the plain-string mutations (`""`,
|
|
83
|
+
`"Henitai was here"`). Affected mutants get new stable ids and re-execute
|
|
84
|
+
once under `--incremental`
|
|
85
|
+
- `HashKeyType` descriptions name the replaced key
|
|
86
|
+
(`replaced symbol key foo with string key`) instead of one constant string,
|
|
87
|
+
so several mutants of the same hash are distinguishable in every report
|
|
88
|
+
surface. A symbol key containing a newline falls back to its position.
|
|
89
|
+
Affected mutants get new stable ids and re-execute once under
|
|
90
|
+
`--incremental`
|
|
91
|
+
- Retired mutant identities no longer linger in `mutation-history.json`.
|
|
92
|
+
When a description or operator changes, the old stable id can never match
|
|
93
|
+
again; those rows kept appearing in the trend export with a frozen
|
|
94
|
+
`lastSeenVersion` and a meaningless `daysAlive`. Retirement is decided per
|
|
95
|
+
subject — a mutant is retired only once its own subject has been mutated
|
|
96
|
+
in full without it — so narrow `--since` runs and `--survivors-from`
|
|
97
|
+
partial reruns cannot retire mutants they simply did not re-record, and a
|
|
98
|
+
`light` scan never retires `full`-only mutants. Rows stay in the SQLite
|
|
99
|
+
database as an audit trail; only the export filters. Rows written before
|
|
100
|
+
this release carry no subject, and a retired identity is by definition
|
|
101
|
+
never re-recorded, so pre-existing retired rows stay in the export —
|
|
102
|
+
retirement applies from the first full scan after upgrading onward
|
|
103
|
+
- `HashLiteral` pair-removal descriptions no longer leak AST s-expressions
|
|
104
|
+
into reports. Only literal keys are named (string keys now quoted, so
|
|
105
|
+
`{ "a" => 1, a: 2 }` yields two distinguishable descriptions); variable,
|
|
106
|
+
array, nested-hash and interpolated-symbol keys fall back to a positional
|
|
107
|
+
label such as `removed hash pair #1`. A nested-hash key previously produced
|
|
108
|
+
a multi-line description, which broke every single-line output surface and
|
|
109
|
+
reached `stableId` in the JSON report and the SQLite history. Affected
|
|
110
|
+
mutants get new stable ids and re-execute once under `--incremental`
|
|
111
|
+
- `henitai operator list` gains a `Hard set` section, so `HashKeyType` and
|
|
112
|
+
`EqualityIdentityOperator` are discoverable again (`EqualityIdentityOperator`
|
|
113
|
+
was listed in 0.3.1 and nowhere in 0.4.0). Sets now nest in the output —
|
|
114
|
+
each section lists only what it adds to the previous one, instead of
|
|
115
|
+
re-printing the light operators in every set
|
|
116
|
+
- `HashKeyType` requires `parser_current` itself instead of relying on a
|
|
117
|
+
sibling operator having loaded the parser first
|
|
118
|
+
|
|
10
119
|
## [0.6.0] - 2026-10-20
|
|
11
120
|
|
|
12
121
|
Minor release with a deliberate score break: false kills and harness
|
|
@@ -808,7 +917,8 @@ before adjusting thresholds.
|
|
|
808
917
|
- CLI critical path: `henitai run` now executes the full pipeline, supports `--since`, returns CI-friendly exit codes, and `henitai version` prints `Henitai::VERSION`
|
|
809
918
|
- RSpec per-test coverage output: `henitai/coverage_formatter` now writes `coverage/henitai_per_test.json`
|
|
810
919
|
|
|
811
|
-
[Unreleased]: https://github.com/martinotten/henitai/compare/v0.
|
|
920
|
+
[Unreleased]: https://github.com/martinotten/henitai/compare/v0.7.0...HEAD
|
|
921
|
+
[0.7.0]: https://github.com/martinotten/henitai/compare/v0.6.0...v0.7.0
|
|
812
922
|
[0.6.0]: https://github.com/martinotten/henitai/compare/v0.5.3...v0.6.0
|
|
813
923
|
[0.5.3]: https://github.com/martinotten/henitai/compare/v0.5.2...v0.5.3
|
|
814
924
|
[0.5.2]: https://github.com/martinotten/henitai/compare/v0.5.1...v0.5.2
|
data/README.md
CHANGED
|
@@ -80,13 +80,14 @@ test_excludes:
|
|
|
80
80
|
- spec/end_to_end/*_spec.rb # never run these files, mutants or coverage baseline
|
|
81
81
|
|
|
82
82
|
mutation:
|
|
83
|
-
operators: light # light | full
|
|
83
|
+
operators: light # light | full | hard
|
|
84
84
|
timeout: 10.0
|
|
85
85
|
timeout_multiplier: 3.0
|
|
86
86
|
max_flaky_retries: 3
|
|
87
87
|
flaky_detection: false # run the baseline twice to find flaky test files
|
|
88
88
|
max_log_bytes: 5000000
|
|
89
89
|
max_timeout: 30.0
|
|
90
|
+
suite_timeout: 900.0 # seconds the baseline suite run (coverage bootstrap, flaky detection) may take
|
|
90
91
|
control_runs: true # re-run detected subjects with the unmutated method
|
|
91
92
|
fork_server: false # opt-in: boot the RSpec/Minitest environment once, fork each mutant run from it (any jobs; falls back to per-mutant boot with a warning)
|
|
92
93
|
sampling:
|
|
@@ -129,7 +130,9 @@ durations of the selected test files + the measured suite boot time), with a
|
|
|
129
130
|
2 s floor. `mutation.max_timeout` (default `30.0`) caps the calibrated value,
|
|
130
131
|
but never below the measured baseline plus 2 s; when the baseline alone exceeds
|
|
131
132
|
`max_timeout`, Henitai warns once and uses baseline + 2 s. An explicit
|
|
132
|
-
`mutation.timeout` still takes precedence.
|
|
133
|
+
`mutation.timeout` still takes precedence. `mutation.suite_timeout` (default
|
|
134
|
+
`900.0`) limits one baseline suite run (coverage bootstrap and flaky detection);
|
|
135
|
+
if it is exceeded, Henitai reports a timeout and names the setting to raise. When JSON or HTML reporting is
|
|
133
136
|
enabled, `reports.checkpoint*` controls periodic canonical-report checkpoints.
|
|
134
137
|
Each checkpoint updates `mutation-report.json`; when the HTML reporter is
|
|
135
138
|
configured, it also regenerates `mutation-report.html` from that merged JSON.
|
|
@@ -196,12 +199,13 @@ of candidate tests for a mutant, and name matching is only the fallback for when
|
|
|
196
199
|
the map cannot decide (no map, no location, or no covering test left in the
|
|
197
200
|
integration).
|
|
198
201
|
|
|
199
|
-
Henitai
|
|
200
|
-
|
|
202
|
+
Henitai runs one mutant at a time by default. Set `jobs` in `.henitai.yml`
|
|
203
|
+
or pass `--jobs N` to run N mutants in parallel. `jobs` only sets how many
|
|
204
|
+
run at once: timeouts, flaky retries, control runs and INT/TERM handling
|
|
205
|
+
behave the same for every value.
|
|
201
206
|
|
|
202
207
|
Every forked test child sees a `HENITAI_WORKER_SLOT` environment variable
|
|
203
|
-
holding a stable worker-slot index (`0..jobs-1`; always `0`
|
|
204
|
-
path). A flaky-retry respawn keeps the original attempt's value. Test suites
|
|
208
|
+
holding a stable worker-slot index (`0..jobs-1`; always `0` with one job). A flaky-retry respawn keeps the original attempt's value. Test suites
|
|
205
209
|
that touch shared external resources can isolate themselves per slot without
|
|
206
210
|
any henitai-side hooks — for example a per-worker database:
|
|
207
211
|
|
|
@@ -257,6 +261,18 @@ canonical entries written before site-offset IDs were introduced instead of
|
|
|
257
261
|
duplicating them.
|
|
258
262
|
Timeouts and errors always re-execute. `--force` bypasses reuse, including
|
|
259
263
|
the reuse applied to `--survivors-from` reruns.
|
|
264
|
+
|
|
265
|
+
An interrupted run can be resumed. During the run, finished verdicts are
|
|
266
|
+
written to the history store in batches (the `reports.checkpoint_every` /
|
|
267
|
+
`checkpoint_interval` cadence). When the run is stopped with Ctrl-C, `TERM`
|
|
268
|
+
or `HUP`, henitai stops its test processes, saves what it has, prints
|
|
269
|
+
`henitai: interrupted; N verdicts saved, resume with --incremental` and exits.
|
|
270
|
+
`henitai run --incremental` then re-executes only what is missing. A detected
|
|
271
|
+
verdict is saved only after its control run passed, and only while the files
|
|
272
|
+
it ran against are unchanged since the run started, so an edit during the run
|
|
273
|
+
makes the affected verdicts re-execute instead of being reused. After a hard
|
|
274
|
+
kill (`SIGKILL`, out of memory) at most the last unsaved batch is lost. An
|
|
275
|
+
aborted run adds no point to the trend in `mutation-history.json`.
|
|
260
276
|
`henitai run --dry-run` lists the post-filter mutant set without executing
|
|
261
277
|
mutants and always exits `0`. Gate 0 may still run the configured test suite to
|
|
262
278
|
refresh baseline coverage.
|
|
@@ -410,6 +426,7 @@ bundle exec ruby bin/verify-process-free-specs # verify self-mutation-safe specs
|
|
|
410
426
|
bundle exec rake smoke:integration:all # run rspec/minitest integration smoke projects
|
|
411
427
|
bundle exec rake oracle # measure false kills/survivors on the oracle corpus
|
|
412
428
|
bundle exec rake oracle:reuse # check --incremental verdicts equal fresh runs
|
|
429
|
+
bundle exec rake oracle:resume # interrupt runs with INT/TERM/HUP, check the resume
|
|
413
430
|
bundle exec rubocop # lint
|
|
414
431
|
bundle exec henitai clean # remove stale generated report artifacts
|
|
415
432
|
bundle exec henitai run # dogfood
|
|
@@ -65,6 +65,12 @@
|
|
|
65
65
|
"type": "number",
|
|
66
66
|
"exclusiveMinimum": 0
|
|
67
67
|
},
|
|
68
|
+
"suite_timeout": {
|
|
69
|
+
"type": "number",
|
|
70
|
+
"exclusiveMinimum": 0,
|
|
71
|
+
"default": 900.0,
|
|
72
|
+
"description": "Seconds the baseline suite run (coverage bootstrap, flaky detection) may take before it is stopped. A timed-out baseline is reported as a timeout, not a failure."
|
|
73
|
+
},
|
|
68
74
|
"flaky_detection": {
|
|
69
75
|
"type": "boolean",
|
|
70
76
|
"default": false,
|
|
@@ -7,14 +7,32 @@ module Henitai
|
|
|
7
7
|
|
|
8
8
|
module_function
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
# +timeout+ is the limit (seconds) the baseline ran under; it is named in
|
|
11
|
+
# the message when the run timed out.
|
|
12
|
+
def build(result, timeout: nil)
|
|
11
13
|
return GENERIC unless result.respond_to?(:log_path)
|
|
12
14
|
|
|
13
15
|
tail = result.tail(12).strip
|
|
14
|
-
message = +
|
|
16
|
+
message = +headline(result, timeout)
|
|
15
17
|
message << " (see #{result.log_path})"
|
|
16
18
|
message << "\n#{tail}" unless tail.empty?
|
|
17
19
|
message
|
|
18
20
|
end
|
|
21
|
+
|
|
22
|
+
def headline(result, timeout)
|
|
23
|
+
return GENERIC unless timed_out?(result)
|
|
24
|
+
|
|
25
|
+
limit = timeout ? "#{format_seconds(timeout)} s" : "the time limit"
|
|
26
|
+
"Configured test suite did not finish within #{limit} while generating coverage; " \
|
|
27
|
+
"raise mutation.suite_timeout to allow more time"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def timed_out?(result)
|
|
31
|
+
result.respond_to?(:status) && result.status == :timeout
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def format_seconds(seconds)
|
|
35
|
+
seconds.is_a?(Float) && seconds == seconds.floor ? seconds.to_i : seconds
|
|
36
|
+
end
|
|
19
37
|
end
|
|
20
38
|
end
|
|
@@ -57,14 +57,19 @@ module Henitai
|
|
|
57
57
|
HELP
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
+
# Sets nest, so each section lists only what it adds to the previous
|
|
61
|
+
# one; printing every set in full would repeat the light operators
|
|
62
|
+
# three times. The header states the nesting so a section title is
|
|
63
|
+
# never mistaken for the whole set.
|
|
60
64
|
def operator_list_text
|
|
61
65
|
validate_operator_metadata!
|
|
62
66
|
sections = [
|
|
63
67
|
operator_list_section("Light set", Operator::LIGHT_SET),
|
|
64
|
-
operator_list_section("Full set", Operator::FULL_SET)
|
|
68
|
+
operator_list_section("Full set (adds to light)", Operator::FULL_SET - Operator::LIGHT_SET),
|
|
69
|
+
operator_list_section("Hard set (adds to full)", Operator::HARD_SET - Operator::FULL_SET)
|
|
65
70
|
]
|
|
66
71
|
|
|
67
|
-
["Available operators", *sections].join("\n")
|
|
72
|
+
["Available operators (full includes light, hard includes full)", *sections].join("\n")
|
|
68
73
|
end
|
|
69
74
|
|
|
70
75
|
def operator_list_section(title, names)
|
|
@@ -86,8 +91,10 @@ module Henitai
|
|
|
86
91
|
["No metadata available", "n/a"]
|
|
87
92
|
end
|
|
88
93
|
|
|
94
|
+
# The widest set is the registry: every operator henitai can name needs
|
|
95
|
+
# a metadata row, not just the ones a default run enables.
|
|
89
96
|
def validate_operator_metadata!
|
|
90
|
-
missing = Operator::
|
|
97
|
+
missing = Operator::HARD_SET - operator_metadata.keys
|
|
91
98
|
return if missing.empty?
|
|
92
99
|
|
|
93
100
|
raise ArgumentError, "Missing operator metadata for: #{missing.join(', ')}"
|
data/lib/henitai/cli.rb
CHANGED
|
@@ -17,7 +17,7 @@ module Henitai
|
|
|
17
17
|
# --since GIT_REF Only mutate subjects changed since GIT_REF
|
|
18
18
|
# --use INTEGRATION Override integration from config (e.g. rspec)
|
|
19
19
|
# --config PATH Path to .henitai.yml (default: .henitai.yml)
|
|
20
|
-
# --operators SET Operator set: light (default) | full
|
|
20
|
+
# --operators SET Operator set: light (default) | full | hard
|
|
21
21
|
# --jobs N Number of parallel workers (default: 1)
|
|
22
22
|
# --all-logs Print all captured child logs
|
|
23
23
|
# -h, --help Show this help message
|
|
@@ -40,6 +40,7 @@ module Henitai
|
|
|
40
40
|
[PerTestCoverageCollector::BOOT_FILE_NAME],
|
|
41
41
|
[CoverageBootstrapper::DEPENDENCY_MANIFEST_FILE],
|
|
42
42
|
[FlakyTestRegistry::FILE_NAME],
|
|
43
|
+
[KillHistory::FILE_NAME],
|
|
43
44
|
[TestFileOutcomes::REPORT_FILE_NAME]
|
|
44
45
|
].freeze
|
|
45
46
|
|
|
@@ -9,8 +9,11 @@ module Henitai
|
|
|
9
9
|
# when terminal output is on, and the checkpoint writer when enabled and a
|
|
10
10
|
# file report (json/html) is configured. Returns a single reporter when only
|
|
11
11
|
# one is active, the composite when several are, or nil when none are.
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
#
|
|
13
|
+
# A {HistoryCheckpointer}, when given, joins them (ADR-19).
|
|
14
|
+
def self.for(config:, source_provider:, full_run:, history_checkpointer: nil)
|
|
15
|
+
active = [terminal_for(config), checkpoint_for(config, source_provider, full_run),
|
|
16
|
+
history_checkpointer].compact
|
|
14
17
|
return active.first if active.one?
|
|
15
18
|
|
|
16
19
|
active.empty? ? nil : new(active)
|
|
@@ -38,5 +41,15 @@ module Henitai
|
|
|
38
41
|
def progress(mutant, scenario_result: nil)
|
|
39
42
|
@reporters.each { |reporter| reporter.progress(mutant, scenario_result:) }
|
|
40
43
|
end
|
|
44
|
+
|
|
45
|
+
# Flushes every reporter that buffers. Each failure is reported and
|
|
46
|
+
# contained, so one reporter cannot keep the others from saving.
|
|
47
|
+
def flush
|
|
48
|
+
@reporters.each do |reporter|
|
|
49
|
+
reporter.flush if reporter.respond_to?(:flush)
|
|
50
|
+
rescue StandardError => e
|
|
51
|
+
warn "henitai: could not flush progress (#{e.class}: #{e.message})"
|
|
52
|
+
end
|
|
53
|
+
end
|
|
41
54
|
end
|
|
42
55
|
end
|
|
@@ -22,6 +22,9 @@ module Henitai
|
|
|
22
22
|
# Ceiling for the per-mutant auto-calibrated timeout (seconds). Keeps a
|
|
23
23
|
# runaway from running for minutes when the calibrated value is large.
|
|
24
24
|
DEFAULT_MAX_TIMEOUT = 30.0
|
|
25
|
+
# Limit (seconds) for one baseline suite run: coverage bootstrap and flaky
|
|
26
|
+
# detection. A run that exceeds it reports a timeout, not a failure.
|
|
27
|
+
DEFAULT_SUITE_TIMEOUT = 900.0
|
|
25
28
|
# Incremental report checkpoint cadence for long full runs.
|
|
26
29
|
DEFAULT_CHECKPOINT_EVERY = 200
|
|
27
30
|
DEFAULT_CHECKPOINT_INTERVAL = 30.0
|
|
@@ -43,7 +46,8 @@ module Henitai
|
|
|
43
46
|
|
|
44
47
|
attr_reader :integration, :includes, :excludes, :test_excludes, :operators, :timeout,
|
|
45
48
|
:timeout_multiplier, :ignore_patterns, :sampling, :jobs,
|
|
46
|
-
:max_flaky_retries, :max_log_bytes, :max_timeout, :
|
|
49
|
+
:max_flaky_retries, :max_log_bytes, :max_timeout, :suite_timeout,
|
|
50
|
+
:control_runs, :flaky_detection, :fork_server,
|
|
47
51
|
:coverage_criteria, :thresholds,
|
|
48
52
|
:reporters, :reports_dir,
|
|
49
53
|
:checkpoint_enabled, :checkpoint_every, :checkpoint_interval,
|
|
@@ -124,6 +128,7 @@ module Henitai
|
|
|
124
128
|
@max_flaky_retries = mutation.fetch(:max_flaky_retries, DEFAULT_MAX_FLAKY_RETRIES)
|
|
125
129
|
@max_log_bytes = mutation[:max_log_bytes] || DEFAULT_MAX_LOG_BYTES
|
|
126
130
|
@max_timeout = mutation[:max_timeout] || DEFAULT_MAX_TIMEOUT
|
|
131
|
+
@suite_timeout = mutation[:suite_timeout] || DEFAULT_SUITE_TIMEOUT
|
|
127
132
|
@control_runs = mutation.fetch(:control_runs, true)
|
|
128
133
|
@flaky_detection = mutation.fetch(:flaky_detection, false)
|
|
129
134
|
@fork_server = mutation.fetch(:fork_server, false)
|
|
@@ -100,6 +100,7 @@ module Henitai
|
|
|
100
100
|
Scalars.validate_max_flaky_retries(value[:max_flaky_retries])
|
|
101
101
|
Scalars.validate_max_log_bytes(value[:max_log_bytes])
|
|
102
102
|
Scalars.validate_max_timeout(value[:max_timeout])
|
|
103
|
+
Scalars.validate_suite_timeout(value[:suite_timeout])
|
|
103
104
|
validate_mutation_flags(value)
|
|
104
105
|
end
|
|
105
106
|
|
|
@@ -111,6 +111,15 @@ module Henitai
|
|
|
111
111
|
)
|
|
112
112
|
end
|
|
113
113
|
|
|
114
|
+
def validate_suite_timeout(value)
|
|
115
|
+
return if value.nil?
|
|
116
|
+
return if value.is_a?(Numeric) && value.positive?
|
|
117
|
+
|
|
118
|
+
Rules.configuration_error(
|
|
119
|
+
"Invalid configuration value for mutation.suite_timeout: expected positive Numeric, got #{value.inspect}"
|
|
120
|
+
)
|
|
121
|
+
end
|
|
122
|
+
|
|
114
123
|
def validate_checkpoint_every(value)
|
|
115
124
|
return if value.nil?
|
|
116
125
|
return if value.is_a?(Integer) && value.positive?
|
|
@@ -167,6 +176,10 @@ module Henitai
|
|
|
167
176
|
)
|
|
168
177
|
end
|
|
169
178
|
|
|
179
|
+
# The result is only ever interpolated into an error message, and
|
|
180
|
+
# Class#to_s returns exactly Class#name for the named classes a config
|
|
181
|
+
# value can hold — so dropping `.name` produces identical output.
|
|
182
|
+
# henitai:disable MethodChainUnwrap: `.class` and `.class.name` interpolate identically
|
|
170
183
|
def describe_array_type(value)
|
|
171
184
|
return value.class.name unless value.is_a?(Array)
|
|
172
185
|
|
|
@@ -25,7 +25,8 @@ module Henitai
|
|
|
25
25
|
jobs
|
|
26
26
|
].freeze
|
|
27
27
|
VALID_MUTATION_KEYS = %i[
|
|
28
|
-
operators timeout timeout_multiplier ignore_patterns max_flaky_retries max_log_bytes max_timeout
|
|
28
|
+
operators timeout timeout_multiplier ignore_patterns max_flaky_retries max_log_bytes max_timeout
|
|
29
|
+
suite_timeout sampling
|
|
29
30
|
control_runs flaky_detection fork_server
|
|
30
31
|
].freeze
|
|
31
32
|
VALID_REPORTS_KEYS = %i[checkpoint checkpoint_every checkpoint_interval].freeze
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Henitai
|
|
4
|
+
# Holds a detected verdict back from the progress observers until a control
|
|
5
|
+
# run has shown that the unmutated method passes the same tests (ADR-14,
|
|
6
|
+
# ADR-19). Every verdict an observer sees is therefore final: the terminal,
|
|
7
|
+
# the report checkpoints and the history never see a detection that a later
|
|
8
|
+
# control would reclassify.
|
|
9
|
+
#
|
|
10
|
+
# One control runs per {ControlRun#group_key}; its outcome is memoized and
|
|
11
|
+
# applied to every later detection of the group. A failing control
|
|
12
|
+
# reclassifies the mutant and its scenario result as CompileError.
|
|
13
|
+
#
|
|
14
|
+
# The launcher starts a group's control; the scheduler that owns it reports
|
|
15
|
+
# the outcome through {#control_finished}, and the gate holds the group's
|
|
16
|
+
# detections until then (ADR-20: controls are scheduler jobs).
|
|
17
|
+
class ControlGate
|
|
18
|
+
attr_reader :stats
|
|
19
|
+
|
|
20
|
+
def initialize(downstream:, control_run:, launcher:)
|
|
21
|
+
@downstream = downstream
|
|
22
|
+
@control_run = control_run
|
|
23
|
+
@launcher = launcher
|
|
24
|
+
@outcomes = {}
|
|
25
|
+
@held = {}
|
|
26
|
+
@stats = { verified: 0, failed: 0, reclassified: 0 }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def progress(mutant, scenario_result: nil)
|
|
30
|
+
return deliver(mutant, scenario_result) unless @control_run.controllable?(mutant)
|
|
31
|
+
|
|
32
|
+
key = @control_run.group_key(mutant)
|
|
33
|
+
return release(mutant, scenario_result, @outcomes[key]) if @outcomes.key?(key)
|
|
34
|
+
|
|
35
|
+
hold(key, mutant, scenario_result)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def control_finished(key, result)
|
|
39
|
+
@outcomes[key] = result
|
|
40
|
+
@stats[:verified] += 1
|
|
41
|
+
@stats[:failed] += 1 unless @control_run.passed?(result)
|
|
42
|
+
Array(@held.delete(key)).each { |mutant, scenario_result| release(mutant, scenario_result, result) }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Discards every held detection, e.g. on shutdown; they re-execute in the
|
|
46
|
+
# next run. @return [Integer] how many were dropped
|
|
47
|
+
def drop_held
|
|
48
|
+
count = @held.values.sum(&:size)
|
|
49
|
+
@held.clear
|
|
50
|
+
count
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
private
|
|
54
|
+
|
|
55
|
+
def hold(key, mutant, scenario_result)
|
|
56
|
+
first = !@held.key?(key)
|
|
57
|
+
(@held[key] ||= []) << [mutant, scenario_result]
|
|
58
|
+
@launcher.call(key, mutant) if first
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def release(mutant, scenario_result, control_result)
|
|
62
|
+
return deliver(mutant, scenario_result) if @control_run.passed?(control_result)
|
|
63
|
+
|
|
64
|
+
@stats[:reclassified] += @control_run.reclassify([mutant], control_result)
|
|
65
|
+
deliver(mutant, reclassified(scenario_result, mutant))
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def reclassified(scenario_result, mutant)
|
|
69
|
+
return scenario_result unless scenario_result.respond_to?(:reclassified)
|
|
70
|
+
|
|
71
|
+
scenario_result.reclassified(status: mutant.status, status_reason: mutant.status_reason)
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def deliver(mutant, scenario_result)
|
|
75
|
+
@downstream&.progress(mutant, scenario_result:)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
data/lib/henitai/control_run.rb
CHANGED
|
@@ -1,64 +1,51 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Henitai
|
|
4
|
-
# Verifies
|
|
5
|
-
# a subject's tests.
|
|
4
|
+
# Verifies that the activation path itself does not break a subject's tests.
|
|
6
5
|
#
|
|
7
|
-
# For every subject with a detected verdict (Killed,
|
|
8
|
-
# the unmutated method is injected through the same
|
|
9
|
-
# path, against the same test files. The tests must
|
|
10
|
-
# injecting the method is what made them fail -- a
|
|
11
|
-
# `super` or `yield` inside `define_method`, a rebuilt
|
|
12
|
-
# none of
|
|
13
|
-
# are reclassified as CompileError with the control's
|
|
6
|
+
# For every subject and test-file set with a detected verdict (Killed,
|
|
7
|
+
# Timeout, RuntimeError) the unmutated method is injected through the same
|
|
8
|
+
# activation and fork path, against the same test files. The tests must
|
|
9
|
+
# pass. If they do not, injecting the method is what made them fail -- a
|
|
10
|
+
# lost constant scope, `super` or `yield` inside `define_method`, a rebuilt
|
|
11
|
+
# parameter list -- so none of the group's detections can be credited to
|
|
12
|
+
# their mutations. They are reclassified as CompileError with the control's
|
|
13
|
+
# outcome as reason. {ControlGate} decides when a control runs: at the
|
|
14
|
+
# group's first detection (ADR-19); the scheduler runs it as a control job
|
|
15
|
+
# (`SlotScheduler::ControlSlots`, ADR-20).
|
|
14
16
|
#
|
|
15
17
|
# Verdicts reused from history are left alone: they were not produced by
|
|
16
18
|
# this run's activation.
|
|
17
19
|
class ControlRun
|
|
18
20
|
DETECTED = %i[killed timeout runtime_error].freeze
|
|
19
21
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
# True for a verdict this run's activation produced and a control can
|
|
23
|
+
# check: a detection with the original node at hand. Reused verdicts and
|
|
24
|
+
# activation-recipe stubs (no original node) are not controllable.
|
|
25
|
+
def controllable?(mutant)
|
|
26
|
+
DETECTED.include?(mutant.status) && !from_cache?(mutant) && original_node?(mutant)
|
|
24
27
|
end
|
|
25
28
|
|
|
26
|
-
#
|
|
27
|
-
def
|
|
28
|
-
stats = { verified: 0, failed: 0, reclassified: 0 }
|
|
29
|
-
detected_groups(mutants).each_value do |detected|
|
|
30
|
-
stats[:verified] += 1
|
|
31
|
-
result = run_control(detected.first)
|
|
32
|
-
next if result.status == :survived
|
|
29
|
+
# Detections sharing a key share one control run.
|
|
30
|
+
def group_key(mutant) = [mutant.subject, test_files(mutant)]
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
stats[:reclassified] += reclassify(detected, result)
|
|
36
|
-
end
|
|
37
|
-
stats
|
|
38
|
-
end
|
|
32
|
+
def passed?(result) = result.status == :survived
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def detected_groups(mutants)
|
|
43
|
-
Array(mutants)
|
|
44
|
-
.select { |mutant| DETECTED.include?(mutant.status) && !mutant.from_cache? && mutant.original_node }
|
|
45
|
-
.group_by { |mutant| [mutant.subject, test_files(mutant)] }
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def run_control(mutant)
|
|
49
|
-
files = test_files(mutant)
|
|
50
|
-
@integration.run_mutant(mutant: control_for(mutant), test_files: files, timeout: @timeout_for.call(files))
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def control_for(mutant)
|
|
34
|
+
# The unmutated method as a mutant the activation path can inject.
|
|
35
|
+
def control_mutant(mutant)
|
|
54
36
|
node = mutant.original_node
|
|
55
37
|
Mutant.new(subject: mutant.subject, operator: "Control", nodes: { original: node, mutated: node },
|
|
56
38
|
description: "unmutated control", location: mutant.location)
|
|
57
39
|
end
|
|
58
40
|
|
|
41
|
+
# The test files a group's control runs against: the detection's own.
|
|
42
|
+
def test_files(mutant)
|
|
43
|
+
Array(mutant.covered_by).sort
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# @return [Integer] the number of reclassified mutants
|
|
59
47
|
def reclassify(detected, result)
|
|
60
|
-
reason =
|
|
61
|
-
"(#{[result.status, result.status_reason].compact.join(': ')})"
|
|
48
|
+
reason = reason_for(result)
|
|
62
49
|
detected.each do |mutant|
|
|
63
50
|
mutant.status = :compile_error
|
|
64
51
|
mutant.status_reason = reason
|
|
@@ -66,8 +53,15 @@ module Henitai
|
|
|
66
53
|
detected.size
|
|
67
54
|
end
|
|
68
55
|
|
|
69
|
-
|
|
70
|
-
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def from_cache?(mutant) = mutant.respond_to?(:from_cache?) && mutant.from_cache?
|
|
59
|
+
|
|
60
|
+
def original_node?(mutant) = mutant.respond_to?(:original_node) && !mutant.original_node.nil?
|
|
61
|
+
|
|
62
|
+
def reason_for(result)
|
|
63
|
+
"control run failed: the unmutated method fails its tests when injected " \
|
|
64
|
+
"(#{[result.status, result.status_reason].compact.join(': ')})"
|
|
71
65
|
end
|
|
72
66
|
end
|
|
73
67
|
end
|