Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/crossrunner/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import os
import sys

if sys.version_info[0] == 2:
_ENCODE = sys.getfilesystemencoding()

def path_join(*args):
bin_args = map(lambda a: a.decode(_ENCODE), args)
return os.path.join(*bin_args).encode(_ENCODE)

def str_join(s, l):
bin_args = map(lambda a: a.decode(_ENCODE), l)
b = s.decode(_ENCODE)
return b.join(bin_args).encode(_ENCODE)

else:

path_join = os.path.join

def str_join(s, l):
return s.join(l)
12 changes: 4 additions & 8 deletions test/crossrunner/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
import time
import traceback

from crossrunner.test import TestEntry
from .compat import path_join, str_join
from .test import TestEntry

LOG_DIR = 'log'
RESULT_HTML = 'result.html'
Expand Down Expand Up @@ -84,7 +85,7 @@ def __init__(self):
@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.decode(sys.getfilesystemencoding()), relpath.decode(sys.getfilesystemencoding())).encode(sys.getfilesystemencoding()))
return relpath if not dir else os.path.realpath(path_join(dir, relpath))

def _start(self):
self._start_time = time.time()
Expand Down Expand Up @@ -194,13 +195,8 @@ def _close(self):
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' % joined)
self.out.write('Executing: %s\n' % str_join(' ', self._prog.command))
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)
Expand Down
13 changes: 5 additions & 8 deletions test/crossrunner/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@
import time
import traceback

from crossrunner.test import TestEntry, domain_socket_path
from crossrunner.report import ExecReporter, SummaryReporter
from .compat import str_join
from .test import TestEntry, domain_socket_path
from .report import ExecReporter, SummaryReporter

RESULT_TIMEOUT = 128
RESULT_ERROR = 64
Expand Down Expand Up @@ -82,16 +83,12 @@ def _popen_args(self):
return args

def start(self, timeout=0):
tmp = list()
joined = ''
for item in self.cmd:
tmp.append( item.decode(sys.getfilesystemencoding()))
joined = ' '.join(tmp).encode(sys.getfilesystemencoding())
joined = str_join(' ', self.cmd)
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(tmp, **self._popen_args())
self.proc = subprocess.Popen(self.cmd, **self._popen_args())
if timeout > 0:
self.timer = threading.Timer(timeout, self._expire)
self.timer.start()
Expand Down
11 changes: 3 additions & 8 deletions test/crossrunner/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import multiprocessing
import os
import sys
from .compat import path_join

from crossrunner.util import merge_dict

Expand Down Expand Up @@ -51,9 +52,7 @@ def __init__(self, kind, name, protocol, transport, socket, workdir, command, en
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 = self.workdir.decode(sys.getfilesystemencoding())
p = os.path.join(p, arg.decode(sys.getfilesystemencoding()))
p = p.encode(sys.getfilesystemencoding())
p = path_join(self.workdir, arg)
return p if os.path.exists(p) else arg

if cmd[0] == 'python':
Expand Down Expand Up @@ -115,11 +114,7 @@ def _fix_workdir(self, config):
if os.path.isabs(path):
path = os.path.realpath(path)
else:
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)
path = os.path.realpath(path_join(self.testdir, path))
config.update({key: path})
return config

Expand Down