diff --git a/tests/api_shells_mutants.py b/tests/api_shells_mutants.py index 4c05e98788e9ecd861cea635d77cb6e0cf3b8f87..dcb4bfa8508f1c5e2688afced56c9e8993b1852c 100755 --- a/tests/api_shells_mutants.py +++ b/tests/api_shells_mutants.py @@ -54,25 +54,18 @@ def main() -> int: if count != 1: print(f"FAIL mutant {name}: site count {count}") return 1 - with open(full, "w") as fh: - fh.write(src.replace(old, new, 1)) - try: - with tempfile.TemporaryDirectory(prefix="api-shells-mutant-") as out: - env = dict(os.environ, OUT_DIR=out) - r = subprocess.run( - ["bash", script, "regen"], - cwd=ROOT, - env=env, - stdout=subprocess.PIPE, - stderr=subprocess.STDOUT, - text=True, - ) - finally: - with open(full, "w") as fh: - fh.write(src) - if r.returncode == 0: - tail = r.stdout[-400:] - print(f"FAIL mutant {name} survived\n{tail}") + with tempfile.TemporaryDirectory(prefix="api-shells-mutant-") as out: + mutant = os.path.join(out, os.path.basename(path)) + with open(mutant, "w") as fh: + fh.write(src.replace(old, new, 1)) + env = dict(os.environ, OUT_DIR=out, API_SHELLS_MUTANT=mutant) + r = subprocess.run( + ["bash", script, "regen"], cwd=ROOT, env=env, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, + ) + if r.returncode != 1 or "FAIL api-shells checks=" not in r.stdout: + print(f"FAIL mutant {name}: expected a differential mismatch, " + f"got rc={r.returncode}\n{r.stdout[-400:]}") return 1 print(f"KILLED {name} rc={r.returncode}") killed += 1 diff --git a/tests/api_shells_run.sh b/tests/api_shells_run.sh index f57ad1df012fae45deb607fe67ec5a83d9a69241..60977ef0c460ebb713d11142adbfe4416261ce86 100755 --- a/tests/api_shells_run.sh +++ b/tests/api_shells_run.sh @@ -10,7 +10,15 @@ mkdir -p "$OUT" if [[ "${1:-}" == "regen" ]]; then export OMEGA_OMC="${OMEGA_OMC:-$HOME/work/cudastack/omega-mv/seed/out/omc}" export OMEGA_BRIDGE="${OMEGA_BRIDGE:-$HOME/work/cudastack/omega-bridge}" - export OMEGA_UNITS="om/api/apish_shp.om om/api/apish_pack.om om/api/apish_slot.om om/api/apish_blk.om om/api/apish_trit.om" + units=() + for name in shp pack slot blk trit; do + source_file="om/api/apish_$name.om" + if [[ "${API_SHELLS_MUTANT:-}" == */"apish_$name.om" ]]; then + source_file="$API_SHELLS_MUTANT" + fi + units+=("$source_file") + done + export OMEGA_UNITS="${units[*]}" export OMEGA_UNITS_DEST="$OUT/gen" mkdir -p "$OMEGA_UNITS_DEST" bash om/units.sh