Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test/crossrunner: merge in old Py2vs3 compat.py #3088

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 0 additions & 7 deletions test/crossrunner/compat.py

This file was deleted.

21 changes: 12 additions & 9 deletions test/crossrunner/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import time
import traceback

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

LOG_DIR = 'log'
Expand All @@ -37,14 +36,18 @@
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
for r in results:
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')
Expand All @@ -67,7 +70,7 @@ def collect_failures(results):

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 []
Expand All @@ -84,8 +87,8 @@ def __init__(self):

@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()
Expand Down Expand Up @@ -199,7 +202,7 @@ def _close(self):

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)
Expand All @@ -221,8 +224,8 @@ def __init__(self, basedir, testdir_relative, concurrent=True):
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()
Expand All @@ -239,7 +242,7 @@ def __init__(self, basedir, testdir_relative, concurrent=True):

@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:
Expand Down
3 changes: 1 addition & 2 deletions test/crossrunner/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -72,7 +71,7 @@ def _popen_args(self):
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)
Expand Down
5 changes: 2 additions & 3 deletions test/crossrunner/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import multiprocessing
import os
import sys
from .compat import path_join
from .util import merge_dict, domain_socket_path


Expand Down Expand Up @@ -50,7 +49,7 @@ def __init__(self, kind, name, protocol, transport, socket, workdir, stop_signal
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':
Expand Down Expand Up @@ -125,7 +124,7 @@ def _fix_workdir(self, config):
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

Expand Down
Loading