Mercurial > hg
comparison tests/run-tests.py @ 44452:9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Built with:
hg files 'set:**.py - mercurial/thirdparty/** - "contrib/python-zstandard/**" - hgext/fsmonitor/pywatchman/**' | xargs pyupgrade --keep-percent-format --keep-extraneous-parens
and then blackened. pyupgrade comes from
https://github.com/asottile/pyupgrade with a patch to let me preserve
extraneous parens (which we use for marking strings that shouldn't be
translated), and lets us clean up a bunch of idioms that have cruftily
accumulated over the years.
# skip-blame no-op automated code cleanups
Differential Revision: https://phab.mercurial-scm.org/D8255
author | Augie Fackler <augie@google.com> |
---|---|
date | Fri, 06 Mar 2020 13:27:41 -0500 |
parents | ff72bd52d56a |
children | 408a4eb41453 |
comparison
equal
deleted
inserted
replaced
44449:ff72bd52d56a | 44452:9d2b2df2c2ba |
---|---|
1551 SKIPPED_PREFIX = b'skipped: ' | 1551 SKIPPED_PREFIX = b'skipped: ' |
1552 FAILED_PREFIX = b'hghave check failed: ' | 1552 FAILED_PREFIX = b'hghave check failed: ' |
1553 NEEDESCAPE = re.compile(br'[\x00-\x08\x0b-\x1f\x7f-\xff]').search | 1553 NEEDESCAPE = re.compile(br'[\x00-\x08\x0b-\x1f\x7f-\xff]').search |
1554 | 1554 |
1555 ESCAPESUB = re.compile(br'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub | 1555 ESCAPESUB = re.compile(br'[\x00-\x08\x0b-\x1f\\\x7f-\xff]').sub |
1556 ESCAPEMAP = dict((bchr(i), br'\x%02x' % i) for i in range(256)) | 1556 ESCAPEMAP = {bchr(i): br'\x%02x' % i for i in range(256)} |
1557 ESCAPEMAP.update({b'\\': b'\\\\', b'\r': br'\r'}) | 1557 ESCAPEMAP.update({b'\\': b'\\\\', b'\r': br'\r'}) |
1558 | 1558 |
1559 def __init__(self, path, *args, **kwds): | 1559 def __init__(self, path, *args, **kwds): |
1560 # accept an extra "case" parameter | 1560 # accept an extra "case" parameter |
1561 case = kwds.pop('case', []) | 1561 case = kwds.pop('case', []) |
2522 | 2522 |
2523 | 2523 |
2524 def savetimes(outputdir, result): | 2524 def savetimes(outputdir, result): |
2525 saved = dict(loadtimes(outputdir)) | 2525 saved = dict(loadtimes(outputdir)) |
2526 maxruns = 5 | 2526 maxruns = 5 |
2527 skipped = set([str(t[0]) for t in result.skipped]) | 2527 skipped = {str(t[0]) for t in result.skipped} |
2528 for tdata in result.times: | 2528 for tdata in result.times: |
2529 test, real = tdata[0], tdata[3] | 2529 test, real = tdata[0], tdata[3] |
2530 if test not in skipped: | 2530 if test not in skipped: |
2531 ts = saved.setdefault(test, []) | 2531 ts = saved.setdefault(test, []) |
2532 ts.append(real) | 2532 ts.append(real) |
2735 self.stream.writeln(cols % (start, end, cuser, csys, real, test)) | 2735 self.stream.writeln(cols % (start, end, cuser, csys, real, test)) |
2736 | 2736 |
2737 @staticmethod | 2737 @staticmethod |
2738 def _writexunit(result, outf): | 2738 def _writexunit(result, outf): |
2739 # See http://llg.cubic.org/docs/junit/ for a reference. | 2739 # See http://llg.cubic.org/docs/junit/ for a reference. |
2740 timesd = dict((t[0], t[3]) for t in result.times) | 2740 timesd = {t[0]: t[3] for t in result.times} |
2741 doc = minidom.Document() | 2741 doc = minidom.Document() |
2742 s = doc.createElement('testsuite') | 2742 s = doc.createElement('testsuite') |
2743 s.setAttribute('errors', "0") # TODO | 2743 s.setAttribute('errors', "0") # TODO |
2744 s.setAttribute('failures', str(len(result.failures))) | 2744 s.setAttribute('failures', str(len(result.failures))) |
2745 s.setAttribute('name', 'run-tests') | 2745 s.setAttribute('name', 'run-tests') |
3341 | 3341 |
3342 refpath = os.path.join(getcwdb(), path) | 3342 refpath = os.path.join(getcwdb(), path) |
3343 tmpdir = os.path.join(self._hgtmp, b'child%d' % count) | 3343 tmpdir = os.path.join(self._hgtmp, b'child%d' % count) |
3344 | 3344 |
3345 # extra keyword parameters. 'case' is used by .t tests | 3345 # extra keyword parameters. 'case' is used by .t tests |
3346 kwds = dict((k, testdesc[k]) for k in ['case'] if k in testdesc) | 3346 kwds = {k: testdesc[k] for k in ['case'] if k in testdesc} |
3347 | 3347 |
3348 t = testcls( | 3348 t = testcls( |
3349 refpath, | 3349 refpath, |
3350 self._outputdir, | 3350 self._outputdir, |
3351 tmpdir, | 3351 tmpdir, |