-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboosttest.py
More file actions
55 lines (43 loc) · 1.96 KB
/
boosttest.py
File metadata and controls
55 lines (43 loc) · 1.96 KB
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
## Copyleft. All wrongs reserved.
from buildbot.steps.shell import ShellCommand
from xml.etree import ElementTree
import re
class BoostTest (ShellCommand) :
def __init__(self, **kwargs) :
ShellCommand.__init__(self, **kwargs)
def add_key_to_description(self, description, key) :
value = self.step_status.getStatistic(key, 0)
if (value <= 0) :
return
total = self.step_status.getStatistic('total', 0)
if (total > 0) :
description.append('%s: %d / %d [%3d%]' % (key, value, total, (value * 100 / total)))
else :
description.append('%s: %d' % (key, value))
def describe(self, done=False):
description = ShellCommand.describe(self, done)
if done :
self.add_key_to_description(description, 'passed')
self.add_key_to_description(description, 'skipped')
self.add_key_to_description(description, 'failed')
return description
def collect_statistical_value(self, name, query, tree) :
nodes = tree.findall(".//TestSuite")
value = 0
for node in nodes :
value += int(node.get(query, 0));
self.step_status.setStatistic(name, value)
def createSummary(self, log):
ShellCommand.createSummary(self, log)
output = self.getLog('stdio').getText()
testresult = re.search('<TestResult>.*</TestResult>', output, re.MULTILINE)
testresult_root = ElementTree.fromstring(testresult.group(0))
self.collect_statistical_value('passed', 'test_cases_passed', testresult_root)
self.collect_statistical_value('failed', 'test_cases_failed', testresult_root)
self.collect_statistical_value('skipped', 'test_cases_skipped', testresult_root)
self.collect_statistical_value('aborted', 'test_cases_aborted', testresult_root)
total = self.step_status.getStatistic('passed', 0)
total += self.step_status.getStatistic('failed', 0)
total += self.step_status.getStatistic('skipped', 0)
total += self.step_status.getStatistic('aborted', 0)
self.step_status.setStatistic('total', total)