-
Notifications
You must be signed in to change notification settings - Fork 55
/
sanitizer.py
79 lines (65 loc) · 1.84 KB
/
sanitizer.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
import os
import subprocess
import sys
# XXX Near duplicates in maketest.py, 02/06/24
def Main():
BuildVPLanet()
dir_list = CollectAllTests()
tot_fail = 0
tot_test = 0
for dir in dir_list:
tot_test += 1
sys.stdout.write(dir)
sys.stdout.flush()
os.chdir(dir)
subdirs = dir.split("/")
test = subdirs[1]
outfile = test + ".sanitize"
cmd = "../../../bin/vplanet vpl.in"
with open(outfile, "w+") as f:
fail = 0
subprocess.run(cmd, shell=True, stdout=f, stderr=f)
#subprocess.run(cmd, shell=True)
f = open(outfile, "r")
for line in f:
if ("ABORTING" in line):
fail = 1
tot_fail += 1
if (line != "Simulation completed.\n"):
fail = 1
tot_fail += 1
if fail:
print(": FAIL",flush=True)
else:
print(": pass",flush=True)
f.close()
os.chdir("../../")
print("Done! ")
if tot_fail == 0:
print("VPLanet is sanitized!")
assert True
else:
print(repr(tot_fail) + "/" + repr(tot_test) + " test(s) failed.")
assert False
exit(0)
def BuildVPLanet():
sys.stdout.write("Building VPLanet...")
sys.stdout.flush()
os.chdir("../")
subprocess.check_output(["make", "sanitize"])
print("done.", flush=True)
os.chdir("tests")
def CollectAllTests():
top_list = sorted(next(os.walk("."))[1])
dir_list = []
for top in top_list:
subdirs = [
os.path.join(top, subdir) for subdir in sorted(next(os.walk(top))[1])
]
for subdir in subdirs:
if "pycache" not in subdir:
dir_list.append(subdir)
print(" ", flush=True)
return dir_list
if __name__ == "__main__":
Main()