58 lines
4.4 KiB
Bash
Executable File
58 lines
4.4 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Row 56 mutants: each line applies one perl substitution to one file, runs
|
|
# the packages/runs tests, and expects a failure (killed). Restores after.
|
|
cd /mnt/storage/scratch/rocko-r56/r2 || exit 4
|
|
G=/mnt/storage/scratch/rocko-r56/gate2
|
|
: > "$G/mutants.txt"
|
|
mut() { # id file perl-expr
|
|
local id="$1" f="$2" e="$3"
|
|
cp "$f" "$f.orig"
|
|
perl -0pi -e "$e" "$f"
|
|
if cmp -s "$f" "$f.orig"; then echo "$id NOT-APPLIED" >> "$G/mutants.txt"; mv -f "$f.orig" "$f"; return; fi
|
|
if timeout 300 env -u NODE_TEST_CONTEXT node --test 'packages/runs/tests/*.test.mjs' > "$G/mut-$id.log" 2>&1; then
|
|
echo "$id SURVIVED" >> "$G/mutants.txt"
|
|
else
|
|
echo "$id killed" >> "$G/mutants.txt"
|
|
fi
|
|
mv -f "$f.orig" "$f"
|
|
}
|
|
P=packages/runs/src/paths.mjs; R=packages/runs/src/runs.mjs; S=packages/runs/src/state.mjs; T=scripts/mosaic-task.mjs
|
|
mut M01 $P 's/return relative === "" \|\|/return true ||/'
|
|
mut M02 $P 's/relative !== "\.\." && //'
|
|
mut M03 $P 's/startsWith\(`\.\.\$\{path\.sep\}`\)/startsWith("..x")/'
|
|
mut M04 $P 's/ && !path\.isAbsolute\(relative\)\)/)/'
|
|
mut M05 $P 's/ && !Array\.isArray\(value\) \? value/ ? value/'
|
|
mut M06 $P 's/error\?\.code === "ENOENT" \|\| error\?\.code === "ENOTDIR"/error?.code === "ENOENT"/'
|
|
mut M07 $P 's/if \(isMissing\(error\)\) return null;\n throw new RunsError\(`cannot resolve/return null;\n throw new RunsError(`cannot resolve/'
|
|
mut M08 $P 's/if \(!isInside\(root, real\)\)/if (false)/'
|
|
mut M09 $R 's/filter\(\(name\) => name\.startsWith\("r-"\)\)\.sort\(\)/filter((name) => name.startsWith("r-"))/'
|
|
mut M10 $R 's/filter\(\(name\) => name\.startsWith\("r-"\)\)/filter(() => true)/'
|
|
mut M11 $R 's/if \(isMissing\(error\)\) return \[\];\n throw/return [];\n throw/'
|
|
mut M12 $R 's/if \(!RUN_DOCUMENTS\.includes\(name\)\) throw/if (false) throw/'
|
|
mut M13 $R 's/export function readRunRecord\(dataRoot, runId\) \{\n requireRunId\(runId\);/export function readRunRecord(dataRoot, runId) {/'
|
|
mut M14 $R 's/if \(resolveInside\(dataRoot, RUNS_DIRNAME\) === null\) return null;\n//'
|
|
mut M15 $R 's/if \(isMissing\(error\)\) return null;\n throw new RunsError\(`cannot read \$\{dir\}/return null;\n throw new RunsError(`cannot read ${dir}/'
|
|
mut M16 $R 's/RUN_ID_PATTERN = \/\^r-/RUN_ID_PATTERN = \/r-/'
|
|
mut M17 $S 's/if \(!POINTER_KEYS\.includes\(key\)\) throw/if (false) throw/'
|
|
mut M18 $S 's/if \(pointer\.pointerVersion !== 1\)/if (false)/'
|
|
mut M19 $S 's/new RunsError\(`release pointer \$\{why\} \(\$\{state\.file\}\)`, 2\)/new RunsError(`release pointer ${why} (${state.file})`)/'
|
|
mut M20 $S 's/if \(Object\.keys\(entry\)\.some\(\(key\) => !LOG_KEYS\.includes\(key\)\)\) return null;//'
|
|
mut M21 $S 's/if \(entry\.note !== undefined && typeof entry\.note !== "string"\) return null;//'
|
|
mut M22 $S 's/entries\.slice\(-last\)/entries.slice(0, last)/'
|
|
mut M23 $S 's/if \(line\.trim\(\) === ""\) continue;//'
|
|
mut M24 $S 's/if \(last !== undefined && \(!Number\.isInteger\(last\) \|\| last < 1\)\)/if (false)/'
|
|
mut M25 $S 's/ throw new RunsError\(`cannot read \$\{file\}/ return null; throw new RunsError(`cannot read ${file}/'
|
|
mut M26 $S 's/if \(!isNonEmptyString\(pointer\[key\]\)\)/if (pointer[key] === undefined)/'
|
|
mut M27 $S 's/\["at", "event", "release", "imageTag"\]\.every/["event"].every/'
|
|
mut M28 $T 's/ if \(result\) \{\n status = result\.status;/ if (true) {\n status = result.status;/'
|
|
mut M29 $T 's/ if \(record === null\) \{\n fail\(4, `run not found/ if (false) {\n fail(4, `run not found/'
|
|
mut M30 $T 's/if \(error instanceof RunsError\) fail\(error\.exitCode, error\.message\);/if (false) fail(error.exitCode, error.message);/'
|
|
mut M31 $T 's/ if \(!isRunId\(runId\)\) \{\n fail\(4, `invalid run id/ if (false) {\n fail(4, `invalid run id/'
|
|
mut M32 $T 's/artifacts\.join\(", "\)/artifacts.join(",")/'
|
|
mut D17 $R 's/result: readJsonObject\(dataRoot, RUNS_DIRNAME, runId, "result\.json"\)/result: readRunDocument(dataRoot, runId, "result.json")/'
|
|
mut D20 $R 's/names\.filter\(\(name\) => name\.startsWith\("r-"\)\)/names.filter((name) => name.startsWith("r-") \&\& isRunId(name))/'
|
|
mut D22 $S 's/\["at", "event", "release", "imageTag"\]\.every/["at", "event", "release"].every/'
|
|
mut N2 $S 's/\["at", "event", "release", "imageTag"\]\.every/["at", "event", "imageTag"].every/'
|
|
mut S1 $S 's/if \(file === null\) return null;\n try \{\n return \{ file, text/if (file === null) throw new RunsError("x");\n try {\n return { file, text/'
|
|
echo done >> "$G/mutants.txt"
|