[Piglit] [PATCH 3/3] framework/backends/junit.py: make the replacement character for '.' unique

baker.dylan.c at gmail.com baker.dylan.c at gmail.com
Thu Oct 8 17:21:30 PDT 2015


From: Dylan Baker <baker.dylan.c at gmail.com>

This is a hard requirement for being able to pass junit into the current
piglit summary tools. The value itself is irrelevant, and I'm opened to
changing it to whatever, but it must by unique. I picked "___" (three
underscores), because it seemed very likely to be unique.
---
 framework/backends/junit.py             |  5 ++++-
 framework/tests/junit_backends_tests.py | 11 ++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/framework/backends/junit.py b/framework/backends/junit.py
index 15c6c0b..3654eae 100644
--- a/framework/backends/junit.py
+++ b/framework/backends/junit.py
@@ -44,7 +44,7 @@ _JUNIT_SPECIAL_NAMES = ('api', 'search')
 
 
 def junit_escape(name):
-    name = name.replace('.', '_')
+    name = name.replace('.', '___')
     if name in _JUNIT_SPECIAL_NAMES:
         name += '_'
     return name
@@ -254,6 +254,9 @@ def _load(results_file):
         if name.endswith('_'):
             name = name[:-1]
 
+        # If the name has had '.' replaced we want to convert it back
+        name = name.replace('___', '.')
+
         result.result = test.attrib['status']
 
         # This is the fallback path, we'll try to overwrite this with the value
diff --git a/framework/tests/junit_backends_tests.py b/framework/tests/junit_backends_tests.py
index 7d5a3fc..bf02f5b 100644
--- a/framework/tests/junit_backends_tests.py
+++ b/framework/tests/junit_backends_tests.py
@@ -45,7 +45,7 @@ _XML = """\
 <?xml version='1.0' encoding='utf-8'?>
   <testsuites>
     <testsuite name="piglit" tests="1">
-      <testcase classname="piglit.foo.bar" name="a-test" status="pass" time="1.12345">
+      <testcase classname="piglit.foo.bar___bar" name="a-test" status="pass" time="1.12345">
         <system-out>this/is/a/command\nThis is stdout</system-out>
         <system-err>this is stderr
 
@@ -207,7 +207,7 @@ class TestJUnitLoad(utils.StaticDirectory):
         with open(cls.xml_file, 'w') as f:
             f.write(_XML)
 
-        cls.testname = grouptools.join('foo', 'bar', 'a-test')
+        cls.testname = grouptools.join('foo', 'bar.bar', 'a-test')
 
     @classmethod
     def xml(cls):
@@ -226,7 +226,12 @@ class TestJUnitLoad(utils.StaticDirectory):
 
     @doc_formatter
     def test_replace_sep(self):
-        """backends.junit._load: replaces '.' with '{separator}'"""
+        """backends.junit._load: Restores name to piglit expected value
+
+        Replaces '.' with '{separator}', and '___' with '.', which is what
+        piglit expects.
+
+        """
         nt.assert_in(self.testname, self.xml().tests)
 
     def test_testresult_instance(self):
-- 
2.6.1



More information about the Piglit mailing list