Patchwork [STABLE,v2] py3: decode bytes before logging in run-tests.py

login
register
mail settings
Submitter Denis Laxalde
Date Oct. 21, 2019, 8:31 p.m.
Message ID <c704b455ac0128c2f126.1571689917@marimba>
Download mbox | patch
Permalink /patch/42517/
State Accepted
Headers show

Comments

Denis Laxalde - Oct. 21, 2019, 8:31 p.m.
# HG changeset patch
# User Denis Laxalde <denis@laxalde.org>
# Date 1571650001 -7200
#      Mon Oct 21 11:26:41 2019 +0200
# Branch stable
# Node ID c704b455ac0128c2f126e212e3edd385cafaf1c1
# Parent  dcf396551305254d05dac2ef205f75f5170340cb
py3: decode bytes before logging in run-tests.py

Avoids messages like "Found prerequisite b'diff' at b'/usr/bin/diff'"
under Python 3.
Yuya Nishihara - Oct. 22, 2019, 1:04 a.m.
On Mon, 21 Oct 2019 22:31:57 +0200, Denis Laxalde wrote:
> # HG changeset patch
> # User Denis Laxalde <denis@laxalde.org>
> # Date 1571650001 -7200
> #      Mon Oct 21 11:26:41 2019 +0200
> # Branch stable
> # Node ID c704b455ac0128c2f126e212e3edd385cafaf1c1
> # Parent  dcf396551305254d05dac2ef205f75f5170340cb
> py3: decode bytes before logging in run-tests.py

Queued for stable, thanks.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1504,7 +1504,7 @@  class PythonTest(Test):
         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 @@  class TTest(Test):
                 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 @@  class TestRunner(object):
                 '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 @@  class TestRunner(object):
         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 @@  class TestRunner(object):
         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 @@  class TestRunner(object):
             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):