Repository navigation
Conversation
gcov counts what runs, so a constexpr or consteval function checked only by static_assert has no executed lines and was never mutated. A header used only that way isn't even in the coverage data. The new strain/compile_time.py finds constexpr and consteval function bodies with the lexer, skipping variables, declarations, lambdas and `if constexpr`. - By default, the lines of those functions that hold mutants but that no test runs are listed under "Not mutated: evaluated at compile time only": on the console, in summary.md and index.html, and as compileTimeOnly in report.json. The error for a run with no mutants points at them too. - With --compile-time, strain mutates those lines after the tests and builds everything with each mutant. A failed static_assert or constant evaluation kills it as the new killed_at_compile_time state, which counts as detected. A mutant that builds survives, with a hint to add a static_assert. Invalid code stays compile_error. - Any build or -fsyntax-only check that fails on a compile-time check now counts as killed_at_compile_time, using GCC's and Clang's diagnostics. The build cache keeps the description, so a cached failure keeps its state. Diagnostic paths are made relative to the project. - The TUI header and the Mutants filters use the short state labels, so the totals fit beside the timing. Fixes #43. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On macOS the compiler reports /var/folders/... while strain resolves the source folder to /private/var/folders/..., so the plain prefix replacement left the paths long. Any absolute path in a diagnostic that resolves into the project is now made relative to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lefticus
force-pushed
the
fix/issue-42-cheapest-first-eta
branch
from
November 18, 2026 03:56
d2b3b3c to
59d42b1
Compare
lefticus
force-pushed
the
fix/issue-43-compile-time-code
branch
from
November 18, 2026 03:56
05c4940 to
283f437
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #43. Stacked on #51 (#42), which is stacked on #50 and #48. Merge those first; GitHub retargets each PR as its base merges.
The gap
gcov counts what runs. I checked on a small project: a header whose
constexprandconstevalfunctions are used only instatic_asserts doesn't appear in the coverage data at all. strain mutates only executed lines, so it never looked at that code, and nothing said so.What changes
strain/compile_time.pyfindsconstexprandconstevalfunction bodies with strain's lexer. It skipsconstexprvariables, brace-initialised objects, declarations without a body, lambdas assigned to variables,if constexpr, and comments; it handlesoperator=and nested lambdas. strain walks the project's C++ sources and headers, skipping the build folder, dot-folders, test code andexcludepatterns, and reads only files that mentionconstexprorconsteval. The lines no test ran come from the union of every baseline's coverage.By default, a new section lists the lines of those functions that hold mutants but that no test runs:
It appears on the console, in
summary.mdandindex.html, and ascompileTimeOnlyinreport.json. If a run has no mutants at all, the error now points at these lines and at--compile-time.With
--compile-time, strain mutates those lines after the tests, builds everything with each mutant, and restores the source. A new phase, "compile-time checks", appears in the log and the TUI.killed_at_compile_time(new state, counted as detected): astatic_assertor a constant evaluation failed. The detail names the failed check.survived: the mutant builds, so no compile-time check caught it, and no test runs the line. The hint says "add a static_assert where<and<=give different results".compile_error: invalid code, as before.Any mutant, not only with
--compile-time: when-fsyntax-onlyor the build fails, its diagnostics decide the state. A failed compile-time check meanskilled_at_compile_time; anything else stayscompile_error. A failedstatic_assertis a real detection wherever the mutated line is, and-fsyntax-onlyevaluatesstatic_asserts too. This changes results: mutants thatstatic_asserts catch used to be excluded from the score as compile errors.static assertion failed,non-constant condition for static assertionand… is not a constant expression, which I checked against g++ here.static assertion failed due to requirement,static_assert expression is not an integral constant expressionandmust be initialized by a constant expression. The macOS CI runners (Apple Clang) producedstatic assertion failed due to requirement 'clamp_index(-1, 4) == 0'and classified it correctly. The other two Clang messages come from its documentation, not from a run.Build cache: it stores the description (
killed at compile time: …), so a cached failure keeps its state, as the issue suggested. Diagnostic paths are made relative to the project.TUI: the new state's short label is
constexpr. The header totals and the Mutants filters now use the short labels (sanitizer,memory,constexpr,no build). With full names, the totals ran into the timing:README: a "Compile-time code" section, a row in the result states table, the score formula and the CLI table.
This also covers the "lines not covered at runtime" group from #44 (#52): they get their own section instead of mixing with survivors.
Tests
clamp_index, checked only bystatic_asserts, andfirst_of, where a*→/mutant makesconst Value *startinvalid code.summary.mdandreport.json. No header mutant is run.--compile-time, I worked out each state by hand:<→>=,>=→<and-→+arekilled_at_compile_time;<→<=and>=→>survive, since nostatic_assertsits at 0 or at the size;*→/stayscompile_error. The failed check is named, and the survivors get thestatic_asserthint.tests/test_compile_time.py:noexcept,if constexpr, variables, brace initialisation, declarations, lambdas,operator=, nested lambdas and comments;NotMutatedwith line ranges.--compile-time.python -W error -m pytest: 288 passed, 9 skipped.ruff format --check,ruff checkand lizard are clean.🤖 Generated with Claude Code