-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathverify.py
More file actions
59 lines (50 loc) · 1.71 KB
/
Copy pathverify.py
File metadata and controls
59 lines (50 loc) · 1.71 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
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python3
"""Run the async-fetcher contract against the starter or solution."""
from __future__ import annotations
import argparse
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("implementation", choices=("starter", "solution"))
parser.add_argument("--expect-failure", action="store_true")
args = parser.parse_args()
command = [
sys.executable,
"-m",
"unittest",
"discover",
"-s",
str(ROOT / "tests"),
]
environment = os.environ.copy()
environment["PYTHONPATH"] = str(ROOT / args.implementation)
result = subprocess.run(
command,
env=environment,
check=False,
capture_output=args.expect_failure,
text=args.expect_failure,
)
if args.expect_failure:
if result.returncode == 0:
print("Expected the starter to fail, but it passed.", file=sys.stderr)
return 1
output = (result.stdout or "") + (result.stderr or "")
expected_failures = (
"test_bounded_concurrency",
"test_records_exhausted_retries_without_crashing",
"test_retries_transient_failure",
)
if not any(failure in output for failure in expected_failures):
print("Starter failed for an unexpected reason:", file=sys.stderr)
print(output, file=sys.stderr)
return 1
print("Expected concurrency regression reproduced: unbounded execution and lack of retries fail.")
return 0
return result.returncode
if __name__ == "__main__":
raise SystemExit(main())