Patchwork D948: run-tests: extract Popen logic to a single method

login
register
mail settings
Submitter phabricator
Date Oct. 17, 2017, 12:10 p.m.
Message ID <acbc5ac0b885311ab5497a2872432c3d@localhost.localdomain>
Download mbox | patch
Permalink /patch/25086/
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 rHGd817bf1fc675: run-tests: extract Popen logic to a single method (authored by quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D948?vs=2889&id=2900

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

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




To: quark, #hg-reviewers, ryanmce
Cc: ryanmce, dlax, 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
@@ -2103,29 +2103,25 @@ 
         bisectrepo = self._runner.options.bisect_repo
         if bisectrepo:
             bisectcmd.extend(['-R', os.path.abspath(bisectrepo)])
-        def nooutput(args):
+        def pread(args):
             p = subprocess.Popen(args, stderr=subprocess.STDOUT,
                                  stdout=subprocess.PIPE)
-            p.stdout.read()
+            data = p.stdout.read()
             p.wait()
+            return data
         for test in tests:
-            nooutput(bisectcmd + ['--reset']),
-            nooutput(bisectcmd + ['--bad', '.'])
-            nooutput(bisectcmd + ['--good',
-                      self._runner.options.known_good_rev])
+            pread(bisectcmd + ['--reset']),
+            pread(bisectcmd + ['--bad', '.'])
+            pread(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()
+            data = pread(bisectcmd + ['--command', rtc])
             m = re.search(
                 (br'\nThe first (?P<goodbad>bad|good) revision '
                  br'is:\nchangeset: +\d+:(?P<node>[a-f0-9]+)\n.*\n'