Mercurial > hg
changeset 34802:9c7548eb7d1c
run-tests: move bisect logic to a separate method
This removes 8 space indentation and makes upcoming changes easier.
Differential Revision: https://phab.mercurial-scm.org/D947
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 04 Oct 2017 18:42:24 -0700 |
parents | 1f4249c764f1 |
children | d817bf1fc675 |
files | tests/run-tests.py |
diffstat | 1 files changed, 44 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Wed Oct 04 11:00:04 2017 -0400 +++ b/tests/run-tests.py Wed Oct 04 18:42:24 2017 -0700 @@ -2085,47 +2085,7 @@ savetimes(self._runner._outputdir, result) if failed and self._runner.options.known_good_rev: - bisectcmd = ['hg', 'bisect'] - bisectrepo = self._runner.options.bisect_repo - if bisectrepo: - bisectcmd.extend(['-R', os.path.abspath(bisectrepo)]) - def nooutput(args): - p = subprocess.Popen(args, stderr=subprocess.STDOUT, - stdout=subprocess.PIPE) - p.stdout.read() - p.wait() - for test, msg in result.failures: - nooutput(bisectcmd + ['--reset']), - nooutput(bisectcmd + ['--bad', '.']) - nooutput(bisectcmd + ['--good', - self._runner.options.known_good_rev]) - # TODO: we probably need to forward more options - # that alter hg's behavior inside the tests. - opts = '' - withhg = self._runner.options.with_hg - if withhg: - opts += ' --with-hg=%s ' % shellquote(_strpath(withhg)) - rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts, - test) - sub = subprocess.Popen(bisectcmd + ['--command', rtc], - stderr=subprocess.STDOUT, - stdout=subprocess.PIPE) - data = sub.stdout.read() - sub.wait() - m = re.search( - (br'\nThe first (?P<goodbad>bad|good) revision ' - br'is:\nchangeset: +\d+:(?P<node>[a-f0-9]+)\n.*\n' - br'summary: +(?P<summary>[^\n]+)\n'), - data, (re.MULTILINE | re.DOTALL)) - if m is None: - self.stream.writeln( - 'Failed to identify failure point for %s' % test) - continue - dat = m.groupdict() - verb = 'broken' if dat['goodbad'] == 'bad' else 'fixed' - self.stream.writeln( - '%s %s by %s (%s)' % ( - test, verb, dat['node'], dat['summary'])) + self._bisecttests(t for t, m in result.failures) self.stream.writeln( '# Ran %d tests, %d skipped, %d failed.' % (result.testsRun, skipped + ignored, failed)) @@ -2138,6 +2098,49 @@ return result + def _bisecttests(self, tests): + bisectcmd = ['hg', 'bisect'] + bisectrepo = self._runner.options.bisect_repo + if bisectrepo: + bisectcmd.extend(['-R', os.path.abspath(bisectrepo)]) + def nooutput(args): + p = subprocess.Popen(args, stderr=subprocess.STDOUT, + stdout=subprocess.PIPE) + p.stdout.read() + p.wait() + for test in tests: + nooutput(bisectcmd + ['--reset']), + nooutput(bisectcmd + ['--bad', '.']) + nooutput(bisectcmd + ['--good', + self._runner.options.known_good_rev]) + # TODO: we probably need to forward more options + # that alter hg's behavior inside the tests. + opts = '' + withhg = self._runner.options.with_hg + if withhg: + opts += ' --with-hg=%s ' % shellquote(_strpath(withhg)) + rtc = '%s %s %s %s' % (sys.executable, sys.argv[0], opts, + test) + sub = subprocess.Popen(bisectcmd + ['--command', rtc], + stderr=subprocess.STDOUT, + stdout=subprocess.PIPE) + data = sub.stdout.read() + sub.wait() + m = re.search( + (br'\nThe first (?P<goodbad>bad|good) revision ' + br'is:\nchangeset: +\d+:(?P<node>[a-f0-9]+)\n.*\n' + br'summary: +(?P<summary>[^\n]+)\n'), + data, (re.MULTILINE | re.DOTALL)) + if m is None: + self.stream.writeln( + 'Failed to identify failure point for %s' % test) + continue + dat = m.groupdict() + verb = 'broken' if dat['goodbad'] == 'bad' else 'fixed' + self.stream.writeln( + '%s %s by %s (%s)' % ( + test, verb, dat['node'], dat['summary'])) + def printtimes(self, times): # iolock held by run self.stream.writeln('# Producing time report')