Skip to content

Filters

Applying mutation testing onto existing large project might be overwhelming at first since Mull would generate a lot of mutants.

Mull provides several filters enabling precise control over what is being mutated.

File path filter allows selection of which files to enable or disable. This is useful in cases when you want to start incrementally with handful of modules, or to ignore irrelevant files such as third-party modules.

To enable this filter add the needed flags to the config, e.g.:

mull.yml
excludePaths:
- .*testutil.*
- .*third-party.*

Alternatively, enable a single module, e.g. encoder.c and encoder.h:

mull.yml
includePaths:
- .*encoder.*

In some cases even a single file may produce too many mutants, or there might be a case when a mutant can’t be easily killed by the test suite.

In such cases, you may disable certain parts of the code via manual annotations, such as mull-on/mull-off or more precise ones mull-ignore or mull-ignore-next:

main.c
// disable all mutations from mull-off till mull-on
// mull-off
int ignore_all(int a, int b) {
return a + b;
}
// mull-on
// disable cxx_add_to_sub from mull-off till mull-on
// mull-off: cxx_add_to_sub
int ignore_some(int a, int b, int c) {
return a + b - c;
}
// mull-on
// disable all mutations till the end of file
// mull-off
int ignore_till_eof(int a, int b, int c) {
return a + b - c;
}

See more examples in the Disable mutants with annotations guide.

This filter is especially useful in the CI context when you only want to generate mutants for the code relevant to a pull request.

To enable it, simply add the following to the config:

mull.yml
gitDiffRef: main
gitProjectRoot: .

See more examples in the Diff-based mutations guide.

Code coverage is another useful filter, it is often makes sense to only generate mutants for the code which is actually reachable during a test run.

The coverage filter can be enabled indirectly: simply enable profiling during compilation and Mull will do the rest.

Terminal window
clang-22 \
-fpass-plugin=/usr/lib/mull-ir-frontend-22 \
-g -grecord-command-line \
-fprofile-instr-generate -fcoverage-mapping \
main.c

See CMake Integration: fmtlib guide for an example.