Skip to content

Commit ea6f6bb

Browse files
committed
GUITESTS: Print summary from the test script.
1 parent 0cd8282 commit ea6f6bb

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

gui/test/runtests.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class Test:
1414
def __init__(self):
1515
self.profile = ''
1616
self.binary = ''
17+
self.passed = 0
18+
self.failed = 0
19+
self.skipped = 0
1720

1821

1922
class TestList:
@@ -105,6 +108,7 @@ def __init__(self, testlist):
105108
def runtests(self):
106109
for test in self._testlist:
107110
self._runtest(test)
111+
self._printsummary()
108112

109113
def _runtest(self, test):
110114
cmd = test.binary
@@ -115,6 +119,36 @@ def _runtest(self, test):
115119
stderr = subprocess.STDOUT)
116120
stdout_value, stderr_value = proc.communicate()
117121
print stdout_value
122+
self._parseoutput(test, stdout_value)
123+
124+
def _parseoutput(self, test, output):
125+
'''Parse test counts (passed, failed, skipped) from the output.'''
126+
127+
lines = output.splitlines(True)
128+
for line in lines:
129+
# Lines are like: Totals: 6 passed, 0 failed, 0 skipped
130+
if line.startswith('Totals: '):
131+
parts = line.split(' ')
132+
test.passed = int(parts[1])
133+
test.failed = int(parts[3])
134+
test.skipped = int(parts[5])
135+
136+
def _printsummary(self):
137+
total = 0
138+
passed = 0
139+
failed = 0
140+
skipped = 0
141+
for test in self._testlist:
142+
total += test.passed + test.failed + test.skipped
143+
passed += test.passed
144+
failed += test.failed
145+
skipped += test.skipped
146+
147+
print '\nTEST SUMMARY:'
148+
print ' Total tests: %i' % total
149+
print ' Passed tests: %i' % passed
150+
print ' Failed tests: %i' % failed
151+
print ' Skipped tests: %i' % skipped
118152

119153

120154
def main():

0 commit comments

Comments
 (0)