# HG changeset patch # User Jun Wu # Date 1507168218 25200 # Node ID d817bf1fc675c0dea379641768b3f5b95f8dedf4 # Parent 9c7548eb7d1cbc07cb1bcc45300f4f8e0a321d15 run-tests: extract Popen logic to a single method This removes 3 lines in total LOC and makes the upcoming changes easier. Differential Revision: https://phab.mercurial-scm.org/D948 diff -r 9c7548eb7d1c -r d817bf1fc675 tests/run-tests.py --- a/tests/run-tests.py Wed Oct 04 18:42:24 2017 -0700 +++ b/tests/run-tests.py Wed Oct 04 18:50:18 2017 -0700 @@ -2103,16 +2103,16 @@ 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 = '' @@ -2121,11 +2121,7 @@ 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 (?Pbad|good) revision ' br'is:\nchangeset: +\d+:(?P[a-f0-9]+)\n.*\n'