-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
91 lines (65 loc) · 1.99 KB
/
run_tests.py
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import os
import sys
import glob
import warnings
os.environ["SIRE_NO_LAZY_IMPORT"] = "1"
warnings.filterwarnings("ignore", "to-Python converter for")
try:
import sire
sire.use_old_api()
except ImportError:
pass
# make sure we are in this directory
os.chdir(os.path.dirname(os.path.abspath(__file__)))
from Sire import try_import
import Sire.Config
nose = try_import("nose")
import Sire.Base
old_cwd = os.path.abspath(".")
testdir = "."
if len(sys.argv) > 1:
testdirs = sys.argv[1:]
sys.argv = [sys.argv[0], "-v"]
drop = []
for dir in testdirs:
if dir.startswith("-"):
drop.append(dir)
if len(drop) > 0:
testdirs = []
dirs = os.listdir(testdir)
for dir in dirs:
for d in drop:
if d[1:] != dir:
testdirs.append(dir)
else:
testdirs = glob.glob(f"Sire*")
testdirs.sort()
testdirs.append("OpenMM")
testdirs.append("Tools")
print(f"Running in {testdirs}")
sys.argv = [sys.argv[0], "-v"]
failures = []
for file in testdirs:
subdir = os.path.join(testdir, file)
if not file.startswith(".") and os.path.isdir(subdir):
print("\n\nRunning tests in directory %s..." % subdir)
print("############################################")
os.chdir(subdir)
success = nose.run()
if not success:
failures.append(file)
os.chdir(old_cwd)
if len(failures) > 0:
print("\n\nWARNING: SOME OF THE TEST JOBS FAILED!!!")
print("#########################################")
s = []
for failure in failures:
print("One of more jobs in %s failed!" % failure)
s.append("One of more jobs in %s failed!" % failure)
print("\nEXITING AS FAIL")
error_message = "SOME OF THE UNIT TESTS FAILED!\n%s" % \
"\n".join(s)
raise AssertionError(error_message)
else:
print("\n\nHOORAY - ALL OF THE UNIT TESTS PASSED!!!")
print("\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/")