-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_all.py
More file actions
43 lines (34 loc) · 1.31 KB
/
Copy pathrun_all.py
File metadata and controls
43 lines (34 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
"""
Runs every example in examples/*/run.py, in order.
--verify additionally checks each example's required output markers.
"""
import glob
import os
import subprocess
import sys
ROOT = os.path.dirname(os.path.abspath(__file__))
def main() -> int:
verify = "--verify" in sys.argv[1:]
failures = 0
scripts = sorted(glob.glob(os.path.join(ROOT, "examples", "*", "run.py")))
for script in scripts:
name = os.path.basename(os.path.dirname(script))
print(f"\n=== {name} ===")
proc = subprocess.run([sys.executable, script])
if proc.returncode != 0 and name != "06-validate-gate":
# 06 demonstrates a failing gate on purpose; its run.py manages
# its own exit codes (see its header comment).
print(f"FAILED: {name} (exit {proc.returncode})", file=sys.stderr)
failures += 1
continue
if verify:
check = os.path.join(os.path.dirname(script), "verify.py")
if os.path.isfile(check):
vproc = subprocess.run([sys.executable, check])
if vproc.returncode != 0:
print(f"VERIFY FAILED: {name}", file=sys.stderr)
failures += 1
return 0 if failures == 0 else 1
if __name__ == "__main__":
sys.exit(main())