Patchwork D947: run-tests: move bisect logic to a separate method

login
register
mail settings
Submitter phabricator
Date Oct. 17, 2017, 12:10 p.m.
Message ID <fd0021f78733efeab48ae0fc240a48cb@localhost.localdomain>
Download mbox | patch
Permalink /patch/25085/
State Not Applicable
Headers show

Comments

phabricator - Oct. 17, 2017, 12:10 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9c7548eb7d1c: run-tests: move bisect logic to a separate method (authored by quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D947?vs=2448&id=2899

REVISION DETAIL
  https://phab.mercurial-scm.org/D947

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




To: quark, #hg-reviewers, ryanmce
Cc: mercurial-devel

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -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')