-
Notifications
You must be signed in to change notification settings - Fork 0
/
regression.py
54 lines (44 loc) · 1.5 KB
/
regression.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
# import fnmatch
import os
# import glob
import sys
success = '\033[92m'
fail = '\033[91m'
def run_test(file, flag1="", flag2=""):
print ('Running test ' + file + ':')
cmd = "./doc %s %s %s" % (file, flag1, flag2)
print ("Running command: " + cmd)
# print "> %s : " % file
os.system(cmd)
def valid():
print ("Running tests that should be VALID...")
for root, dirnames, filenames in os.walk('programs/valid'):
for filename in filenames:
if (filename.endswith(('.onc')) and
not filename.endswith(('.pretty.onc'))):
run_test(os.path.join(root, filename))
for root, dirnames, filenames in os.walk('programs/examples'):
for filename in filenames:
if not filename.endswith(('.pretty.onc')):
run_test(os.path.join(root, filename))
print
def invalid():
print ("Running tests that should be INVALID...")
for root, dirnames, filenames in os.walk('programs/invalid'):
for filename in filenames:
if not filename.endswith(('pretty.onc')):
run_test(os.path.join(root, filename))
if (len(sys.argv) == 1):
valid()
invalid()
else:
if (sys.argv[1] == "-i"):
invalid()
elif (sys.argv[1] == "-v"):
valid()
else:
if (len(sys.argv) == 3):
run_test(sys.argv[1], sys.argv[2])
elif (len(sys.argv) == 4):
run_test(sys.argv[1], sys.argv[2], sys.argv[3])
sys.exit()