[PATCH V4] run-tests: added '--json' functionality to store test result data in json file

Gregory Szorc gregory.szorc at gmail.com
Tue Aug 5 09:23:46 CDT 2014


On 8/1/14, 10:49 AM, Anurag Goel wrote:
> @@ -1341,9 +1358,23 @@
>                   os.environ['PYTHONHASHSEED'])
>           if self._runner.options.time:
>               self.printtimes(result.times)
> +        if self._runner.options.json:
> +            self.getjsonfile(result.outcome)
>
>           return result
>
> +    def getjsonfile(self, outcome):
> +        """Store test result info in json format in report.json file."""
> +
> +        os.chdir(self._runner._testdir)

This is a needless chdir. Instead, 
open(os.path.join(self._runner._testdir, 'report.json')), 'w')

> +        fp = open('report.json', 'w')
> +        try:
> +            testdata = dict(outcome)
> +            fp.writelines(("testreport =", (json.dumps(testdata,
> +                                sort_keys=True, indent=4))))
> +        finally:
> +            fp.close()
> +



More information about the Mercurial-devel mailing list