THRIFT-3436 cross test fails with "UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 20: ordinal not in range(128)"
Client: Test Suite
Patch: Jens Geyer
diff --git a/test/crossrunner/report.py b/test/crossrunner/report.py
index a284d2b..6ffc8e2 100644
--- a/test/crossrunner/report.py
+++ b/test/crossrunner/report.py
@@ -84,7 +84,7 @@
@classmethod
def test_logfile(cls, test_name, prog_kind, dir=None):
relpath = os.path.join('log', '%s_%s.log' % (test_name, prog_kind))
- return relpath if not dir else os.path.realpath(os.path.join(dir, relpath))
+ return relpath if not dir else os.path.realpath(os.path.join(dir.decode(sys.getfilesystemencoding()), relpath.decode(sys.getfilesystemencoding())).encode(sys.getfilesystemencoding()))
def _start(self):
self._start_time = time.time()
@@ -194,8 +194,13 @@
self.out.close()
def _print_header(self):
+ tmp = list()
+ joined = ''
+ for item in self._prog.command:
+ tmp.append( item.decode(sys.getfilesystemencoding()))
+ joined = ' '.join(tmp).encode(sys.getfilesystemencoding())
self._print_date()
- self.out.write('Executing: %s\n' % ' '.join(self._prog.command))
+ self.out.write('Executing: %s\n' % joined)
self.out.write('Directory: %s\n' % self._prog.workdir)
self.out.write('config:delay: %s\n' % self._test.delay)
self.out.write('config:timeout: %s\n' % self._test.timeout)
diff --git a/test/crossrunner/run.py b/test/crossrunner/run.py
index ae7d366..8de6ba9 100644
--- a/test/crossrunner/run.py
+++ b/test/crossrunner/run.py
@@ -21,6 +21,7 @@
import multiprocessing
import multiprocessing.managers
import os
+import sys
import platform
import random
import socket
@@ -81,11 +82,16 @@
return args
def start(self, timeout=0):
- self._log.debug('COMMAND: %s', ' '.join(self.cmd))
+ tmp = list()
+ joined = ''
+ for item in self.cmd:
+ tmp.append( item.decode(sys.getfilesystemencoding()))
+ joined = ' '.join(tmp).encode(sys.getfilesystemencoding())
+ self._log.debug('COMMAND: %s', joined)
self._log.debug('WORKDIR: %s', self.cwd)
self._log.debug('LOGFILE: %s', self.report.logpath)
self.report.begin()
- self.proc = subprocess.Popen(self.cmd, **self._popen_args())
+ self.proc = subprocess.Popen(tmp, **self._popen_args())
if timeout > 0:
self.timer = threading.Timer(timeout, self._expire)
self.timer.start()
diff --git a/test/crossrunner/test.py b/test/crossrunner/test.py
index 3750ba3..6a30b3e 100644
--- a/test/crossrunner/test.py
+++ b/test/crossrunner/test.py
@@ -51,7 +51,9 @@
def _fix_cmd_path(self, cmd):
# if the arg is a file in the current directory, make it path
def abs_if_exists(arg):
- p = os.path.join(self.workdir, arg)
+ p = self.workdir.decode(sys.getfilesystemencoding())
+ p = os.path.join(p, arg.decode(sys.getfilesystemencoding()))
+ p = p.encode(sys.getfilesystemencoding())
return p if os.path.exists(p) else arg
if cmd[0] == 'python':
@@ -113,7 +115,11 @@
if os.path.isabs(path):
path = os.path.realpath(path)
else:
- path = os.path.realpath(os.path.join(self.testdir, path))
+ tmp = self.testdir.decode(sys.getfilesystemencoding())
+ path = path.decode(sys.getfilesystemencoding())
+ path = os.path.join(tmp, path)
+ path = path.encode(sys.getfilesystemencoding())
+ path = os.path.realpath(path)
config.update({key: path})
return config