forked from thomasjball/PyExZ3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_tests.py
42 lines (33 loc) · 1.1 KB
/
run_tests.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
import os
import re
import sys
from optparse import OptionParser
from sys import platform as _platform
class bcolors:
SUCCESS = '\033[32m'
WARNING = '\033[33m'
FAIL = '\033[31m'
ENDC = '\033[0m'
def myprint(color, s, *args):
if _platform != "win32" and sys.stdout.isatty():
print(color, s, bcolors.ENDC, *args)
else:
print(*args)
parser = OptionParser()
(options, args) = parser.parse_args()
if len(args) == 0 or not os.path.exists(args[0]):
parser.error("Please supply directory of tests")
sys.exit(1)
test_dir = os.path.abspath(args[0])
if not os.path.isdir(test_dir):
print("Please provide a directory of test scripts.")
sys.exit(1)
files = [ f for f in os.listdir(test_dir) if re.search(".py$",f) ]
for f in files:
# execute the python runner for this test
full = test_dir + os.sep + f
ret = os.system(sys.executable + " sym_exec.py -l "+full+".log "+full+" > "+full+".out")
if (ret == 0):
myprint(bcolors.SUCCESS, "✓", "Test " + f + " passed.")
else:
myprint(bcolors.FAIL, "✗", "Test " + f + " failed.")