[PATCH 1 of 2 V2] run-tests: added '--json' functionality to store timing data in json file
Anurag Goel
anurag.dsps at gmail.com
Mon Jun 23 04:56:00 CDT 2014
On Mon, Jun 23, 2014 at 2:29 PM, Pierre-Yves David <
pierre-yves.david at ens-lyon.org> wrote:
>
>
> On 06/22/2014 06:44 AM, Anurag Goel wrote:
>
>> # HG changeset patch
>> # User anuraggoel <anurag.dsps at gmail.com>
>> # Date 1403430215 -19800
>> # Sun Jun 22 15:13:35 2014 +0530
>> # Node ID bdb3d7c108ba9a5ba38e1b3282dd18115ba6eed9
>> # Parent f6e0718c2101207ba62ceccc7ca916f4e7d83b1d
>> run-tests: added '--json' functionality to store timing data in json file
>>
>
> Why restricting this to timing data? Could we includes the success
> information too ?
Yes, we can add success information too. But i am waiting for basic timing
information get accepted before adding more information up to next level.
>
>
>> This patch added a new functionality '--json'. While testing, if '--json'
>> is enabled then timing data gets stored in newly created "report.json"
>> file,
>> in the following format.
>> testreport ={
>> "test-xyz.t": 6.181909084320068
>> }
>>
>> This "report.json" file will further accessed by html/javascript file to
>> plot graph between testname Vs testime.
>>
>> diff -r f6e0718c2101 -r bdb3d7c108ba tests/run-tests.py
>> --- a/tests/run-tests.py Sun Jun 22 01:35:29 2014 +0530
>> +++ b/tests/run-tests.py Sun Jun 22 15:13:35 2014 +0530
>> @@ -58,6 +58,7 @@
>> import killdaemons as killmod
>> import Queue as queue
>> import unittest
>> +import json
>>
>> processlock = threading.Lock()
>>
>> @@ -185,6 +186,8 @@
>> " (default: $%s or %d)" % defaults['timeout'])
>> parser.add_option("--time", action="store_true",
>> help="time how long each test takes")
>> + parser.add_option("--json", action="store_true",
>> + help="store timing data in 'report.json' file")
>> parser.add_option("--tmpdir", type="string",
>> help="run tests in the given temporary directory"
>> " (implies --keep-tmpdir)")
>> @@ -1341,9 +1344,19 @@
>> os.environ['PYTHONHASHSEED'])
>> if self._runner.options.time:
>> self.printtimes(result.times)
>> + if self._runner.options.json:
>> + self.getjsonfile(result.times)
>>
>> return result
>>
>> + def getjsonfile(self, times):
>> + """Store timing data in json format in report.json file. """
>>
>
> extra space
>
> +
>> + fp = open("report.json", "w")
>> + timedata = dict(times)
>> + fp.writelines(("testreport =", (json.dumps(timedata, indent=2))))
>> + fp.close()
>> +
>> def printtimes(self, times):
>> self.stream.writeln('# Producing time report')
>> times.sort(key=lambda t: (t[1], t[0]), reverse=True)
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel at selenic.com
>> http://selenic.com/mailman/listinfo/mercurial-devel
>>
>>
> --
> Pierre-Yves David
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20140623/5564884c/attachment.html>
More information about the Mercurial-devel
mailing list