Patchwork [2,of,3] py3: ensure run-tests environment is uniformly str

login
register
mail settings
Submitter Matt Harbison
Date Sept. 15, 2018, 4:31 a.m.
Message ID <289c7157ec4510c619e9.1536985896@Envy>
Download mbox | patch
Permalink /patch/34686/
State Accepted
Headers show

Comments

Matt Harbison - Sept. 15, 2018, 4:31 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1536980658 14400
#      Fri Sep 14 23:04:18 2018 -0400
# Node ID 289c7157ec4510c619e9e7fdd9ac4995e13ce73e
# Parent  bae09abf6ea2f721c78f11a21dd8db9cc8198378
py3: ensure run-tests environment is uniformly str

subprocess.popen() was crashing, and when I printed out `env`, all of the keys
and most of the values were str.  Except these.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1004,7 +1004,7 @@  class Test(unittest.TestCase):
         environment."""
         # Put the restoreenv script inside self._threadtmp
         scriptpath = os.path.join(self._threadtmp, b'restoreenv.sh')
-        testenv['HGTEST_RESTOREENV'] = scriptpath
+        testenv['HGTEST_RESTOREENV'] = _strpath(scriptpath)
 
         # Only restore environment variable names that the shell allows
         # us to export.
@@ -1036,15 +1036,15 @@  class Test(unittest.TestCase):
         env = os.environ.copy()
         env['PYTHONUSERBASE'] = sysconfig.get_config_var('userbase') or ''
         env['HGEMITWARNINGS'] = '1'
-        env['TESTTMP'] = self._testtmp
+        env['TESTTMP'] = _strpath(self._testtmp)
         env['TESTNAME'] = self.name
-        env['HOME'] = self._testtmp
+        env['HOME'] = _strpath(self._testtmp)
         # This number should match portneeded in _getport
         for port in xrange(3):
             # This list should be parallel to _portmap in _getreplacements
             defineport(port)
-        env["HGRCPATH"] = os.path.join(self._threadtmp, b'.hgrc')
-        env["DAEMON_PIDS"] = os.path.join(self._threadtmp, b'daemon.pids')
+        env["HGRCPATH"] = _strpath(os.path.join(self._threadtmp, b'.hgrc'))
+        env["DAEMON_PIDS"] = _strpath(os.path.join(self._threadtmp, b'daemon.pids'))
         env["HGEDITOR"] = ('"' + sys.executable + '"'
                            + ' -c "import sys; sys.exit(0)"')
         env["HGMERGE"] = "internal:merge"
@@ -1069,7 +1069,7 @@  class Test(unittest.TestCase):
 
         # LOCALIP could be ::1 or 127.0.0.1. Useful for tests that require raw
         # IP addresses.
-        env['LOCALIP'] = self._localip()
+        env['LOCALIP'] = _strpath(self._localip())
 
         # Reset some environment variables to well-known values so that
         # the tests produce repeatable output.