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
|
#!/usr/bin/python
import getopt
import os
import platform
import sys
root = os.path.dirname(__file__)
report_path = None
def usage():
print "Usage: run.py [options]"
# parse options
try:
opts, args = getopt.getopt(sys.argv[1:], 'hx:')
except getopt.GetoptError, err:
print err
usage()
sys.exit(2)
for opt, optarg in opts:
if opt == '-h':
usage()
sys.exit()
elif opt == '-x':
report_path = optarg
if not os.path.exists(report_path):
os.mkdir(report_path)
# set library path
path = os.path.join(root, '..', 'src')
if platform.system() == 'Darwin':
os.environ['DYLD_LIBRARY_PATH'] = path
else:
os.environ['LD_LIBRARY_PATH'] = path
# run tests
for test in os.listdir(root):
test_path = os.path.join(root, test)
if os.path.isdir(test_path):
if platform.system() == 'Darwin':
prog = os.path.join(test_path, 'tst_' + test + '.app', 'Contents', 'MacOS', 'tst_' + test)
else:
prog = os.path.join(test_path, 'tst_' + test)
if report_path:
os.system('%s -xunitxml -o %s/%s.xml' % (prog, report_path, test))
else:
os.system(prog)
|