Skip to content

Fix #43: Code evaluated only at compile time is never mutated, and the run doesn't say so - #68

Merged
lefticus merged 4 commits into
cpp-best-practices:mainfrom
leftibot:fix/issue-43-code-evaluated-only-at-compile-time-is-n
Nov 22, 2026
Merged

lefticus merged 4 commits into
cpp-best-practices:mainfrom
leftibot:fix/issue-43-code-evaluated-only-at-compile-time-is-n

Conversation

@leftibot

Copy link
Copy Markdown
Contributor

Automated fix by @leftibot.

What changed

Fix #43: report code evaluated only at compile time, and mutate it with --compile-time
strain mutated only lines gcov counted as executed, so constexpr/consteval functions used only in constant
expressions (static_assert, template arguments, constexpr initialisers) were never mutated, and nothing said so.
The runner now finds those functions' unexecuted lines with operators and lists them as "not mutated: evaluated at
compile time only", with a count in the console summary and summary.md. With --compile-time it mutates them too: a
mutant whose only compiler errors are failed static_asserts or constant evaluations is killed_at_compile_time (scored
as a detection and remembered in the build cache), while any other error keeps it a compile_error.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

Files

 strain/build.py            |   9 ++--
 strain/build_cache.py      |  48 +++++++++++++++-----
 strain/cli.py              |   6 +++
 strain/compile_time.py     | 111 +++++++++++++++++++++++++++++++++++++++++++++
 strain/console.py          |   1 +
 strain/report.py           |  15 ++++--
 strain/results.py          |   5 +-
 strain/runner.py           |  88 +++++++++++++++++++++++++++++------
 strain/tui.py              |   7 ++-
 tests/test_build_cache.py  |  10 ++++
 tests/test_compile_time.py |  83 +++++++++++++++++++++++++++++++++
 tests/test_console.py      |   2 +-
 tests/test_end_to_end.py   |  65 ++++++++++++++++++++++++++
 13 files changed, 415 insertions(+), 35 deletions(-)

Closes #43

Triggered by @lefticus.

…, and mutate it with --compile-time

strain mutated only lines gcov counted as executed, so constexpr/consteval functions used only in constant
expressions (static_assert, template arguments, constexpr initialisers) were never mutated, and nothing said so.
The runner now finds those functions' unexecuted lines with operators and lists them as "not mutated: evaluated at
compile time only", with a count in the console summary and summary.md. With --compile-time it mutates them too: a
mutant whose only compiler errors are failed static_asserts or constant evaluations is killed_at_compile_time (scored
as a detection and remembered in the build cache), while any other error keeps it a compile_error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lefticus

Copy link
Copy Markdown
Member

@leftibot fix the errors

@leftibot

leftibot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ leftibot finished addressing the review feedback.

leftibot and others added 2 commits November 22, 2026 11:11
…tting

The tests from cpp-best-practices#61 and cpp-best-practices#62, merged into main, disagreed about the project's
name: the code prints "mutant_strain" and installs the `mutant_strain` command,
so the summary, Textual warning and wheel entry-point tests now expect that, and
the distribution test compares PyPI-normalised names (`mutant-strain` is the
published name). Also adds the blank line ruff format wants in
tests/test_end_to_end.py.

Requested by @lefticus in PR cpp-best-practices#68 review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Splits the scheduling options out of _add_selection_arguments, the mutant
planning out of Runner.run_test, and the group, brace and declaration checks
out of compile_time._body_start.

Requested by @lefticus in PR cpp-best-practices#68 review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leftibot

Copy link
Copy Markdown
Contributor Author

Addressed review feedback from @lefticus. New commits:

35296a1 Address review: keep functions within lizard's 30-line limit
b4cc8aa Address review: align tests with the mutant_strain name and fix formatting

@lefticus

Copy link
Copy Markdown
Member

@leftibot still have failing tests

@leftibot

leftibot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor Author

✅ leftibot finished addressing the review feedback.

…ime end-to-end test

On macOS, Clang reports "static assertion failed due to requirement '...'",
so the cached detail no longer matched the GCC-only literal. The test now
matches either form.

The project validator job also fails, on fuzz-testing, status-badges and
type-checking. Those checks fail on main too and are outside this PR.

Requested by @lefticus in PR cpp-best-practices#68 review.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leftibot

Copy link
Copy Markdown
Contributor Author

Addressed review feedback from @lefticus. New commits:

de0d470 Address review: accept Clang's static_assert message in the compile-time end-to-end test

@lefticus
lefticus merged commit 1ba2667 into cpp-best-practices:main Nov 22, 2026
11 of 12 checks passed
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.

Code evaluated only at compile time is never mutated, and the run doesn't say so

2 participants