-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_results.py
38 lines (30 loc) · 1.21 KB
/
check_results.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
import sys, os
def validate(file1, file2):
with open(file1, 'r') as f:
f1array = (int(line.split()[1]) for line in f.readlines())
with open(file2, 'r') as f:
f2array = (int(line.split()[1]) for line in f.readlines())
for (a, b) in zip(f1array, f2array):
s = "{} {}\t{}\t{}".format("Expected", a, "Got", b)
print(s)
if a != 0 or b != 0:
# make sure a and b have same signs if definite win
assert(a * b > 0)
else:
# check if both are ties
assert(a == b)
print("OK")
if __name__ == "__main__":
os.makedirs(name='test_outputs', exist_ok=True)
if len(sys.argv) == 1:
files = [os.path.basename(f) for f in os.listdir("test_outputs")]
files = ["test_inputs/" + f[:-4] for f in files]
print(files)
else:
files = sys.argv[1:]
for file_to_check in files:
basename = os.path.basename(file_to_check)
outputfile = f'test_outputs/{basename}.log'
os.system(f' RUSTFLAGS="-C target-cpu=native" cargo r --release -- test {file_to_check} > {outputfile}')
validate(file_to_check, outputfile)
os.system(f'tail -n5 test_outputs/{basename}.log')