3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-19 14:45:44 +01:00

Mutation-test the source lines a chunk changes with mutation-tests/run.sh

This commit is contained in:
2026-10-28 19:50:00 +01:00
committed by Lillem4n
parent 75ddc2ee17
commit 061ae81644
6 changed files with 2551 additions and 0 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
source ./docker-runner.sh
base=$(git merge-base "${1:-origin/main}" HEAD)
# Each hunk's added lines as path:first-last, in the working tree's numbering; a hunk that only deletes has none to mutate.
mutate=$(git diff -U0 --no-color "$base" -- 'src/*.ts' ':!src/*.test.ts' ':!src/conformance/property-harness.ts' | awk '
/^\+\+\+ / { path = substr($2, 3) }
/^@@ / {
split($3, added, ",")
first = substr(added[1], 2)
count = (2 in added) ? added[2] : 1
if (count > 0) { printf "%s%s:%d-%d", separator, path, first, first + count - 1; separator = "," }
}')
if [ -z "$mutate" ]; then
echo "no source line changed since $base"
exit 0
fi
leg "install ($node_image)" in_image "$node_image" sh -c 'npm ci --no-audit --no-fund && npm ci --no-audit --no-fund --prefix mutation-tests'
leg "mutation tests ($node_image)" in_image "$node_image" mutation-tests/node_modules/.bin/stryker run mutation-tests/stryker.config.mjs --mutate "$mutate"