37 lines
1.7 KiB
Bash
Executable File
37 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
||
# Row 107 (#1601) N1: the retry-order test must fail when the privileged-add gate-owner
|
||
# check is hoisted above step 3 (the step that answers a recorded op with its receipt).
|
||
# Runs only gate-owner.test.mjs, twice, in the given worktree:
|
||
# control real store.mjs -> passes
|
||
# mutant the check block moved above step 3 -> the retry test fails
|
||
# Usage: n1-mutant.sh <worktree> <outdir> Restores store.mjs on exit.
|
||
set -u
|
||
WT=$(cd "$1" && pwd); OUT=$(mkdir -p "$2" && cd "$2" && pwd)
|
||
S=packages/queue/src/store.mjs; T=packages/queue/tests/gate-owner.test.mjs
|
||
cd "$WT" || exit 2
|
||
BAK=$(mktemp -d "$OUT/.bak.XXXXXX")
|
||
cp "$S" "$BAK/store"
|
||
restore() { cp "$BAK/store" "$S"; rm -rf "$BAK"; }
|
||
trap restore EXIT
|
||
hoist() { node -e '
|
||
const fs = require("fs"), f = process.argv[1];
|
||
let s = fs.readFileSync(f, "utf8");
|
||
const start = s.indexOf(" if (verb === \"add\" && PRIVILEGED.has(actor) && cargs.gateOwner === null) {");
|
||
if (start < 0) process.exit(3);
|
||
const end = s.indexOf(" }\n", start) + " }\n".length;
|
||
const block = s.slice(start, end);
|
||
s = s.slice(0, start) + s.slice(end);
|
||
const anchor = " const prior = cur.doc.log.find((e) => e.op === op);\n";
|
||
if (!s.includes(anchor)) process.exit(4);
|
||
fs.writeFileSync(f, s.replace(anchor, block + anchor));
|
||
' "$S"; }
|
||
run() { # name
|
||
setsid -w timeout -k 10 240 node --test "$T" > "$OUT/$1.out" 2>&1; echo "$?" > "$OUT/$1.rc"
|
||
echo "$1: exit $(cat "$OUT/$1.rc"); $(grep -E '^ℹ (tests|pass|fail)' "$OUT/$1.out" | tr '\n' ' ')"
|
||
}
|
||
run control
|
||
hoist || { echo "hoist edit failed ($?)"; exit 3; }
|
||
git diff -- "$S" > "$OUT/mutant.patch"
|
||
run mutant
|
||
grep -E '^✖|not ok' "$OUT/mutant.out" | head
|