omnet
aien-dev/omnet
Brought by drakestapleton
omnet / om / tka / test / check.py
| 1 | #!/usr/bin/env python3 |
| 2 | """A mutant must complete normally with exactly the expected record count.""" |
| 3 | import pathlib |
| 4 | import sys |
| 5 | |
| 6 | want = pathlib.Path(sys.argv[1]).read_text().splitlines() |
| 7 | got = pathlib.Path(sys.argv[2]).read_text().splitlines() |
| 8 | if len(want) != len(got): |
| 9 | for i, (a, b) in enumerate(zip(want, got)): |
| 10 | if a != b: |
| 11 | print(f"first difference record {i + 1}: expected {a[:240]}, got {b[:240]}") |
| 12 | break |
| 13 | raise SystemExit(f"FAIL record count: expected {len(want)}, got {len(got)}") |
| 14 | bad = [i for i, pair in enumerate(zip(want, got)) if pair[0] != pair[1]] |
| 15 | if sys.argv[3] == "mutant": |
| 16 | if not bad: |
| 17 | raise SystemExit("FAIL mutant survived") |
| 18 | print(f"PASS mutant: completed {len(got)} records, {len(bad)} differ") |
| 19 | else: |
| 20 | if bad: |
| 21 | for i in bad[:10]: |
| 22 | print(f"record {i + 1}: expected {want[i][:240]}, got {got[i][:240]}") |
| 23 | raise SystemExit(f"FAIL {len(bad)} differing records") |
| 24 | print(f"PASS {len(got)} differential records") |