40 lines
3.3 KiB
Bash
40 lines
3.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Darkwing row 83 round 1 mutants: single-site edits to the candidate in a
|
|
# detached worktree of d13b9300 with build.patch applied by `git apply
|
|
# --index`. Each mutant edits one site with mut.mjs, runs the candidate's
|
|
# service.test.mjs and restores the file from the worktree index.
|
|
# Usage: mutants.sh WORKTREE
|
|
set -u
|
|
WT="$1"
|
|
MUT="$(cd "$(dirname "$0")/../../queue-59-review/r1" && pwd)/mut.mjs"
|
|
S=scripts/webui-service.sh
|
|
cd "$WT" || exit 1
|
|
|
|
m() { # name file from to
|
|
local name="$1" file="$2" from="$3" to="$4"
|
|
if ! node "$MUT" "$file" "$from" "$to"; then echo "$name BAD-SITE"; return; fi
|
|
if (cd packages/webui && node --test tests/service.test.mjs > "$TMPDIR/$name.out" 2>&1); then
|
|
echo "$name SURVIVED"
|
|
else
|
|
echo "$name killed: $(grep -E '^✖ ' "$TMPDIR/$name.out" | grep -v 'failing tests' | sort -u | sed 's/ ([0-9.]*ms)$//' | tr '\n' ';')"
|
|
fi
|
|
git checkout -q -- "$file"
|
|
}
|
|
|
|
# install creates the unit directory before render can refuse.
|
|
m install-mkdir-first $S $' unit="$(render)" || exit 1\n mkdir -p "$UNIT_DIR"\n' $' mkdir -p "$UNIT_DIR"\n unit="$(render)" || exit 1\n'
|
|
# install goes on after a refused render.
|
|
m install-refusal-continues $S $' unit="$(render)" || exit 1\n' $' unit="$(render)" || true\n'
|
|
# the install message drops Mos (decision 102).
|
|
m msg-no-mos $S 'starts and restarts it, or Mos under lead decision 102 (sends then enter the' 'starts and restarts it under lead decision 94 (sends then enter the'
|
|
# the usage text doesn't name --send.
|
|
m usage-no-send $S '--allow-user ID [--send]]"' '--allow-user ID]"'
|
|
# status prints the send line before it checks a unit exists.
|
|
m status-send-before-unit-check $S $' if [ ! -f "$target" ]; then\n echo "healthz: not checked; no unit at $target"' $' grep -q \'^ExecStart=.* --allow-user [^ ][^ ]* --send$\' "$target" 2>/dev/null && echo "send: on (--send; human messages to roles)" || echo "send: off (read-only)"\n if [ ! -f "$target" ]; then\n echo "healthz: not checked; no unit at $target"'
|
|
# status reads the template instead of the installed unit.
|
|
m status-reads-template $S $'--send$\' "$target"; then' $'--send$\' "$TEMPLATE"; then'
|
|
# the --send check runs only once the preview set is complete (inside the block).
|
|
m send-check-inside-block $S $' [ "$SEND" = 0 ] || [ "$preview" -eq 3 ] || die "--send needs the preview mode (--public-host, --auth-header and --allow-user)"\n if [ "$preview" -ne 0 ]; then\n [ "$preview" -eq 3 ] || die "--public-host, --auth-header and --allow-user go together: all three or none"\n' $' if [ "$preview" -ne 0 ]; then\n [ "$preview" -eq 3 ] || die "--public-host, --auth-header and --allow-user go together: all three or none"\n [ "$SEND" = 0 ] || [ "$preview" -eq 3 ] || die "--send needs the preview mode (--public-host, --auth-header and --allow-user)"\n'
|
|
# the append moves inside the preview block (equivalent: the check guarantees it).
|
|
m send-append-inside-block $S $' flags="$flags --public-host $PUBLIC_HOST --auth-header $AUTH_HEADER --allow-user $ALLOW_USER"\n fi\n [ "$SEND" = 0 ] || flags="$flags --send"\n' $' flags="$flags --public-host $PUBLIC_HOST --auth-header $AUTH_HEADER --allow-user $ALLOW_USER"\n [ "$SEND" = 0 ] || flags="$flags --send"\n fi\n'
|