interplane-forge
INTERPLANE Forge
Brought by drakestapleton
interplane-forge / server / tests / counts-mutants.sh
| 1 | #!/usr/bin/env bash |
| 2 | # server/tests/counts-mutants.sh: negative controls for server/tests/counts.sh. Each mutant breaks one |
| 3 | # rule of server/json.om / server/counts.om in the composed test copy (FORGE_TEST_MUTANT, a sed |
| 4 | # script); counts.sh must FAIL on every one. Prints KILLED or SURVIVED per mutant; exit 0 only when |
| 5 | # all are killed. Same cores and ports as counts.sh, one run after another. |
| 6 | set -u |
| 7 | cd "$(dirname "$0")/../.." |
| 8 | names=(own-filter-off bot-filter-off cursor-ignored no-journal-cursor accept-ignores-html status-ignored suffix-skips-allow-list no-tail-trim since-before-cursor) |
| 9 | muts=( |
| 10 | 's/^if fzown add p1 1 p2$/if eq ulong 1 ulong 0/' |
| 11 | 's/^if fzua ue e$/if eq ulong 1 ulong 0/' |
| 12 | 's/^f = get fzoff s$/f = ulong 0/' |
| 13 | 's/^fzjc 107$/fzjc 120/' |
| 14 | 's/^ret not fjhas tfjth$/ret true/' |
| 15 | 's/^if ne fznum add q2 2 e 200$/if eq ulong 1 ulong 0/' |
| 16 | '/^fn fjsfx /,/^ret 200$/ s/^if not fsetrepo$/if eq ulong 1 ulong 0/' |
| 17 | 's/^if gt ulong sz get fzjend 0$/if eq ulong 1 ulong 0/' |
| 18 | 's/^put fzspen s fznum add a 4 e$/put fzsnc s fznum add a 4 e/' |
| 19 | ) |
| 20 | killed=0; survived=0 |
| 21 | for k in "${!muts[@]}"; do |
| 22 | out=$(FORGE_TEST_MUTANT=${muts[$k]} bash server/tests/counts.sh 2>&1); rc=$? |
| 23 | if [ "$rc" -ne 0 ] && ! echo "$out" | grep -q '^MUTANT did not apply'; then |
| 24 | killed=$((killed+1)); echo "KILLED ${names[$k]} (rc $rc): $(echo "$out" | grep -m2 '^FAIL' | tr '\n' ' ' | cut -c1-240)" |
| 25 | else |
| 26 | survived=$((survived+1)); echo "SURVIVED ${names[$k]} (rc $rc) $(echo "$out" | grep -m1 'MUTANT')" |
| 27 | fi |
| 28 | done |
| 29 | echo "counts-mutants: $killed killed, $survived survived" |
| 30 | [ "$survived" = 0 ] |