[PATCH] tests: make --json run-tests option create a valid json file

Matt Mackall mpm at selenic.com
Sun Jan 17 21:08:27 CST 2016


On Sun, 2016-01-17 at 11:49 -0800, Pierre-Yves David wrote:
> 
> On 01/16/2016 05:14 PM, Laurent Charignon wrote:
> > # HG changeset patch
> > # User Laurent Charignon <lcharignon at fb.com>
> > # Date 1452993245 28800
> > #      Sat Jan 16 17:14:05 2016 -0800
> > # Node ID cbd838c46ccaded263066898c09e80fda842cdab
> > # Parent  443848eece189002c542339dc1cf84f49a94c824
> > tests: make --json run-tests option create a valid json file
> > 
> > Before this patch, the report.json was not a valid json. This patch adds a
> > test
> > to make sure that the file can be read with the python json module.
> > 
> > diff --git a/tests/run-tests.py b/tests/run-tests.py
> > --- a/tests/run-tests.py
> > +++ b/tests/run-tests.py
> > @@ -1740,7 +1740,7 @@
> >                                       }
> >                               outcome[tc.name] = tres
> >                       jsonout = json.dumps(outcome, sort_keys=True,
> > indent=4)
> > -                    fp.writelines(("testreport =", jsonout))
> > +                    fp.writelines(("{\"testreport\" :", jsonout, "}"))
>
> Oops, good find.
> 
> We should probably use json dumps for everything.
> 
> Adding "outcome" to a "{"testreport": outcome}" dictionnary and using 
> json.dumps on that. The current mix of library and manual general feels 
> strange to me.

Is there any advantage to wrapping the whole thing in another dict?

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list