[Piglit] [PATCH v2] junit.py: Fix handling of special test names.

Mark Janes mark.a.janes at intel.com
Mon Feb 23 11:02:52 PST 2015


In junit.py, the testname variable is used by a closure within the
write_test() scope.  Modifying it breaks the filtering of expected
failures.

v2: to improve readability, use a different variable for the
    `testname + self._test_suffix` sub-expression. (thanks to Jose)
---
 framework/backends/junit.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/framework/backends/junit.py b/framework/backends/junit.py
index ddaf826..82f9c29 100644
--- a/framework/backends/junit.py
+++ b/framework/backends/junit.py
@@ -166,16 +166,18 @@ class JUnitBackend(FileBackend):
         # set different root names.
         classname = 'piglit.' + classname
 
-        testname += self._test_suffix
-
         # Jenkins will display special pages when the test has certain names.
         # https://jenkins-ci.org/issue/18062
         # https://jenkins-ci.org/issue/19810
-        if testname in ('api', 'search'):
+        # The testname variable is used in the calculate_result
+        # closure, and must not have the suffix appended.
+        full_test_name = testname + self._test_suffix
+        if full_test_name in ('api', 'search'):
             testname += '_'
+            full_test_name = testname + self._test_suffix
 
         # Create the root element
-        element = etree.Element('testcase', name=testname,
+        element = etree.Element('testcase', name=full_test_name,
                                 classname=classname,
                                 time=str(data['time']),
                                 status=str(data['result']))
-- 
2.1.4



More information about the Piglit mailing list