-
Notifications
You must be signed in to change notification settings - Fork 29
/
test.py
73 lines (64 loc) · 2 KB
/
test.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
import doctest, sys, os, glob
retcode = 0
import snakes
version = open("VERSION").read().strip()
if snakes.version != version :
print("Mismatched versions:")
print(" snakes.version = %r" % snakes.version)
print(" VERSION = %r" % version)
sys.exit(1)
def test (module) :
print(" Testing '%s'" % module.__name__)
f, t = doctest.testmod(module, #verbose=True,
optionflags=doctest.NORMALIZE_WHITESPACE
| doctest.REPORT_ONLY_FIRST_FAILURE
| doctest.ELLIPSIS)
return f
modules = ["snakes",
"snakes.hashables",
"snakes.lang",
"snakes.lang.python.parser",
"snakes.lang.abcd.parser",
"snakes.lang.ctlstar.parser",
"snakes.data",
"snakes.typing",
"snakes.nets",
"snakes.pnml",
"snakes.plugins",
"snakes.plugins.pos",
"snakes.plugins.status",
"snakes.plugins.ops",
"snakes.plugins.synchro",
"snakes.plugins.hello",
"snakes.plugins.gv",
"snakes.plugins.clusters",
"snakes.plugins.labels",
"snakes.utils.abcd.build",
]
stop = False
if len(sys.argv) > 1 :
if sys.argv[1] == "--stop" :
stop = True
del sys.argv[1]
doscripts = True
if len(sys.argv) > 1 :
modules = sys.argv[1:]
doscripts = False
for modname in modules :
try :
__import__(modname)
retcode = max(retcode, test(sys.modules[modname]))
if retcode and stop :
break
except :
print(" Could not test %r:" % modname)
c, e, t = sys.exc_info()
print(" %s: %s" % (c.__name__, e))
if doscripts :
for script in (glob.glob("test-scripts/test*.sh")
+ glob.glob("test-scripts/test*.py")) :
print(" Running '%s'" % script)
retcode = max(retcode, os.system(script))
if retcode and stop :
break
sys.exit(retcode)