48 lines
2.6 KiB
Python
48 lines
2.6 KiB
Python
#!/usr/bin/env python3
|
|
# Row 302 (#1809) mutants, from BUILD.md d3 and d4. Each replaces one exact string, once, in one file.
|
|
# Kill rule: every (test file, failing test name) listed fails in that file's run.
|
|
# mutants.py list | apply M | file M | kills M
|
|
import sys
|
|
|
|
BROKER = "packages/bus/src/broker.mjs"
|
|
RUNNER = "packages/harness/src/runner.mjs"
|
|
ADD = " this.#launcherReleased.add(key);\n"
|
|
|
|
IDLE = ("packages/cli/tests/idle-stop-race.test.mjs", "row 302 REQ-THREAD-2 an idle-released run")
|
|
LR1 = ("packages/bus/tests/launcher-released.test.mjs", "row 302 a run threadIdle released answers launcher-released")
|
|
LR2 = ("packages/bus/tests/launcher-released.test.mjs", "row 302 with a run launcher-released, a run that lost its claim")
|
|
LR3 = ("packages/bus/tests/launcher-released.test.mjs", "row 302 a run landRelease released answers launcher-released")
|
|
LAND = ("packages/bus/tests/land.test.mjs", "landRelease releases the holding run by land-relaunch")
|
|
RUN = ("packages/harness/tests/runner.test.mjs", "a run in a landing turn isn't released for a second held decision")
|
|
|
|
M = {
|
|
"M1": (BROKER, "this.#claimEnd(session, this.#own(session), 'release', null));\n" + ADD,
|
|
"this.#claimEnd(session, this.#own(session), 'release', null));\n", [IDLE, LR1]),
|
|
"M2": (BROKER, "fail(this.#launcherReleased.has(s.business + ':' + s.run) ? 'launcher-released' : 'not-holder');",
|
|
"fail('not-holder');", [IDLE, LR1, LR3, LAND, RUN]),
|
|
"M3": (RUNNER, " if (err.code === LAUNCHER_RELEASED) {", " if (false) {", [IDLE, RUN]),
|
|
"M4": (RUNNER, " released = true;\n return true;", " released = true;\n code = EXIT.session;\n return true;", [IDLE, RUN]),
|
|
"M5": (BROKER, "? 'launcher-released' : 'not-holder')", "? 'launcher-released' : 'launcher-released')", [IDLE, LR2]),
|
|
"M7": (BROKER, " if (this.#launcherReleased.has(s.business + ':' + s.run)) fail('launcher-released');\n", "", [LR1, LR3]),
|
|
"M8": (BROKER, "'land-relaunch'));\n" + ADD, "'land-relaunch'));\n", [LR3, LAND, RUN]),
|
|
"M9": (RUNNER, "if (code === EXIT.stopped && !released) {", "if (code === EXIT.stopped) {", [IDLE]),
|
|
}
|
|
|
|
cmd = sys.argv[1]
|
|
if cmd == "list":
|
|
print(" ".join(M))
|
|
elif cmd == "file":
|
|
print(M[sys.argv[2]][0])
|
|
elif cmd == "kills":
|
|
for f, name in M[sys.argv[2]][3]:
|
|
print(f + "\t" + name)
|
|
elif cmd == "apply":
|
|
path, old, new, _ = M[sys.argv[2]]
|
|
s = open(path).read()
|
|
if s.count(old) != 1:
|
|
sys.exit(f"{sys.argv[2]}: anchor found {s.count(old)} times in {path}")
|
|
open(path, "w").write(s.replace(old, new))
|
|
print(path)
|
|
else:
|
|
sys.exit("usage: mutants.py list|apply M|file M|kills M")
|