Skip to content

fix(mutation): honor filters and isolation#14848

Open
zerosnacks wants to merge 13 commits into
mutation-testing-fastfrom
pr-13091
Open

fix(mutation): honor filters and isolation#14848
zerosnacks wants to merge 13 commits into
mutation-testing-fastfrom
pr-13091

Conversation

@zerosnacks
Copy link
Copy Markdown
Contributor

@zerosnacks zerosnacks commented May 20, 2026

Stacked on #14971 towards OSS-1

  • Honor Forge test filters and isolation settings during mutation runs.
  • Reject mutation mode with incompatible test flags instead of silently producing misleading results.
  • Preserve fix(mutation): key cached results by execution inputs #14971's execution-aware result/survived cache keys while layering the remaining runtime correctness fixes on top.
  • Improve adaptive/resume behavior by loading survived spans before mutant generation.
  • Avoid invalid/duplicate mutations for compound assignments and tighten mutator tests.
  • Improve reporting/runner plumbing for skipped, timed out, and resumed mutants.

mablr and others added 4 commits May 29, 2026 15:45
…compound assignment mutation, reject incompatible flags

- runner: thread FilterArgs and --isolate through MutationRunConfig into
  compile_and_test_inner; rebuild ProjectPathsAwareFilter against the
  per-mutant temp config so --match-test/--match-contract/--match-path
  work and mutants exercise the same test set/execution model as baseline
- mod: add runtime_context_digest folded into the per-file cache key so
  cached results aren't reused when filters, isolation, fork URL/block,
  sender, or initial_balance change
- orchestrator: compute runtime_context_digest once per run and bind it
  to every MutationHandler
- binary_op_mutator: stop mutating compound assignments (a += b would
  silently be rewritten to a - b dropping the assignment); add regression
  tests
- cmd/test: bail when --mutate is combined with --list/--debug/
  --flamegraph/--flamechart/--junit instead of silently mixing modes
- fs_permissions guard now narrowed to permissions whose path can reach
  symlinked dependency trees (lib/node_modules/dependencies)

Amp-Thread-ID: https://ampcode.com/threads/T-019e4567-e7ca-717e-bcc0-bb67a3667c4d
Co-authored-by: Amp <amp@ampcode.com>
Blockers
- filter parity: pass materialized baseline filter (filter.args().clone())
  into MutationRunConfig so positional 'forge test <path>' and --rerun
  reach mutant runs too; raw self.filter dropped them silently
- bail when baseline matched zero tests; without it every compileable
  mutant was reported as 'Alive'
- negative literal mutation: add OwnedLiteral::NegatedNumber(U256)
  formatted as '-{val}'; the old Number(-*val) wrapped via two's
  complement and produced wrong-source mutants
- mutator test harness: wrap snippets in valid Solidity, panic on parse
  failure, and check emitted replacement text. Fixed 6 stale test
  expectations and 1 unmatched delegate-pattern case the old vacuous
  harness was hiding

Mediums
- survived-span resume: load retrieve_survived_spans BEFORE mutant
  generation/cached load and filter cached mutants through
  should_skip_span so cross-run adaptive skipping actually works
- runtime context digest: hash the full serialized EvmOpts (networks,
  env, gas-limit toggles, fork, sender, balance, ...) instead of a
  hand-picked 4-field subset that missed several mutation-affecting
  knobs
- deterministic output: BTreeMap for JSON survived_mutants with sorted
  entries; reporter sorts survived list by (path, line, col, span,
  mutation); persisted results_vec sorted by span
- --mutate-contract: intersect with explicit --mutate <paths> instead of
  silently overriding them; explicit paths are now respected
- workspace: copy 'script/' when present and distinct from src/test so
  projects that import script-side helpers don't see false Invalid
  mutants

Amp-Thread-ID: https://ampcode.com/threads/T-019e4567-e7ca-717e-bcc0-bb67a3667c4d
Co-authored-by: Amp <amp@ampcode.com>
@mablr mablr changed the base branch from mutation-testing-fast to mablr/mutation-cache-correctness May 29, 2026 16:49
@mablr mablr changed the title fix: mutation testing fix(mutation): honor filters and isolation May 29, 2026
@mablr mablr marked this pull request as ready for review May 29, 2026 17:15
mablr

This comment was marked as outdated.

Base automatically changed from mablr/mutation-cache-correctness to mutation-testing-fast May 29, 2026 18:27
Copy link
Copy Markdown
Collaborator

@stevencartavia stevencartavia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

three things worth a look. All reproduced end-to-end against this branch (pr-14848 @ 79abd60e7).

Comment thread crates/forge/src/cmd/test/mod.rs Outdated
Comment thread crates/forge/src/mutation/mutators/binary_op_mutator.rs
Comment thread crates/forge/src/mutation/mod.rs Outdated
@mablr mablr dismissed their stale review May 30, 2026 22:30

stale

@mablr mablr self-requested a review May 30, 2026 22:34
@mablr mablr requested a review from stevencartavia May 30, 2026 22:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants