Copy the target tree, or build a small fixture with the same shapes. Run the new script against the copy and inspect what changed.
Trial on | Size | Restore after a mistake |
|---|---|---|
Disposable copy | Small fixture or full copy | Delete and rebuild the copy. |
Live data | Full working tree | Restore from backups, slowly. |
Long inputs are used less reliably than short ones, and material in the middle of a long input gets less use than material at the ends.
This tendency varies by model, so keep trial outputs short and measure it.
A fixture needs one of each shape the script treats differently. Keep-alive files, deletable files and nested directories each earn one entry.
Keep fixtures beside the script under version control. A fixture that drifts from reality stops proving anything.
The program below models a log-cleanup trial over six fixed names. The live tuple is never mutated; only new lists are built.
import sys
LIVE = ("a.sdc", "b.sdc", "top.v", "notes.txt", "run.log", "gold.ref")
def cleanup(files, do_delete):
kept = []
dropped = []
for name in files:
if name.endswith(".log"):
if do_delete:
dropped.append(name)
else:
kept.append(name)
else:
kept.append(name)
return kept, dropped
def main():
bad = 0
copy = list(LIVE)
kept, dropped = cleanup(copy, True)
if dropped != ["run.log"]:
bad += 1
if len(kept) != 5:
bad += 1
if len(list(LIVE)) != 6:
bad += 1
if "run.log" not in LIVE:
bad += 1
if bad:
print("FAIL: copy trial counts wrong")
sys.exit(1)
print("PASS: copy run drops 1 file, live tree keeps 6 files")
main()assume copying the fixture takes 4 s and one trial run takes 6 s (stated example parameters)
one trial costs 4 + 6 = 10 s
three trials cost 3 x 10 = 30 srun.log from a six-file copy. How many files does the copy keep, and what changed in the live tree?The copy keeps five files. The live tree is unchanged at six files.
30 s. Each trial costs 10 s, and three times 10 s is 30 s.