-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
29 lines (25 loc) · 897 Bytes
/
Copy pathrun_tests.py
File metadata and controls
29 lines (25 loc) · 897 Bytes
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
#!/usr/bin/env python3
"""Host test runner for plexus. No services, no dependencies.
python run_tests.py
Exit code is non-zero if any test file fails, so CI can gate on it.
"""
import os
import runpy
import sys
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
TESTS = os.path.join(HERE, "tests")
mods = sorted(f for f in os.listdir(TESTS) if f.startswith("test_") and f.endswith(".py"))
failed = []
for m in mods:
print("\n===== %s =====" % m)
try:
runpy.run_path(os.path.join(TESTS, m), run_name="__main__")
except Exception as e: # AssertionError or anything else = failure
failed.append(m)
print("FAILED: %s: %s" % (type(e).__name__, e))
print("\n" + "=" * 40)
if failed:
print("%d/%d test file(s) FAILED: %s" % (len(failed), len(mods), ", ".join(failed)))
sys.exit(1)
print("ALL %d TEST FILES PASSED" % len(mods))