Files
stack/agents/darkwing/work/queue-53-review/r3/mut/mutate.py
T

27 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Round 3 mutants: exact text, must match once. Run from the worktree root.
import sys
A = "packages/webui/src/public/app.js"
CLOSE = "if (conv) { $('conv-log').replaceChildren(); closeConversation(); }"
M = {
"R01": [(A, " " + CLOSE, "")],
"R02": [(A, CLOSE, "if (conv) { closeConversation(); }")],
"R03": [(A, CLOSE, "if (conv) { $('conv-log').replaceChildren(); showConversation(false); }")],
"R04": [(A, " if (!data) {\n const why", " if (refused) {\n const why")],
"R05": [(A, " for (const id of ['waiting', 'seen', 'sessions']) $(id).replaceChildren();\n", "")],
"R06": [(A, "for (const id of ['waiting', 'seen', 'sessions'])", "for (const id of ['waiting', 'sessions'])")],
"R07": [(A, "for (const id of ['waiting', 'seen', 'sessions'])", "for (const id of ['seen', 'sessions'])")],
"R08": [(A, "for (const id of ['waiting', 'seen', 'sessions'])", "for (const id of ['waiting', 'seen'])")],
"R09": [(A, " for (const id of ['waiting-count', 'seen-count', 'session-count']) $(id).textContent = '–';\n", "")],
"R10": [(A, "$('footer').textContent = `Board not read: ${refused ? 'refused' : 'the read failed'}`;", "$('footer').textContent = 'Board not read: refused';")],
"R11": [(A, "const why = refused ? 'the board refused the read' : 'the read failed';", "const why = 'the board refused the read';")],
"R12": [(A, " inspect();\n }\n $('error').className", " }\n $('error').className")],
"R13": [(A, "if (refused) { data = null; selected = null; project = null;", "if (refused) { data = null; selected = null;")],
"R14": [(A, "if (refused) { data = null; selected = null; project = null;", "if (refused) { data = null; project = null;")],
}
for f, old, new in M[sys.argv[1]]:
s = open(f).read()
n = s.count(old)
if n != 1: sys.exit(f"{sys.argv[1]}: {n} matches in {f}")
open(f, "w").write(s.replace(old, new))
print(sys.argv[1], "applied")