-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-exec.py
41 lines (32 loc) · 862 Bytes
/
single-exec.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
import subprocess, glob, os
testdir = "./tests"
runner = "./bin/ntc"
def test(file):
try:
proc = subprocess.run([runner, file], capture_output=True, text=True, timeout=2)
outs = proc.stdout
errs = proc.stderr
except subprocess.TimeoutExpired as timeErr:
outs = timeErr.stdout
errs = timeErr.stderr
return False
if proc.returncode != 0:
return False
with open(file + ".expected") as f:
expect = f.read()
if expect != outs:
return False
return True
total = 0
ok = 0
fail = 0
for file in sorted(glob.glob(testdir + "/*.nt")):
basename = os.path.basename(file)
total += 1
if test(file):
print("ok\t" + basename)
ok += 1
else:
print("fail\t" + basename)
fail += 1
print(f"{ok}/{total} (pass: {ok}, fail: {fail})")