Expand description
The static half of mutation testing: mutant selection, test mapping, pruning and ranking. The static half of mutation testing: select, map, prune and rank mutants.
The plan reads only facts that the dead-code analysis already has: the
module graph with its test reachability (including the vi.mock
replacement masks), the dead-code results, the function complexity of each
module, and the captured security sink sites. It reads the source text of
each selected file one time to instrument it, and it holds the
instrumented code in memory. It never writes a file and never runs user
code.
Each mutant gets one disposition:
planned: a test file reaches the file, and no static rule prunes the mutant. The runner executes these mutants in rank order.pending: a planned mutant after themax_mutantslimit.no-coverage: no test file reaches the file in the graph. A test that replaces the module withvi.mockdoes not reach it.pruned: a static rule removes the mutant (seePruneReason).
Structs§
- Diff
Index - Parsed, command-neutral index of files and added lines in a unified diff.
- Framework
Config Exports - Framework config exports, by root-relative file path.
- Function
Facts - The facts of the function that contains a mutant.
- Function
Ref - The function that contains a mutant.
- Mutant
- One mutant.
- Mutant
Id - The stable identity of a mutant: 16 lowercase hex digits.
- Mutant
Test Reach - How tests reach the code of one mutant, from the module graph.
- Mutation
Plan - The static mutation plan.
- Mutation
Plan Counts - The number of mutants for each disposition.
- Mutation
Plan Inputs - The analysis facts that a plan reads.
- Mutation
Plan Request - What to plan.
- Planned
File - One file that the runner loads in its instrumented form.
- Planned
Mutant - One mutant of the plan.
- Prune
Counts - The number of pruned mutants for each reason.
- Skipped
File - A selected file that the plan did not instrument.
Enums§
- Mutant
Disposition - The status of a mutant in a plan.
- Mutation
Error - An error from
instrument. - Mutation
Plan Error - An error from
plan_mutations_for_session. - Mutation
Scope - The files and lines that a plan mutates.
- Operator
- One mutation operator.
- Prune
Reason - Why a static rule removes a mutant.
- Skip
Reason - Why the plan did not instrument a selected file.
- Source
Kind - The language of a source text.
Constants§
- RESERVED_
PREFIX - The name prefix that the instrumentation reserves.
- RUNNER_
CONFIG_ MODULES - The runner config modules at the project root. Each test run loads them,
so they and the files that they reach through static imports are in
MutationPlan::support_files.
Functions§
- instrument_
source - Instruments a source file of any layout that
fallow mutationsupports: JavaScript, TypeScript, and the script blocks of Vue, Svelte and Astro components. ReturnsNonefor another file type. - is_
component_ file - True when
pathis a Vue, Svelte or Astro component file, whose code is in script blocks. A Svelte module file (.svelte.ts) is not a component file. - plan_
mutations - Builds the mutation plan from the facts of one analysis.
- plan_
mutations_ for_ session - Runs the dead-code analysis of
sessionwith complexity and the graph, then builds the mutation plan. - plan_
mutations_ for_ session_ with - Like
plan_mutations_for_session, butskip_componentsreads the first plan and decides if the component files leave the plan. The test runner can depend on the test files of the plan, so the caller decides after the first plan. When the first plan has a component mutant andskip_componentsreturns true, the plan is built again from the same analysis withMutationPlanRequest::skip_component_filesset.