Expand description
bynk test --mutate (#3069): check that the suites would notice a small
change to the code.
The run applies one mutation at a time to a project’s own sources, runs the suites that exercise the mutated unit, and reports the mutants no suite failed on, each with its source span. A surviving mutant is a gap in the suites, not a bug in the code.
How a mutant is made. Sites are found in the lexed source of every
non-suite file, inside the declaration items the parser delimits, so each
site knows its unit and declaration. The mutant is the file’s text with one
operator token replaced, handed to an ordinary in-process bynk test run as
an in-memory source overlay (TestArgs::mutant_overlay); nothing is
written under the project, and the emitted output goes to a scratch
directory. A mutant that does not compile is invalid and left out of the
score, so a mutant is only ever “killed” by a suite that built and failed.
Which suites run. The suites that target the mutated unit, or a unit
that (transitively) uses it, or that themselves uses it. A mutant no
suite reaches is no suite: reported, never run, and not scored.
The first slice mutates comparison operators (<↔<=, >↔>=,
==↔!=) and boolean connectives (&&↔||).
Structs§
- Model
- What the project’s files say about how units relate.
- Mutate
Args - What
bynk test --mutatewas asked to do. - Site
- One place a mutation applies.
Functions§
- apply
textwith the site’s operator replaced.- build_
model - Lex and parse every file in
sources, collecting the unit graph and the mutation sites of the non-suite files. A file that does not parse contributes nothing (the baseline run fails first on it). - run
- Run
bynk test --mutate. - sql_
mutations - The mutations inside one string literal’s source text (quotes included),
as
(start, end, from, to)offsets into it. The caller has established that the literal is SQL (the checker ties it to a D1 call: seebuild_model); the scan runs on the literal’s decoded text, so an escape such as\nis the newline it stands for, and is mapped back to the source span it came from. Three kinds: a comparison<↔<=,>↔>=;max(↔min(; and, in aWHEREof two or moreANDconjuncts, dropping one conjunct (tois empty). ACASE … ENDis one unit, never split. The result is only text: a mutant the checker’s SQL check refuses isinvalid.