Commit e5a90536 authored by Jérome Perrin's avatar Jérome Perrin

testsuite: remove EggTestSuite

We no longer run tests with `python setup.py`, but simply with `python -m unittest`

With nexedi/slapos!862 we no longer need this

See merge request nexedi/erp5!1316
parents 9eb05e32 5f633758
......@@ -226,127 +226,3 @@ class TestSuite(object):
if p.returncode:
raise SubprocessError(result)
return result
# (XXX) The code bellow is an generic extension to run a test for any egg.
# The code above was moved from ERP5 code base, because it is generic
# Enough to be used by others.
class EggTestSuite(TestSuite):
"""Run `python setup.py test` in some directories defined by egg_test_path_dict.
The following arguments are expected by constructor:
``egg_test_path_dict`` is a mapping of paths to packages directories keyed by
package name. The package name is what will be displayed in the test suite.
It has to be stable for "test result history" to work as expected.
The python interpreter is ``python_interpreter``
"""
def run(self, test):
print(test)
try:
status_dict = self.spawn(
self.python_interpreter, 'setup.py', 'test',
cwd=self.egg_test_path_dict[test],
SLAPOS_TEST_SHARED_PART_LIST=self.shared_part_list,
SLAPOS_TEST_LOG_DIRECTORY=self.log_directory)
except SubprocessError as e:
status_dict = e.status_dict
test_log = status_dict['stderr']
search = self.RUN_RE.search(test_log)
if search:
groupdict = search.groupdict()
status_dict.update(duration=float(groupdict['seconds']),
test_count=int(groupdict['all_tests']))
search = self.STATUS_RE.search(test_log)
def updateStatusDictWithGroup(groupdict):
status_dict.update(error_count=int(groupdict.get('errors') or 0),
failure_count=int(groupdict['failures'] or 0)
+int(groupdict['unexpected_successes'] or 0),
skip_count=int(groupdict['skips'] or 0)
+int(groupdict['expected_failures'] or 0))
if search:
groupdict = search.groupdict()
updateStatusDictWithGroup(groupdict)
# In case the test is used to launch another one (like functional test),
# look for results inside stderr
sub_search = self.SUB_STATUS_RE.search(status_dict['stdout'])
if sub_search:
groupdict = sub_search.groupdict()
updateStatusDictWithGroup(groupdict)
status_dict.update(test_count=int(groupdict['all_tests']))
return status_dict
def getTestList(self):
return list(self.egg_test_path_dict)
def runTestSuite():
parser = argparse.ArgumentParser(description='Run a test suite.')
parser.add_argument('--test_suite', help='The test suite name')
parser.add_argument('--test_suite_title', help='The test suite title',
default=None)
parser.add_argument('--test_node_title', help='The test node title',
default=None)
parser.add_argument('--project_title', help='The project title',
default=None)
parser.add_argument('--revision', help='The revision to test',
default='dummy_revision')
parser.add_argument('--node_quantity', help='Number of parallel tests to run',
default=1, type=int)
parser.add_argument('--master_url',
help='The Url of Master controling many suites',
default=None)
parser.add_argument('--frontend_url',
help='The url of the frontend of this test node',
default=None)
parser.add_argument('--log_directory',
help='Directory to store logs',
default='')
parser.add_argument('--python_interpreter',
help='Path to python interpreter used to run the test suite',
default='python')
parser.add_argument('--source_code_path_list',
help='Coma separated list of Eggs folders to test',
default='.')
parser.add_argument('--shared_part_list',
help='Shared parts for recursive slapos',
default='')
args = parser.parse_args()
master = taskdistribution.TaskDistributor(args.master_url)
test_suite_title = args.test_suite_title or args.test_suite
revision = args.revision
# Guess test name from path, we support mainly two cases:
# /path/to/erp5.util/ -> we want erp5.util
# /path/to/slapos/software/erp5/test/ -> we want erp5
egg_test_path_dict = {}
for test_path in args.source_code_path_list.split(','):
path, test_name = os.path.split(test_path)
while test_name in ('', 'test'):
path, test_name = os.path.split(path)
assert path != os.path.sep
egg_test_path_dict[test_name] = test_path
suite = EggTestSuite(1, test_suite=args.test_suite,
node_quantity=args.node_quantity,
revision=revision,
python_interpreter=args.python_interpreter,
egg_test_path_dict=egg_test_path_dict,
shared_part_list=args.shared_part_list,
log_directory=args.log_directory,
)
test_result = master.createTestResult(revision, suite.getTestList(),
args.test_node_title, suite.allow_restart, test_suite_title,
args.project_title)
if test_result is not None:
assert revision == test_result.revision, (revision, test_result.revision)
while suite.acquire():
test = test_result.start(list(suite.running))
if test is not None:
suite.start(test.name, lambda status_dict, __test=test:
__test.stop(**status_dict))
elif not suite.running:
break
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment