test/crossrunner: merge in old Py2vs3 compat.py
diff --git a/test/crossrunner/compat.py b/test/crossrunner/compat.py
deleted file mode 100644
index a670c33..0000000
--- a/test/crossrunner/compat.py
+++ /dev/null
@@ -1,7 +0,0 @@
-import os
-
-path_join = os.path.join
-str_join = str.join
-
-def logfile_open(*args):
- return open(*args, errors='replace')
diff --git a/test/crossrunner/report.py b/test/crossrunner/report.py
index 7e1b0c7..9231a8b 100644
--- a/test/crossrunner/report.py
+++ b/test/crossrunner/report.py
@@ -28,7 +28,6 @@
import time
import traceback
-from .compat import logfile_open, path_join, str_join
from .test import TestEntry
LOG_DIR = 'log'
@@ -37,6 +36,10 @@
FAIL_JSON = 'known_failures_%s.json'
+def logfile_open(*args):
+ return open(*args, errors='replace')
+
+
def generate_known_failures(testdir, overwrite, save, out):
def collect_failures(results):
success_index = 5
@@ -44,7 +47,7 @@
if not r[success_index]:
yield TestEntry.get_name(*r)
try:
- with logfile_open(path_join(testdir, RESULT_JSON), 'r') as fp:
+ with logfile_open(os.path.join(testdir, RESULT_JSON), 'r') as fp:
results = json.load(fp)
except IOError:
sys.stderr.write('Unable to load last result. Did you run tests ?\n')
@@ -67,7 +70,7 @@
def load_known_failures(testdir):
try:
- with logfile_open(path_join(testdir, FAIL_JSON % platform.system()), 'r') as fp:
+ with logfile_open(os.path.join(testdir, FAIL_JSON % platform.system()), 'r') as fp:
return json.load(fp)
except IOError:
return []
@@ -84,8 +87,8 @@
@classmethod
def test_logfile(cls, test_name, prog_kind, dir=None):
- relpath = path_join('log', '%s_%s.log' % (test_name, prog_kind))
- return relpath if not dir else os.path.realpath(path_join(dir, relpath))
+ 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))
def _start(self):
self._start_time = time.time()
@@ -199,7 +202,7 @@
def _print_header(self):
self._print_date()
- print('Executing: %s' % str_join(' ', self._prog.command), file=self.out)
+ print('Executing: %s' % ' '.join(self._prog.command), file=self.out)
print('Directory: %s' % self._prog.workdir, file=self.out)
print('config:delay: %s' % self._test.delay, file=self.out)
print('config:timeout: %s' % self._test.timeout, file=self.out)
@@ -221,8 +224,8 @@
super(SummaryReporter, self).__init__()
self._basedir = basedir
self._testdir_rel = testdir_relative
- self.logdir = path_join(self.testdir, LOG_DIR)
- self.out_path = path_join(self.testdir, RESULT_JSON)
+ self.logdir = os.path.join(self.testdir, LOG_DIR)
+ self.out_path = os.path.join(self.testdir, RESULT_JSON)
self.concurrent = concurrent
self.out = sys.stdout
self._platform = platform.system()
@@ -239,7 +242,7 @@
@property
def testdir(self):
- return path_join(self._basedir, self._testdir_rel)
+ return os.path.join(self._basedir, self._testdir_rel)
def _result_string(self, test):
if test.success:
diff --git a/test/crossrunner/run.py b/test/crossrunner/run.py
index 126b7ec..3ccc6e3 100644
--- a/test/crossrunner/run.py
+++ b/test/crossrunner/run.py
@@ -28,7 +28,6 @@
import sys
import time
-from .compat import str_join
from .report import ExecReporter, SummaryReporter
from .test import TestEntry
from .util import domain_socket_path
@@ -72,7 +71,7 @@
return args
def start(self):
- joined = str_join(' ', self.cmd)
+ joined = ' '.join(self.cmd)
self._log.debug('COMMAND: %s', joined)
self._log.debug('WORKDIR: %s', self.cwd)
self._log.debug('LOGFILE: %s', self.report.logpath)
diff --git a/test/crossrunner/test.py b/test/crossrunner/test.py
index 0e91284..2a1a4da 100644
--- a/test/crossrunner/test.py
+++ b/test/crossrunner/test.py
@@ -21,7 +21,6 @@
import multiprocessing
import os
import sys
-from .compat import path_join
from .util import merge_dict, domain_socket_path
@@ -50,7 +49,7 @@
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 = path_join(self.workdir, arg)
+ p = os.path.join(self.workdir, arg)
return p if os.path.exists(p) else arg
if cmd[0] == 'python':
@@ -125,7 +124,7 @@
if os.path.isabs(path):
path = os.path.realpath(path)
else:
- path = os.path.realpath(path_join(self.testdir, path))
+ path = os.path.realpath(os.path.join(self.testdir, path))
config.update({key: path})
return config