File size: 1,752 Bytes
24aaa76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Runs every test file of r5eval (J2's unchanged scorelib test first) and prints one summary. usage: python -I run_all.py SCRATCH_DIR
Exit code 0 only if all pass. Synthetic data only; scratch files go under SCRATCH_DIR."""
import os
import subprocess
import sys
import time

HERE = os.path.dirname(os.path.abspath(__file__))
scratch = sys.argv[1]
os.makedirs(scratch, exist_ok=True)
SRC = os.path.join(HERE, "..", "src", "r5eval", "frozen", "scorelib_j2.py")
jobs = [("test_scorelib_j2_unchanged.py (J2's own tests, unchanged file)", ["test_scorelib_j2_unchanged.py", SRC]),
        ("test_core.py", ["test_core.py"]), ("test_pages.py", ["test_pages.py"]), ("test_ktrain.py", ["test_ktrain.py"]),
        ("test_curve.py", ["test_curve.py"]), ("test_cli.py", ["test_cli.py", os.path.join(scratch, "cli")]),
        ("test_report_cards.py", ["test_report_cards.py", os.path.join(scratch, "cards")]),
        ("test_leaders.py", ["test_leaders.py", os.path.join(scratch, "leaders")]),
        ("test_verdict.py", ["test_verdict.py", os.path.join(scratch, "verdict")])]
bad = 0
for label, args in jobs:
    t0 = time.time()
    p = subprocess.run([sys.executable, "-I", os.path.join(HERE, args[0])] + args[1:], capture_output=True, text=True, cwd=HERE)
    tail = [l for l in p.stdout.strip().split("\n") if l.startswith(("tests:", "all scorelib"))]
    fails = [l for l in p.stdout.split("\n") if l.startswith("FAIL")]
    print("%-70s exit %d  %s  (%.1f s)" % (label, p.returncode, tail[-1] if tail else "", time.time() - t0))
    for f in fails:
        print("    ", f)
    if p.returncode:
        bad += 1
        print(p.stdout[-2500:], p.stderr[-1500:])
print("ALL PASSED" if not bad else "%d test files FAILED" % bad)
sys.exit(1 if bad else 0)