-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify.py
More file actions
48 lines (37 loc) · 1.5 KB
/
Copy pathverify.py
File metadata and controls
48 lines (37 loc) · 1.5 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
44
45
46
47
48
"""
Smoke test for 06-validate-gate. See SUITE.md "06 -- validate-gate" for
the required markers this checks. Runs run.py as a subprocess with
explicit argv paths so it observes the REAL gate exit codes -- the
no-args path is a demo only and always exits 0 (see run.py's header).
"""
import os
import subprocess
import sys
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
failures = 0
def run_gate(*paths: str):
proc = subprocess.run(
[sys.executable, os.path.join(THIS_DIR, "run.py"), *paths],
capture_output=True,
text=True,
)
return proc.returncode, proc.stdout + proc.stderr
# bad.inky alone -> exit 1, with distinct rule ids present in the output.
bad_exit, bad_output = run_gate(os.path.join(THIS_DIR, "bad.inky"))
if bad_exit != 1:
print(f"06-validate-gate: expected exit 1 for bad.inky, got {bad_exit}\n{bad_output}", file=sys.stderr)
failures += 1
if "button-no-href" not in bad_output:
print("06-validate-gate: expected rule id 'button-no-href' in output", file=sys.stderr)
failures += 1
if "missing-preheader" not in bad_output:
print("06-validate-gate: expected rule id 'missing-preheader' in output", file=sys.stderr)
failures += 1
# good.inky alone -> exit 0.
good_exit, good_output = run_gate(os.path.join(THIS_DIR, "good.inky"))
if good_exit != 0:
print(f"06-validate-gate: expected exit 0 for good.inky, got {good_exit}\n{good_output}", file=sys.stderr)
failures += 1
if failures > 0:
sys.exit(1)
print("06-validate-gate: ok")