changeset 25042:201823c50610

run-tests: work around with_hg being bytes or string depending on provenance
author Augie Fackler <augie@google.com>
date Sun, 12 Apr 2015 15:35:57 -0400
parents 09c71e3da704
children facaceeb85ac
files tests/run-tests.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Tue Apr 14 16:03:04 2015 -0400
+++ b/tests/run-tests.py	Sun Apr 12 15:35:57 2015 -0400
@@ -1709,8 +1709,15 @@
 
         if self.options.with_hg:
             self._installdir = None
-            self._bindir = os.path.dirname(os.path.realpath(
-                                           self.options.with_hg))
+            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 sys.version_info[0] == 3:
+                if not isinstance(whg, bytes):
+                    whg = whg.encode('utf-8')
+            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')
             os.makedirs(self._tmpbindir)