#!/usr/bin/env python3 """mutate_regex.py -- write a copy of the q63 scanner carrying the PRE-FIX population regex, for the non-vacuity cell in CHECK-q150. The mutation is one line: the current rule matches the basename at any depth (`(?:^|/)verify_[^/]*\\.py$`), the pre-Q150 rule required a slash (`/verify_.*\\.py$`). If this helper cannot find the line it exits 2 rather than writing a copy that changes nothing -- a mutant that did not mutate is the vacuous-cell defect wearing the mutant's clothes. Deliberately not sed: the pattern contains `|`, `(`, `)` and `/`, so every delimiter choice is a quoting hazard, and a silently failed substitution here would make the cell pass by not running. """ import sys src, dst = sys.argv[1], sys.argv[2] NEW = 'VERIFY_RE = re.compile(r"(?:^|/)verify_[^/]*\\.py$")' OLD = 'VERIFY_RE = re.compile(r"/verify_.*\\.py$")' text = open(src, encoding="utf-8").read() if NEW not in text: sys.exit("mutate_regex: no post-fix VERIFY_RE line in %s -- cannot mutate" % src) out = text.replace(NEW, OLD, 1) if OLD not in out: sys.exit("mutate_regex: substitution did not land") open(dst, "w", encoding="utf-8").write(out) print("mutant: %s -> %s (pre-fix regex restored)" % (NEW, OLD))