[PATCH V2] run-tests: added 'cuser', 'csys' time info in report.json file

Anurag Goel anurag.dsps at gmail.com
Thu Sep 18 20:54:17 CDT 2014


# HG changeset patch
# User anuraggoel <anurag.dsps at gmail.com>
# Date 1411091590 -19800
#      Fri Sep 19 07:23:10 2014 +0530
# Node ID 86b86564cc03038af9fd74e339f5c2d30d49872f
# Parent  349c63f940fe055f25887eac8debb9e57e161e2e
run-tests: added 'cuser', 'csys' time info in report.json file

This patch adds up a 'cuser' and 'csys'(cputime) info in report.json file
which generated when --json is enabled while testing.

Now the new format of report.json file is as below.

testreport ={
    "test-success.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "success",
        "time": "2.041"
    }
    "test-failure.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "failure",
        "time": "4.430"
    }
    "test-skip.t": {
        "csys": "1.041",
        "cuser": "1.041",
        "result": "skip",
        "time": "3.754"
    }
}

diff -r 349c63f940fe -r 86b86564cc03 tests/run-tests.py
--- a/tests/run-tests.py	Fri Sep 19 07:08:36 2014 +0530
+++ b/tests/run-tests.py	Fri Sep 19 07:23:10 2014 +0530
@@ -1437,22 +1437,28 @@
             try:
                 timesd = {}
                 for test, cuser, csys, real in result.times:
-                    timesd[test] = real
+                    timesd[test] = (real, cuser, csys)
 
                 outcome = {}
                 for tc in result.successes:
                     testresult = {'result': 'success',
-                                  'time': ('%0.3f' % timesd[tc.name])}
+                                  'time': ('%0.3f' % timesd[tc.name][0]),
+                                  'cuser': ('%0.3f' % timesd[tc.name][1]),
+                                  'csys': ('%0.3f' % timesd[tc.name][2])}
                     outcome[tc.name] = testresult
 
                 for tc, err in sorted(result.faildata.iteritems()):
                     testresult = {'result': 'failure',
-                                  'time': ('%0.3f' % timesd[tc])}
+                                  'time': ('%0.3f' % timesd[tc][0]),
+                                  'cuser': ('%0.3f' % timesd[tc][1]),
+                                  'csys': ('%0.3f' % timesd[tc][2])}
                     outcome[tc] = testresult
 
                 for tc, reason in result.skipped:
                     testresult = {'result': 'skip',
-                                  'time': ('%0.3f' % timesd[tc.name])}
+                                  'time': ('%0.3f' % timesd[tc.name][0]),
+                                  'cuser': ('%0.3f' % timesd[tc.name][1]),
+                                  'csys': ('%0.3f' % timesd[tc.name][2])}
                     outcome[tc.name] = testresult
 
                 jsonout = json.dumps(outcome, sort_keys=True, indent=4)
diff -r 349c63f940fe -r 86b86564cc03 tests/test-run-tests.t
--- a/tests/test-run-tests.t	Fri Sep 19 07:08:36 2014 +0530
+++ b/tests/test-run-tests.t	Fri Sep 19 07:23:10 2014 +0530
@@ -394,14 +394,20 @@
   $ cat report.json
   testreport ={
       "test-failure.t": [\{] (re)
+          "csys": "\s*[\d\.]{5}",  (re)
+          "cuser": "\s*[\d\.]{5}",  (re)
           "result": "failure", 
           "time": "\s*[\d\.]{5}" (re)
       }, 
       "test-skip.t": {
+          "csys": "\s*[\d\.]{5}",  (re)
+          "cuser": "\s*[\d\.]{5}",  (re)
           "result": "skip", 
           "time": "\s*[\d\.]{5}" (re)
       }, 
       "test-success.t": [\{] (re)
+          "csys": "\s*[\d\.]{5}",  (re)
+          "cuser": "\s*[\d\.]{5}",  (re)
           "result": "success", 
           "time": "\s*[\d\.]{5}" (re)
       }


More information about the Mercurial-devel mailing list