[PATCH] runtests: add 'diff' entry in json report
Laurent Charignon
lcharignon at fb.com
Tue Jan 5 21:26:42 UTC 2016
> On Jan 5, 2016, at 1:22 PM, Laurent Charignon <lcharignon at fb.com> wrote:
>
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1452028810 28800
> # Tue Jan 05 13:20:10 2016 -0800
> # Node ID a57990a4292548eff520b32fec567c67a33c0d96
> # Parent b8405d739149cdd6d8d9bd5e3dd2ad8487b1f09a
> runtests: add 'diff' entry in json report
>
> This patch adds to the json report the "diff" between expected and observed
> result. This diff can be useful for automatically filing bug report on failing
> tests.
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -1688,7 +1688,9 @@ class TextTestRunner(unittest.TextTestRu
> 'cuser': ('%0.3f' % timesd[tc.name][0]),
> 'csys': ('%0.3f' % timesd[tc.name][1]),
> 'start': ('%0.3f' % timesd[tc.name][3]),
> - 'end': ('%0.3f' % timesd[tc.name][4])}
> + 'end': ('%0.3f' % timesd[tc.name][4]),
> + 'diff': result.faildata.get(tc.name, ''),
> + }
> outcome[tc.name] = tres
> jsonout = json.dumps(outcome, sort_keys=True, indent=4)
> fp.writelines(("testreport =", jsonout))
> diff --git a/tests/test-run-tests.t b/tests/test-run-tests.t
> --- a/tests/test-run-tests.t
> +++ b/tests/test-run-tests.t
> @@ -530,6 +530,7 @@ test for --json
> "test-failure.t": [\{] (re)
> "csys": "\s*[\d\.]{4,5}", ? (re)
> "cuser": "\s*[\d\.]{4,5}", ? (re)
> + "diff": "--- $TESTTMP/test-failure.t\n+++ $TESTTMP/test-failure.t.err\n@@ -1,4 +1,4 @@\n $ echo babar\n- rataxes\n+ babar\n This is a noop statement so that\n this test is still more bytes
Actually, this test might fail on windows because of the \n. I will send a v2
Thanks,
Laurent
> than success.\n",
> "end": "\s*[\d\.]{4,5}", ? (re)
> "result": "failure", ? (re)
> "start": "\s*[\d\.]{4,5}", ? (re)
> @@ -538,6 +539,7 @@ test for --json
> "test-skip.t": {
> "csys": "\s*[\d\.]{4,5}", ? (re)
> "cuser": "\s*[\d\.]{4,5}", ? (re)
> + "diff": "",
> "end": "\s*[\d\.]{4,5}", ? (re)
> "result": "skip", ? (re)
> "start": "\s*[\d\.]{4,5}", ? (re)
> @@ -546,6 +548,7 @@ test for --json
> "test-success.t": [\{] (re)
> "csys": "\s*[\d\.]{4,5}", ? (re)
> "cuser": "\s*[\d\.]{4,5}", ? (re)
> + "diff": "",
> "end": "\s*[\d\.]{4,5}", ? (re)
> "result": "success", ? (re)
> "start": "\s*[\d\.]{4,5}", ? (re)
> @@ -575,6 +578,7 @@ Test that failed test accepted through i
> "test-failure.t": [\{] (re)
> "csys": "\s*[\d\.]{4,5}", ? (re)
> "cuser": "\s*[\d\.]{4,5}", ? (re)
> + "diff": "",
> "end": "\s*[\d\.]{4,5}", ? (re)
> "result": "success", ? (re)
> "start": "\s*[\d\.]{4,5}", ? (re)
> @@ -583,6 +587,7 @@ Test that failed test accepted through i
> "test-skip.t": {
> "csys": "\s*[\d\.]{4,5}", ? (re)
> "cuser": "\s*[\d\.]{4,5}", ? (re)
> + "diff": "",
> "end": "\s*[\d\.]{4,5}", ? (re)
> "result": "skip", ? (re)
> "start": "\s*[\d\.]{4,5}", ? (re)
> @@ -591,6 +596,7 @@ Test that failed test accepted through i
> "test-success.t": [\{] (re)
> "csys": "\s*[\d\.]{4,5}", ? (re)
> "cuser": "\s*[\d\.]{4,5}", ? (re)
> + "diff": "",
> "end": "\s*[\d\.]{4,5}", ? (re)
> "result": "success", ? (re)
> "start": "\s*[\d\.]{4,5}", ? (re)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list