[Asterisk-code-review] runtests.py: Make xml output more jUnit compatible (testsuite[master])
Jenkins2
asteriskteam at digium.com
Tue Jul 10 05:24:35 CDT 2018
Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/9370 )
Change subject: runtests.py: Make xml output more jUnit compatible
......................................................................
runtests.py: Make xml output more jUnit compatible
Separate "name" into "classname" and "name".
Use '.' for classname separator instead of '/'.
Prefix reserved words with '_'.
Also modified the '-t' option processing to allow test specification
by "classname". I.E. -t channels.pjsip.ami
Change-Id: Ia532c0fa20e9ebb62adc93081e0cb52791e80edb
---
M runtests.py
1 file changed, 31 insertions(+), 2 deletions(-)
Approvals:
Kevin Harwell: Looks good to me, but someone else must approve
Benjamin Keith Ford: Looks good to me, but someone else must approve
George Joseph: Looks good to me, approved
Jenkins2: Approved for Submit
diff --git a/runtests.py b/runtests.py
index 1351a3c..be1055f 100755
--- a/runtests.py
+++ b/runtests.py
@@ -676,6 +676,21 @@
return data.translate(None, ''.join(char_list))
def write_results_xml(self, doc, root):
+ # Java reserved words we need to munge so Jenkins doesn't barf
+ reserved = ['abstract', 'arguments', 'as', 'assert', 'await',
+ 'boolean', 'break', 'byte', 'case', 'catch', 'char',
+ 'class', 'const', 'continue', 'debugger', 'def',
+ 'default', 'delete', 'do', 'double', 'else', 'enum',
+ 'eval', 'export', 'extends', 'false', 'final',
+ 'finally', 'float', 'for', 'function', 'goto', 'if',
+ 'implements', 'import', 'in', 'instanceof', 'int',
+ 'interface', 'let', 'long', 'native', 'new', 'null',
+ 'package', 'private', 'protected', 'public', 'return',
+ 'short', 'static', 'strictfp', 'string', 'super',
+ 'switch', 'synchronized', 'this', 'throw', 'throws',
+ 'trait', 'transient', 'true', 'try', 'typeof', 'var',
+ 'void', 'volatile', 'while', 'with', 'yield'
+ ]
ts = doc.createElement("testsuite")
root.appendChild(ts)
@@ -694,7 +709,19 @@
tc = doc.createElement("testcase")
ts.appendChild(tc)
tc.setAttribute("time", "%.2f" % t.time)
- tc.setAttribute("name", t.test_name)
+
+ name = re.sub('[^A-Za-z0-9_/]', '_', t.test_name)
+ names = name.split('/')
+ for i, n in enumerate(names):
+ if n in reserved:
+ names[i] = "_" + n
+
+ name_count = len(names)
+ classname = '.'.join(names[1:(name_count - 1)])
+ name = names[(name_count - 1)]
+
+ tc.setAttribute("classname", classname)
+ tc.setAttribute("name", name)
if t.did_run is False:
tskip = doc.createElement("skipped")
@@ -872,7 +899,9 @@
# Ensure that there's a trailing '/' in the tests specified with -t
for i, test in enumerate(options.tests):
- if not test.endswith('/'):
+ if "/" not in test and "." in test:
+ options.tests[i] = "tests/" + test.replace(".", "/") + "/"
+ elif not test.endswith('/'):
options.tests[i] = test + '/'
if options.valgrind:
--
To view, visit https://gerrit.asterisk.org/9370
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: testsuite
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia532c0fa20e9ebb62adc93081e0cb52791e80edb
Gerrit-Change-Number: 9370
Gerrit-PatchSet: 3
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Benjamin Keith Ford <bford at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180710/4a60419f/attachment.html>
More information about the asterisk-code-review
mailing list