swift
d91017be - utils: add a mutation tester for SwiftCompilerSources

Commit
4 days ago
utils: add a mutation tester for SwiftCompilerSources `mutation-tester` checks how well lit tests cover code in the SIL and Optimizer modules of SwiftCompilerSources. It introduces bugs ("mutations") into the source code and checks if the tests detect them. All possible mutations of the given source files are tested. A mutation which is not detected by any test "survives" and is reported. The compiler is built only a single time: each mutation is inserted into the source as a conditional, which is enabled with the `-mutation-test=<id>` option, e.g. ``` if (mutationTest() == 17 ? (!(a < b)) : (a < b)) { ``` Mutations which don't compile are removed by mapping compiler errors back to the mutations. The tests of each mutation are run with `lit --param mutation_test=<id>`, several mutations in parallel. Usage: ``` cd <build-dir> <swift>/utils/mutation-tester --pass copy-sinking <swift>/utils/mutation-tester --file <source-file> --test <test-file-or-dir> ... ``` With `--pass`, the source files of the pass and the tests in test/SILOptimizer which run the pass are found automatically. Mutation kinds: negate conditions, remove negations, flip boolean literals, replace binary operators, change integer literals, remove calls and rotate payload-less cases of switch statements. The tool is an additional target in utils/swift-dev-utils. See utils/swift-dev-utils/Sources/mutation-tester/README.md for details.
Author
Committer
Parents
Loading