Skip to content

feat: exit non-zero from slither-mutate when mutants are uncaught#3018

Open
cats2101 wants to merge 1 commit intocrytic:masterfrom
cats2101:feat/mutate-exit-code-uncaught
Open

feat: exit non-zero from slither-mutate when mutants are uncaught#3018
cats2101 wants to merge 1 commit intocrytic:masterfrom
cats2101:feat/mutate-exit-code-uncaught

Conversation

@cats2101
Copy link
Copy Markdown

@cats2101 cats2101 commented May 4, 2026

Closes #2772.

slither-mutate currently exits 0 even when mutants escape the test suite, so CI runs cannot tell whether the suite caught everything without parsing logs. This adds campaign-wide accumulators across files and exits non-zero when any compiled mutant survives.

Per the issue, the exit code is intentionally distinct from 1 (used by argparse / setup failures) so CI scripts can distinguish "test framework misconfigured" from "test suite failed to catch a mutant". The constant EXIT_CODE_UNCAUGHT_MUTANTS = 2 makes the contract explicit.

The exit logic is factored into a small _exit_for_campaign_results helper so it can be unit-tested without standing up a real Foundry/forge campaign.

Test plan

  • pytest tests/tools/mutator/test_mutator.py -k exit_for_campaign — 3 new tests cover all-caught, no-mutants-at-all, and uncaught (asserts SystemExit.code == 2 and a summary line is logged)
  • ruff check clean
  • ruff format --check clean

Currently slither-mutate exits 0 even when mutants escape the test
suite, so CI runs cannot tell whether the suite caught everything
without parsing logs. Track campaign-wide totals across files and
exit with EXIT_CODE_UNCAUGHT_MUTANTS (2) when any mutant survives,
keeping the exit code distinct from 1 so CI can tell setup errors
from uncaught mutants.

Closes crytic#2772
@cats2101 cats2101 requested review from bohendo and smonicas as code owners May 4, 2026 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exit with non-zero exit code when there are uncaught mutants

1 participant