-
Notifications
You must be signed in to change notification settings - Fork 1
/
fieldstest.py
30 lines (28 loc) · 902 Bytes
/
fieldstest.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
import subprocess
import sys
import os
from typing import Iterable
import datetime
def get_files(dir_path: str) -> Iterable[str]:
return sorted(os.path.join(d, file) for d, ns, f in os.walk(os.path.expanduser(dir_path)) for file in f)
if __name__=='__main__':
sys.stdout.reconfigure(encoding='utf-8')
bin_path = sys.argv[1]
num_failed_tests = 0
print("Start test")
for f in list(get_files(sys.argv[2])):
begin_time = datetime.datetime.now()
output = subprocess.run([bin_path, '-b', '-s', '5', f], capture_output=True, shell=False)
print("Test", f)
print("Return code :", output.returncode)
print(output.stderr.strip())
print(datetime.datetime.now() - begin_time)
print()
if (output.returncode != 0):
print("Solution failed with return code %d " % output.returncode)
num_failed_tests += 1
sys.stdout.flush()
if num_failed_tests == 0:
sys.exit(0)
else:
sys.exit(1)