[Asterisk-code-review] runtests: Add some additional attributes to the JUnit XML re... (testsuite[master])
Matt Jordan
asteriskteam at digium.com
Sun Oct 25 07:30:24 CDT 2015
Matt Jordan has uploaded a new change for review.
https://gerrit.asterisk.org/1528
Change subject: runtests: Add some additional attributes to the JUnit XML report
......................................................................
runtests: Add some additional attributes to the JUnit XML report
This patch adds a few new attributes/nodes to the JUnit XML report. This
includes:
(1) Skipped tests, including the reason why they were skipped. This is useful
for knowing why a test wasn't run on a build agent.
(2) The time the test run was started.
Additionally, the 'dry-run' attribute has been removed, as it is illegal within
a JUnit compliant schema. Instead. if the dry-run option is selected, all tests
are counted as being skipped.
Change-Id: Id95d7eb379c35ce8be563a28c5828fd76c0c1387
---
M runtests.py
1 file changed, 19 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/28/1528/1
diff --git a/runtests.py b/runtests.py
index a24a1c3..f05b3b1 100755
--- a/runtests.py
+++ b/runtests.py
@@ -61,6 +61,7 @@
self.stdout = ""
self.timeout = timeout
self.cleanup = options.cleanup
+ self.skipped_reason = ""
assert self.test_name.startswith('tests/')
self.test_relpath = self.test_name[6:]
@@ -348,6 +349,7 @@
self.options = options
self.tests = []
+ self.start_time = None
self.global_config = self._parse_global_config()
self.tests = self._parse_test_yaml("tests", ast_version)
if self.options.randomorder:
@@ -357,6 +359,7 @@
self.total_time = 0.0
self.total_count = 0
self.total_failures = 0
+ self.total_skipped = 0
def _parse_global_config(self):
return TestConfig(os.getcwd())
@@ -446,6 +449,7 @@
i += 1
def run(self):
+ self.start_time = time.strftime("%Y-%m-%dT%H:%M:%S %Z", time.localtime())
test_suite_dir = os.getcwd()
i = 0
for t in self.tests:
@@ -463,6 +467,8 @@
if t.can_run is False:
if t.test_config.skip is not None:
print "--> %s ... skipped '%s'" % (t.test_name, t.test_config.skip)
+ t.skipped_reason = t.test_config.skip
+ self.total_skipped += 1
continue
print "--> Cannot run test '%s'" % t.test_name
if t.test_config.forced_version is not None:
@@ -482,6 +488,8 @@
for d in t.test_config.deps:
print "--- --> Dependency: %s - %s" % (d.name, str(d.met))
print
+ self.total_skipped += 1
+ t.skipped_reason = "Failed dependency"
continue
if self.global_config is not None:
exclude = False
@@ -490,6 +498,7 @@
print "--- ---> Excluded test: %s" % excluded
exclude = True
if exclude:
+ self.total_skipped += 1
continue
print "--> Running test '%s' ..." % t.test_name
@@ -560,18 +569,24 @@
ts.setAttribute("time", "%.2f" % self.total_time)
ts.setAttribute("failures", str(self.total_failures))
ts.setAttribute("name", "AsteriskTestSuite")
+ ts.setAttribute("timestamp", self.start_time)
if self.options.dry_run:
- ts.setAttribute("dry-run", str(self.total_count))
+ ts.setAttribute("skipped", str(self.total_count))
+ elif self.total_skipped > 0:
+ ts.setAttribute("skipped", str(self.total_skipped))
for t in self.tests:
- if t.did_run is False:
- continue
-
tc = doc.createElement("testcase")
ts.appendChild(tc)
tc.setAttribute("time", "%.2f" % t.time)
tc.setAttribute("name", t.test_name)
+ if t.did_run is False:
+ tskip = doc.createElement("skipped")
+ tskip.appendChild(doc.createTextNode(t.skipped_reason))
+ tc.appendChild(tskip)
+ continue
+
if t.passed:
continue
--
To view, visit https://gerrit.asterisk.org/1528
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id95d7eb379c35ce8be563a28c5828fd76c0c1387
Gerrit-PatchSet: 1
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-Owner: Matt Jordan <mjordan at digium.com>
More information about the asterisk-code-review
mailing list