run-tests: cast --with-hg option to bytes consistently at parseargs()
authorYuya Nishihara <yuya@tcha.org>
Sun, 07 Feb 2016 16:00:05 +0900
changeset 28097 81eee5786174
parent 28096 62ef44273678
child 28098 d7b0e81b84c2
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.
tests/run-tests.py
--- a/tests/run-tests.py	Sun Feb 07 15:53:02 2016 +0900
+++ b/tests/run-tests.py	Sun Feb 07 16:00:05 2016 +0900
@@ -285,11 +285,12 @@
         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])))
@@ -1922,12 +1923,6 @@
         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')