Patchwork [4,of,4,v2] run-tests: handle json.dumps divergence

login
register
mail settings
Submitter timeless
Date May 11, 2016, 5:51 p.m.
Message ID <3fb8b57b459449a97de2.1462989087@gcc2-power8.osuosl.org>
Download mbox | patch
Permalink /patch/15030/
State Accepted
Commit daff05dcd1845481ad5f2164190ca23e6c06d109
Headers show

Comments

timeless - May 11, 2016, 5:51 p.m.
# HG changeset patch
# User timeless <timeless@mozdev.org>
# Date 1462490239 0
#      Thu May 05 23:17:19 2016 +0000
# Node ID 3fb8b57b459449a97de29b3828fe75baada38eac
# Parent  ac615a1325bf2d0a2d8c87ae32e755c5d6f56e52
# EXP-Topic runtests
# Available At bb://timeless/mercurial-crew
#              hg pull bb://timeless/mercurial-crew -r 3fb8b57b4594
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.
Augie Fackler - May 23, 2016, 7:21 p.m.
On Wed, May 11, 2016 at 05:51:27PM +0000, timeless wrote:
> # HG changeset patch
> # User timeless <timeless@mozdev.org>
> # Date 1462490239 0
> #      Thu May 05 23:17:19 2016 +0000
> # Node ID 3fb8b57b459449a97de29b3828fe75baada38eac
> # Parent  ac615a1325bf2d0a2d8c87ae32e755c5d6f56e52
> # EXP-Topic runtests
> # Available At bb://timeless/mercurial-crew
> #              hg pull bb://timeless/mercurial-crew -r 3fb8b57b4594
> run-tests: handle json.dumps divergence

I'm taking patches 1, 2, and 4. It sounds like we might want a new version of 3?

>
> 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 ac615a1325bf -r 3fb8b57b4594 tests/run-tests.py
> --- a/tests/run-tests.py	Tue Apr 05 01:35:58 2016 +0000
> +++ b/tests/run-tests.py	Thu May 05 23:17:19 2016 +0000
> @@ -1843,7 +1843,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 ac615a1325bf -r 3fb8b57b4594 tests/test-run-tests.t
> --- a/tests/test-run-tests.t	Tue Apr 05 01:35:58 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 ac615a1325bf -r 3fb8b57b4594 tests/run-tests.py
--- a/tests/run-tests.py	Tue Apr 05 01:35:58 2016 +0000
+++ b/tests/run-tests.py	Thu May 05 23:17:19 2016 +0000
@@ -1843,7 +1843,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 ac615a1325bf -r 3fb8b57b4594 tests/test-run-tests.t
--- a/tests/test-run-tests.t	Tue Apr 05 01:35:58 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"
       }