Patchwork [4,of,5] run-tests: when building json, get time data in the same order as elsewhere

login
register
mail settings
Submitter Pierre-Yves David
Date May 8, 2015, 6:53 p.m.
Message ID <470fb04e8380ec184d9b.1431111237@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8982/
State Accepted
Headers show

Comments

Pierre-Yves David - May 8, 2015, 6:53 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1431065817 25200
#      Thu May 07 23:16:57 2015 -0700
# Node ID 470fb04e8380ec184d9b61f4a6194aa532ef2a7a
# Parent  d875416ce6d6ce611ec5005d05e89faf07e8ce1a
run-tests: when building json, get time data in the same order as elsewhere

The json code was changing the order of the time tuple for unclear reason. We
now use the same order as everywhere else.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1525,23 +1525,22 @@  class TextTestRunner(unittest.TextTestRu
             fp = open(jsonpath, 'w')
             try:
                 timesd = {}
                 for tdata in result.times:
                     test = tdata[0]
-                    real, cuser, csys = tdata[3], tdata[1], tdata[2]
-                    timesd[test] = (real, cuser, csys)
+                    timesd[test] = tdata[1:]
 
                 outcome = {}
                 groups = [('success', ((tc, None) for tc in result.successes)),
                           ('failure', result.failures),
                           ('skip', result.skipped)]
                 for res, testcases in groups:
                     for tc, __ in testcases:
                         testresult = {'result': res,
-                                      'time': ('%0.3f' % timesd[tc.name][0]),
-                                      'cuser': ('%0.3f' % timesd[tc.name][1]),
-                                      'csys': ('%0.3f' % timesd[tc.name][2])}
+                                      'time': ('%0.3f' % timesd[tc.name][2]),
+                                      'cuser': ('%0.3f' % timesd[tc.name][0]),
+                                      'csys': ('%0.3f' % timesd[tc.name][1])}
                         outcome[tc.name] = testresult
 
                 jsonout = json.dumps(outcome, sort_keys=True, indent=4)
                 fp.writelines(("testreport =", jsonout))
             finally: