Patchwork [3,of,5] run-tests: make time field optional for xunit report

login
register
mail settings
Submitter Siddharth Agarwal
Date June 6, 2017, 9:39 p.m.
Message ID <cd0fe3fedddab358d47d.1496785166@devvm31800.prn1.facebook.com>
Download mbox | patch
Permalink /patch/21227/
State Accepted
Headers show

Comments

Siddharth Agarwal - June 6, 2017, 9:39 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1496782345 25200
#      Tue Jun 06 13:52:25 2017 -0700
# Node ID cd0fe3fedddab358d47d6f34d5c1e596298199bb
# Parent  737bb0771ca0bff0673f861c068018c8f606cf7d
run-tests: make time field optional for xunit report

We're going to use XUnit to list tests, and we don't have a time field in that
case.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2016,12 +2016,16 @@  class TextTestRunner(unittest.TextTestRu
         for tc in result.successes:
             t = doc.createElement('testcase')
             t.setAttribute('name', tc.name)
-            t.setAttribute('time', '%.3f' % timesd[tc.name])
+            tctime = timesd.get(tc.name)
+            if tctime is not None:
+                t.setAttribute('time', '%.3f' % tctime)
             s.appendChild(t)
         for tc, err in sorted(result.faildata.items()):
             t = doc.createElement('testcase')
             t.setAttribute('name', tc)
-            t.setAttribute('time', '%.3f' % timesd[tc])
+            tctime = timesd.get(tc)
+            if tctime is not None:
+                t.setAttribute('time', '%.3f' % tctime)
             # createCDATASection expects a unicode or it will
             # convert using default conversion rules, which will
             # fail if string isn't ASCII.