Patchwork run-tests: handle json.dumps divergence

login
register
mail settings
Submitter timeless
Date May 26, 2016, 2:36 a.m.
Message ID <daff05dcd1845481ad5f.1464230204@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/15211/
State Not Applicable
Headers show

Comments

timeless - May 26, 2016, 2:36 a.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1462490239 0
#      Thu May 05 23:17:19 2016 +0000
# Node ID daff05dcd1845481ad5f2164190ca23e6c06d109
# Parent  a3e5e1fb257c4e2ddfd44168b85b748d30230700
# Available At https://bitbucket.org/timeless/mercurial-crew
#              hg pull https://bitbucket.org/timeless/mercurial-crew -r daff05dcd184
run-tests: handle json.dumps divergence

In py2, json.dumps includes a trailing space after a comma at the
end of lines. The py3 behavior which omits the trailing space is
preferable, so we're going to strip it.
timeless - May 26, 2016, 4:36 a.m.
ignore this, it wasn't what i was trying to send.

On Wed, May 25, 2016 at 10:36 PM, timeless <timeless@fmr.im> wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1462490239 0
> #      Thu May 05 23:17:19 2016 +0000
> # Node ID daff05dcd1845481ad5f2164190ca23e6c06d109
> # Parent  a3e5e1fb257c4e2ddfd44168b85b748d30230700
> # Available At https://bitbucket.org/timeless/mercurial-crew
> #              hg pull https://bitbucket.org/timeless/mercurial-crew -r daff05dcd184
> run-tests: handle json.dumps divergence
>
> In py2, json.dumps includes a trailing space after a comma at the
> end of lines. The py3 behavior which omits the trailing space is
> preferable, so we're going to strip it.
>
> diff -r a3e5e1fb257c -r daff05dcd184 tests/run-tests.py
> --- a/tests/run-tests.py        Tue May 10 22:52:26 2016 +0000
> +++ b/tests/run-tests.py        Thu May 05 23:17:19 2016 +0000
> @@ -1836,7 +1836,8 @@
>                                  tres = {'result': res}
>
>                              outcome[tc.name] = tres
> -                    jsonout = json.dumps(outcome, sort_keys=True, indent=4)
> +                    out = json.dumps(outcome, sort_keys=True, indent=4)
> +                    jsonout = '\n'.join([l.rstrip() for l in out.splitlines()])
>                      fp.writelines(("testreport =", jsonout))
>
>              self._runner._checkhglib('Tested')
> diff -r a3e5e1fb257c -r daff05dcd184 tests/test-run-tests.t
> --- a/tests/test-run-tests.t    Tue May 10 22:52:26 2016 +0000
> +++ b/tests/test-run-tests.t    Thu May 05 23:17:19 2016 +0000
> @@ -586,7 +586,7 @@
>    testreport ={
>        "test-bogus.t": {
>            "result": "skip"
> -      },
> +      },
>        "test-failure.t": {
>            "result": "skip"
>        }
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff -r a3e5e1fb257c -r daff05dcd184 tests/run-tests.py
--- a/tests/run-tests.py	Tue May 10 22:52:26 2016 +0000
+++ b/tests/run-tests.py	Thu May 05 23:17:19 2016 +0000
@@ -1836,7 +1836,8 @@ 
                                 tres = {'result': res}
 
                             outcome[tc.name] = tres
-                    jsonout = json.dumps(outcome, sort_keys=True, indent=4)
+                    out = json.dumps(outcome, sort_keys=True, indent=4)
+                    jsonout = '\n'.join([l.rstrip() for l in out.splitlines()])
                     fp.writelines(("testreport =", jsonout))
 
             self._runner._checkhglib('Tested')
diff -r a3e5e1fb257c -r daff05dcd184 tests/test-run-tests.t
--- a/tests/test-run-tests.t	Tue May 10 22:52:26 2016 +0000
+++ b/tests/test-run-tests.t	Thu May 05 23:17:19 2016 +0000
@@ -586,7 +586,7 @@ 
   testreport ={
       "test-bogus.t": {
           "result": "skip"
-      }, 
+      },
       "test-failure.t": {
           "result": "skip"
       }