[PATCH] run-tests: added 'cputime' info in report.json file

Anurag Goel anurag.dsps at gmail.com
Thu Sep 18 20:28:48 CDT 2014


# HG changeset patch
# User anuraggoel <anurag.dsps at gmail.com>
# Date 1411090041 -19800
#      Fri Sep 19 06:57:21 2014 +0530
# Node ID a7f6902e888f86d1ba807ed7a4807cf9c788a10e
# Parent  48791c2bea1ceda4e4f28bc11651e281d636ce1a
run-tests: added 'cputime' info in report.json file

This patch adds up a cputime(cuser + csys) 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": {
        "cputime": "1.041",
        "result": "success",
        "time": "2.041"
    }
    "test-failure.t": {
        "cputime": "4.041",
        "result": "failure",
        "time": "4.430"
    }
    "test-skip.t": {
        "cputime": "3.041",
        "result": "skip",
        "time": "3.754"
    }
}

diff -r 48791c2bea1c -r a7f6902e888f tests/run-tests.py
--- a/tests/run-tests.py	Tue Sep 16 14:49:56 2014 -0500
+++ b/tests/run-tests.py	Fri Sep 19 06:57:21 2014 +0530
@@ -1437,22 +1437,25 @@
             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]),
+                                  'cputime': ('%0.3f' % timesd[tc.name][1])}
                     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]),
+                                  'cputime': ('%0.3f' % timesd[tc][1])}
                     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]),
+                                  'cputime': ('%0.3f' % timesd[tc.name][1])}
                     outcome[tc.name] = testresult
 
                 jsonout = json.dumps(outcome, sort_keys=True, indent=4)
diff -r 48791c2bea1c -r a7f6902e888f tests/test-run-tests.t
--- a/tests/test-run-tests.t	Tue Sep 16 14:49:56 2014 -0500
+++ b/tests/test-run-tests.t	Fri Sep 19 06:57:21 2014 +0530
@@ -394,14 +394,17 @@
   $ cat report.json
   testreport ={
       "test-failure.t": [\{] (re)
+          "cputime": "\s*[\d\.]{5}",  (re)
           "result": "failure", 
           "time": "\s*[\d\.]{5}" (re)
       }, 
       "test-skip.t": {
+          "cputime": "\s*[\d\.]{5}",  (re)
           "result": "skip", 
           "time": "\s*[\d\.]{5}" (re)
       }, 
       "test-success.t": [\{] (re)
+          "cputime": "\s*[\d\.]{5}",  (re)
           "result": "success", 
           "time": "\s*[\d\.]{5}" (re)
       }


More information about the Mercurial-devel mailing list