From patchwork Fri Feb 12 16:12:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 6, chg-test] run-tests: cast --with-hg option to bytes consistently at parseargs() From: Yuya Nishihara X-Patchwork-Id: 13139 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sat, 13 Feb 2016 01:12:35 +0900 # HG changeset patch # User Yuya Nishihara # Date 1454828405 -32400 # Sun Feb 07 16:00:05 2016 +0900 # Node ID c875a2298a7e1af285f8acb60fdb66deb1732bc3 # Parent 8ffb546b8ae698d91f34db6a933c32883f702e66 run-tests: cast --with-hg option to bytes consistently at parseargs() parseargs() sets bytes to options.with_hg if --local is specified, so do the same for --with-hg. diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -285,11 +285,12 @@ def parseargs(args, parser): options.pure = True if options.with_hg: - options.with_hg = os.path.realpath(os.path.expanduser(options.with_hg)) + options.with_hg = os.path.realpath( + os.path.expanduser(_bytespath(options.with_hg))) if not (os.path.isfile(options.with_hg) and os.access(options.with_hg, os.X_OK)): parser.error('--with-hg must specify an executable hg script') - if not os.path.basename(options.with_hg) == 'hg': + if not os.path.basename(options.with_hg) == b'hg': sys.stderr.write('warning: --with-hg should specify an hg script\n') if options.local: testdir = os.path.dirname(_bytespath(os.path.realpath(sys.argv[0]))) @@ -1925,12 +1926,6 @@ class TestRunner(object): if self.options.with_hg: self._installdir = None whg = self.options.with_hg - # If --with-hg is not specified, we have bytes already, - # but if it was specified in python3 we get a str, so we - # have to encode it back into a bytes. - if PYTHON3: - if not isinstance(whg, bytes): - whg = _bytespath(whg) self._bindir = os.path.dirname(os.path.realpath(whg)) assert isinstance(self._bindir, bytes) self._tmpbindir = os.path.join(self._hgtmp, b'install', b'bin')