Patchwork run-tests: added 'cputime' info in report.json file

login
register
mail settings
Submitter Anurag Goel
Date Sept. 19, 2014, 1:28 a.m.
Message ID <a7f6902e888f86d1ba80.1411090128@ubuntu.ubuntu-domain>
Download mbox | patch
Permalink /patch/5879/
State Accepted
Headers show

Comments

Anurag Goel - Sept. 19, 2014, 1:28 a.m.
# HG changeset patch
# User anuraggoel <anurag.dsps@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"
    }
}
Pierre-Yves David - Sept. 19, 2014, 1:32 a.m.
On 09/18/2014 06:28 PM, Anurag Goel wrote:
> # HG changeset patch
> # User anuraggoel <anurag.dsps@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.

You should probably keep the two values explicitly. Tools using the json 
can do the addition themself.
Anurag Goel - Sept. 19, 2014, 1:37 a.m.
On Fri, Sep 19, 2014 at 7:02 AM, Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

>
>
> On 09/18/2014 06:28 PM, Anurag Goel wrote:
>
>> # HG changeset patch
>> # User anuraggoel <anurag.dsps@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.
>>
>
> You should probably keep the two values explicitly. Tools using the json
> can do the addition themself.
>
> Okay, i will send the V2  of it.

>
> --
> Pierre-Yves David
>

Patch

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)
       }