changeset 43309:b4b1131187c4 stable

py3: decode bytes before logging in run-tests.py Avoids messages like "Found prerequisite b'diff' at b'/usr/bin/diff'" under Python 3.
author Denis Laxalde <denis@laxalde.org>
date Mon, 21 Oct 2019 11:26:41 +0200
parents dcf396551305
children 7574ccd87200
files tests/run-tests.py
diffstat 1 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/tests/run-tests.py	Mon Oct 21 11:14:28 2019 -0400
+++ b/tests/run-tests.py	Mon Oct 21 11:26:41 2019 +0200
@@ -1504,7 +1504,7 @@
         py3switch = self._py3warnings and b' -3' or b''
         # Quote the python(3) executable for Windows
         cmd = b'"%s"%s "%s"' % (PYTHON, py3switch, self.path)
-        vlog("# Running", cmd)
+        vlog("# Running", cmd.decode("utf-8"))
         normalizenewlines = os.name == 'nt'
         result = self._runcommand(cmd, env, normalizenewlines=normalizenewlines)
         if self._aborted:
@@ -1589,7 +1589,7 @@
                 f.write(l)
 
         cmd = b'%s "%s"' % (self._shell, fname)
-        vlog("# Running", cmd)
+        vlog("# Running", cmd.decode("utf-8"))
 
         exitcode, output = self._runcommand(cmd, env)
 
@@ -3111,12 +3111,16 @@
                 'extensions.logexceptions=%s' % logexceptions.decode('utf-8')
             )
 
-        vlog("# Using TESTDIR", self._testdir)
-        vlog("# Using RUNTESTDIR", osenvironb[b'RUNTESTDIR'])
-        vlog("# Using HGTMP", self._hgtmp)
+        vlog("# Using TESTDIR", _strpath(self._testdir))
+        vlog("# Using RUNTESTDIR", _strpath(osenvironb[b'RUNTESTDIR']))
+        vlog("# Using HGTMP", _strpath(self._hgtmp))
         vlog("# Using PATH", os.environ["PATH"])
-        vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH])
-        vlog("# Writing to directory", self._outputdir)
+        vlog(
+            "# Using",
+            _strpath(IMPL_PATH),
+            _strpath(osenvironb[IMPL_PATH]),
+        )
+        vlog("# Writing to directory", _strpath(self._outputdir))
 
         try:
             return self._runtests(testdescs) or 0
@@ -3357,7 +3361,7 @@
         if self.options.keep_tmpdir:
             return
 
-        vlog("# Cleaning up HGTMP", self._hgtmp)
+        vlog("# Cleaning up HGTMP", _strpath(self._hgtmp))
         shutil.rmtree(self._hgtmp, True)
         for f in self._createdfiles:
             try:
@@ -3468,7 +3472,7 @@
         makedirs(self._pythondir)
         makedirs(self._bindir)
 
-        vlog("# Running", cmd)
+        vlog("# Running", cmd.decode("utf-8"))
         if subprocess.call(_strpath(cmd), shell=True) == 0:
             if not self.options.verbose:
                 try:
@@ -3643,13 +3647,11 @@
             if os.name == 'nt' and not p.endswith(b'.exe'):
                 p += b'.exe'
             found = self._findprogram(p)
+            p = p.decode("utf-8")
             if found:
-                vlog("# Found prerequisite", p, "at", found)
+                vlog("# Found prerequisite", p, "at", _strpath(found))
             else:
-                print(
-                    "WARNING: Did not find prerequisite tool: %s "
-                    % p.decode("utf-8")
-                )
+                print("WARNING: Did not find prerequisite tool: %s " % p)
 
 
 def aggregateexceptions(path):