#!/bin/bash # Each mutant edits one source file in the build worktree, runs the tasks tests, then restores # the file from the worktree index (the candidate). Expect every mutant to fail at least one test. # The tasks tests run for each mutant; the cli tests too for the config.mjs one. export TMPDIR=~/darkwing-scratch/r62/tmp cd ~/darkwing-scratch/r62/build S=packages/tasks/src/sync.mjs; U=packages/tasks/src/startup.mjs run() { # name file sed-expr [test glob] sed -i "$3" "$2" if git diff --quiet -- "$2"; then echo "$1: MUTATION DID NOT APPLY"; return; fi node --test "${4:-packages/tasks/tests/*.test.mjs}" > ~/darkwing-scratch/r62/tmp/mut-$1.log 2>&1 echo "$1: rc=$? $(grep -E '^ℹ (pass|fail) ' ~/darkwing-scratch/r62/tmp/mut-$1.log | tr '\n' ' ')" grep -E '^not ok|^# Subtest|✖ ' ~/darkwing-scratch/r62/tmp/mut-$1.log | grep -v '^ℹ' | sed 's/^/ /' | sort -u | head -8 git checkout -q -- "$2" } run no-leave-tree-check $S 's/} else if (!ctx.tree.has(project)) {/} else if (false) {/' run no-watch-only-bucket $S 's/^const fieldsFor = .*/const fieldsFor = (task, bucket) => taskFields(task, bucket);/' run placed-by-id $S 's/placed.add(ref(project, id));/placed.add(id);/; s/.filter((r) => !placed.has(r));/.filter((r) => !placed.has(parseRef(r).task));/' run keep-archived $U 's/if (p.is_archived || p.id === ctx.project) continue;/if (p.id === ctx.project) continue;/' run config-drops-descendants packages/cli/src/config.mjs 's/ descendants: v\["tracker.descendants"\],/ descendants: false,/' 'packages/cli/tests/*.test.mjs' git diff --quiet -- $S $U packages/cli/src/config.mjs && echo "restored: sources match the candidate index"