Mercurial > hg-stable
changeset 24981:012b79d549d8
run-tests: refactor json entry creation logic
We are about to add more timing related information to each entry. Having a
single place where the json entry is created is going to be much simpler.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 08 May 2015 10:51:18 -0700 |
parents | 2dadd81c68fb |
children | 5c15f7e0f52b |
files | tests/run-tests.py |
diffstat | 1 files changed, 10 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Thu May 07 23:20:24 2015 -0700 +++ b/tests/run-tests.py Fri May 08 10:51:18 2015 -0700 @@ -1535,26 +1535,16 @@ timesd[test] = (real, cuser, csys) outcome = {} - for tc in result.successes: - testresult = {'result': 'success', - 'time': ('%0.3f' % timesd[tc.name][0]), - 'cuser': ('%0.3f' % timesd[tc.name][1]), - 'csys': ('%0.3f' % timesd[tc.name][2])} - outcome[tc.name] = testresult - - for tc, error in result.failures: - testresult = {'result': 'failure', - 'time': ('%0.3f' % timesd[tc.name][0]), - 'cuser': ('%0.3f' % timesd[tc.name][1]), - 'csys': ('%0.3f' % timesd[tc.name][2])} - outcome[tc.name] = testresult - - for tc, reason in result.skipped: - testresult = {'result': 'skip', - 'time': ('%0.3f' % timesd[tc.name][0]), - 'cuser': ('%0.3f' % timesd[tc.name][1]), - 'csys': ('%0.3f' % timesd[tc.name][2])} - outcome[tc.name] = testresult + groups = [('success', ((tc, None) for tc in result.successes)), + ('failure', result.failures), + ('skip', result.skipped)] + for res, testcases in groups: + for tc, __ in testcases: + testresult = {'result': res, + 'time': ('%0.3f' % timesd[tc.name][0]), + 'cuser': ('%0.3f' % timesd[tc.name][1]), + 'csys': ('%0.3f' % timesd[tc.name][2])} + outcome[tc.name] = testresult jsonout = json.dumps(outcome, sort_keys=True, indent=4) fp.writelines(("testreport =", jsonout))