run-tests: add 'diff' entry in json report
authorLaurent Charignon <lcharignon@fb.com>
Tue, 05 Jan 2016 13:33:09 -0800
changeset 27686 df142b77b4c2
parent 27685 9fbae70faf65
child 27687 4cea1b918b21
run-tests: 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.
tests/run-tests.py
tests/test-run-tests.t
--- a/tests/run-tests.py	Tue Dec 01 13:08:05 2015 -0500
+++ b/tests/run-tests.py	Tue Jan 05 13:33:09 2016 -0800
@@ -1731,7 +1731,9 @@
                                     '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))
--- a/tests/test-run-tests.t	Tue Dec 01 13:08:05 2015 -0500
+++ b/tests/test-run-tests.t	Tue Jan 05 13:33:09 2016 -0800
@@ -530,6 +530,7 @@
       "test-failure.t": [\{] (re)
           "csys": "\s*[\d\.]{4,5}", ? (re)
           "cuser": "\s*[\d\.]{4,5}", ? (re)
+          "diff": "---.+\+\+\+.+", ? (re)
           "end": "\s*[\d\.]{4,5}", ? (re)
           "result": "failure", ? (re)
           "start": "\s*[\d\.]{4,5}", ? (re)
@@ -538,6 +539,7 @@
       "test-skip.t": {
           "csys": "\s*[\d\.]{4,5}", ? (re)
           "cuser": "\s*[\d\.]{4,5}", ? (re)
+          "diff": "", ? (re)
           "end": "\s*[\d\.]{4,5}", ? (re)
           "result": "skip", ? (re)
           "start": "\s*[\d\.]{4,5}", ? (re)
@@ -546,6 +548,7 @@
       "test-success.t": [\{] (re)
           "csys": "\s*[\d\.]{4,5}", ? (re)
           "cuser": "\s*[\d\.]{4,5}", ? (re)
+          "diff": "", ? (re)
           "end": "\s*[\d\.]{4,5}", ? (re)
           "result": "success", ? (re)
           "start": "\s*[\d\.]{4,5}", ? (re)
@@ -575,6 +578,7 @@
       "test-failure.t": [\{] (re)
           "csys": "\s*[\d\.]{4,5}", ? (re)
           "cuser": "\s*[\d\.]{4,5}", ? (re)
+          "diff": "", ? (re)
           "end": "\s*[\d\.]{4,5}", ? (re)
           "result": "success", ? (re)
           "start": "\s*[\d\.]{4,5}", ? (re)
@@ -583,6 +587,7 @@
       "test-skip.t": {
           "csys": "\s*[\d\.]{4,5}", ? (re)
           "cuser": "\s*[\d\.]{4,5}", ? (re)
+          "diff": "", ? (re)
           "end": "\s*[\d\.]{4,5}", ? (re)
           "result": "skip", ? (re)
           "start": "\s*[\d\.]{4,5}", ? (re)
@@ -591,6 +596,7 @@
       "test-success.t": [\{] (re)
           "csys": "\s*[\d\.]{4,5}", ? (re)
           "cuser": "\s*[\d\.]{4,5}", ? (re)
+          "diff": "", ? (re)
           "end": "\s*[\d\.]{4,5}", ? (re)
           "result": "success", ? (re)
           "start": "\s*[\d\.]{4,5}", ? (re)