Patchwork D1883: tests: get run-tests to reliably hand shellquote a string and not a bytes

login
register
mail settings
Submitter phabricator
Date Jan. 18, 2018, 1:38 p.m.
Message ID <differential-rev-PHID-DREV-5tp5pmthkorcc2beeanu-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26872/
State Superseded
Headers show

Comments

phabricator - Jan. 18, 2018, 1:38 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1883

AFFECTED FILES
  tests/run-tests.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 1, 2018, 8:29 p.m.
indygreg accepted this revision.
indygreg added a comment.
This revision is now accepted and ready to land.


  This patch didn't seem correct to me at first because `str` is a different type in Python 2 and 3. But if the desired result is to get a `bytes`, then the logic does seem to check out.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D1883

To: durin42, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1335,7 +1335,11 @@ 
         if os.getenv('MSYSTEM'):
             script.append(b'alias pwd="pwd -W"\n')
         if self._case:
-            script.append(b'TESTCASE=%s\n' % shellquote(self._case))
+            if isinstance(self._case, str):
+                quoted = shellquote(self._case)
+            else:
+                quoted = shellquote(self._case.decode('utf8')).encode('utf8')
+            script.append(b'TESTCASE=%s\n' % quoted)
             script.append(b'export TESTCASE\n')
 
         n = 0