[Asterisk-code-review] runtests.py: Make xml output more jUnit compatible (testsuite[13])

George Joseph asteriskteam at digium.com
Fri Jul 6 09:45:57 CDT 2018


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/9366


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, 28 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/testsuite refs/changes/66/9366/1

diff --git a/runtests.py b/runtests.py
index 1351a3c..9477ed7 100755
--- a/runtests.py
+++ b/runtests.py
@@ -676,6 +676,18 @@
         return data.translate(None, ''.join(char_list))
 
     def write_results_xml(self, doc, root):
+        reserved = {'abstract':1, 'arguments':1, 'as':1, 'assert':1, 'await':1,
+            'boolean':1, 'break':1, 'byte':1, 'case':1, 'catch':1, 'char':1, 'class':1,
+            'const':1, 'continue':1, 'debugger':1, 'def':1, 'default':1, 'delete':1, 'do':1,
+            'double':1, 'else':1, 'enum':1, 'eval':1, 'export':1, 'extends':1, 'false':1,
+            'final':1, 'finally':1, 'float':1, 'for':1, 'function':1, 'goto':1, 'if':1,
+            'implements':1, 'import':1, 'in':1, 'instanceof':1, 'int':1, 'interface':1,
+            'let':1, 'long':1, 'native':1, 'new':1, 'null':1, 'package':1, 'private':1,
+            'protected':1, 'public':1, 'return':1, 'short':1, 'static':1, 'strictfp':1,
+            'string': 1, 'super':1, 'switch':1, 'synchronized':1, 'this':1, 'throw':1, 'throws':1,
+            'trait':1, 'transient':1, 'true':1, 'try':1, 'typeof':1, 'var':1, 'void':1,
+            'volatile':1, 'while':1, 'with':1, 'yield':1
+        }
 
         ts = doc.createElement("testsuite")
         root.appendChild(ts)
@@ -694,7 +706,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 reserved.get(n) is not None:
+                    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 +896,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/9366
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: testsuite
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia532c0fa20e9ebb62adc93081e0cb52791e80edb
Gerrit-Change-Number: 9366
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180706/c2f25b19/attachment.html>


More information about the asterisk-code-review mailing list