-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_suite.py
110 lines (79 loc) · 2.97 KB
/
run_suite.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import os
import time
import glob
import sys
import subprocess
import shutil
import re
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-q", "--quicktest", action="store_true", dest="quicktest", default=False,
help='Runs the quicktest suite')
(options, args) = parser.parse_args()
qt = options.quicktest
##if sys.platform.startswith("darwin"):
os.putenv("MACOSX_DEPLOYMENT_TARGET","10.5")
if os.getenv("PCF_TEST_HOME") == None:
raw_input("Must set PCF_TEST_HOME env to current dir, press key to exit")
##else:
## os.putenv("PCF_TEST_HOME",os.getcwd())
if os.getenv("SIKULI_HOME") == None:
raw_input("Must set SIKULI_HOME environment var to dir containing sikuli-script.jar \
Press any key to exit")
JAR_PATH = os.path.join(os.getenv("SIKULI_HOME"),"sikuli-script.jar")
RESULTS_DIR = os.path.join(os.getenv("PCF_TEST_HOME"), "MVC", "last_run")
QUICK_TESTS = [['sg59_apple_devs.sikuli', 'test_340', 'test_341'],
]
def _clear_out_the_old_results():
for f in glob.glob(os.path.join(RESULTS_DIR, '*.xml')):
os.unlink(f)
def count_results(status):
STAT_STRING = 'resultstatus=\"%s' % status
STAT_COUNT = 0
for f in glob.glob(os.path.join(RESULTS_DIR, '*.xml')):
result = os.path.expandvars(f)
rez = open(result, 'r')
count = len(re.findall (STAT_STRING, rez.read()))
STAT_COUNT += count
return STAT_COUNT
def check_the_results():
total_pass = count_results(status="pass")
total_fail = count_results(status="fail")
print """Test run complete:
%(#pass)d passing tests
%(#fail)d failing tests""" \
% {"#pass": total_pass, "#fail": total_fail}
def _run_the_quicktests():
"""Only run the quicktest suite.
#To run just one test:
#java -jar "$SIKULI_HOME/sikuli-script.jar" sg_xx_xxx.sikuli test_x test_y ...")
"""
for tests in QUICK_TESTS:
sik_run_cmd = ['java', '-jar', JAR_PATH]
for x in tests:
sik_run_cmd.append(x)
p = subprocess.Popen(sik_run_cmd).communicate()
def _run_the_full_suite():
"""Runs all the subgroups.
java -jar $SIKULI_HOME/sikuli-script.jar sgxx_xxx.sikuli"
"""
#get all the tests in the directory and make a list
sglist = []
alltests = glob.glob(os.path.join(os.getcwd(), '*.sikuli'))
for x in alltests:
sglist.append(os.path.basename(x))
#sort the list, then drop subgroup_1 and subgroup 89 install tests to the back of the list.
for subgroup in sglist:
jar_path = os.path.join(os.getenv("SIKULI_HOME"),"sikuli-script.jar")
sik_run_cmd = ['java', '-jar', jar_path]
sik_run_cmd.append(subgroup)
p = subprocess.Popen(sik_run_cmd).communicate()
try:
#Clear out old results before executing tests
_clear_out_the_old_results()
if qt == True:
_run_the_quicktests()
else:
_run_the_full_suite()
finally:
check_the_results()