summaryrefslogtreecommitdiff
path: root/buildscripts/resmokelib
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2017-05-26 13:59:32 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2017-05-26 13:59:32 -0400
commitb6c1b6b6a9bfe17d3c21d87ee8516e069dadfa3c (patch)
treee05d63a53f72e96cf0456b7bb612eee69b8584ec /buildscripts/resmokelib
parent90fd8a19000b5f96983f068e6380c1f6bd824b69 (diff)
downloadmongo-b6c1b6b6a9bfe17d3c21d87ee8516e069dadfa3c.tar.gz
SERVER-28302 resmoke.py parser should accept files that don't end in .js
Diffstat (limited to 'buildscripts/resmokelib')
-rw-r--r--buildscripts/resmokelib/parser.py65
-rw-r--r--buildscripts/resmokelib/reportfile.py3
-rw-r--r--buildscripts/resmokelib/selector.py13
-rw-r--r--buildscripts/resmokelib/testing/suite.py48
4 files changed, 64 insertions, 65 deletions
diff --git a/buildscripts/resmokelib/parser.py b/buildscripts/resmokelib/parser.py
index 0bdaf4782af..91dbe9bf3f9 100644
--- a/buildscripts/resmokelib/parser.py
+++ b/buildscripts/resmokelib/parser.py
@@ -305,11 +305,10 @@ def create_test_membership_map(fail_on_missing_selector=False):
continue
raise
- for group in suite.test_groups:
- for testfile in group.tests:
- if isinstance(testfile, dict):
- continue
- test_membership[testfile].append(suite_name)
+ for testfile in suite.test_group.tests:
+ if isinstance(testfile, dict):
+ continue
+ test_membership[testfile].append(suite_name)
return test_membership
@@ -319,17 +318,21 @@ def get_suites(values, args):
_config.INTERNAL_EXECUTOR_NAME = values.executor_file
- # If there are no suites specified, but there are args, assume they are jstests.
+ # If there are no suites specified, but args, collect the specified files.
if args:
- # Do not change the execution order of the jstests passed as args, unless a tag option is
+ # Do not change the execution order of the tests passed as args, unless a tag option is
# specified. If an option is specified, then sort the tests for consistent execution order.
_config.ORDER_TESTS_BY_NAME = any(tag_filter is not None for
tag_filter in (_config.EXCLUDE_WITH_ANY_TAGS,
_config.INCLUDE_WITH_ANY_TAGS))
# No specified config, just use the following, and default the logging and executor.
- suite_config = _make_jstests_config(args)
+ suite_config = _make_config(args)
_ensure_executor(suite_config, values.executor_file)
- suite = testing.suite.Suite("<jstests>", suite_config)
+ # The test_kind comes from the executor file.
+ _ensure_test_kind(suite_config,
+ _get_yaml_config("executor", values.executor_file),
+ values.executor_file)
+ suite = testing.suite.Suite("<%s>" % suite_config["test_kind"], suite_config)
return [suite]
suite_files = values.suite_files.split(",")
@@ -390,41 +393,37 @@ def _get_suite_config(pathname):
Attempts to read a YAML configuration from 'pathname' that describes
what tests to run and how to run them.
"""
+ return _get_yaml_config("suite", pathname)
+
+
+def _make_config(files):
+ return {"selector": {"roots": files}}
+
+
+def _ensure_test_kind(suite_config, yaml_config, yaml_file):
+ if "test_kind" not in yaml_config:
+ raise ValueError("YAML config file %s missing key 'test_kind'" % (yaml_file))
+ suite_config["test_kind"] = yaml_config["test_kind"]
+
- # Named suites are specified as the basename of the file, without the .yml extension.
+def _get_yaml_config(kind, pathname):
+ # Named executors or suites are specified as the basename of the file, without the .yml
+ # extension.
if not utils.is_yaml_file(pathname) and not os.path.dirname(pathname):
if pathname not in resmokeconfig.NAMED_SUITES:
- raise optparse.OptionValueError("Unknown suite '%s'" % (pathname))
+ raise optparse.OptionValueError("Unknown %s '%s'" % (kind, pathname))
pathname = resmokeconfig.NAMED_SUITES[pathname] # Expand 'pathname' to full path.
if not utils.is_yaml_file(pathname) or not os.path.isfile(pathname):
- raise optparse.OptionValueError("Expected a suite YAML config, but got '%s'" % (pathname))
-
+ raise optparse.OptionValueError("Expected a %s YAML config, but got '%s'"
+ % (kind, pathname))
return utils.load_yaml_file(pathname)
-def _make_jstests_config(js_files):
- for pathname in js_files:
- if not utils.is_js_file(pathname) or not os.path.isfile(pathname):
- raise optparse.OptionValueError("Expected a list of JS files, but got '%s'"
- % (pathname))
-
- return {"selector": {"js_test": {"roots": js_files}}}
-
-
-def _ensure_executor(suite_config, executor_pathname):
+def _ensure_executor(suite_config, pathname):
if "executor" not in suite_config:
# Named executors are specified as the basename of the file, without the .yml extension.
- if not utils.is_yaml_file(executor_pathname) and not os.path.dirname(executor_pathname):
- if executor_pathname not in resmokeconfig.NAMED_SUITES:
- raise optparse.OptionValueError("Unknown executor '%s'" % (executor_pathname))
- executor_pathname = resmokeconfig.NAMED_SUITES[executor_pathname]
-
- if not utils.is_yaml_file(executor_pathname) or not os.path.isfile(executor_pathname):
- raise optparse.OptionValueError("Expected an executor YAML config, but got '%s'"
- % (executor_pathname))
-
- suite_config["executor"] = utils.load_yaml_file(executor_pathname).pop("executor")
+ suite_config["executor"] = _get_yaml_config("executor", pathname).pop("executor")
def _expand_user(pathname):
diff --git a/buildscripts/resmokelib/reportfile.py b/buildscripts/resmokelib/reportfile.py
index 7bf288069e2..716f90d8cae 100644
--- a/buildscripts/resmokelib/reportfile.py
+++ b/buildscripts/resmokelib/reportfile.py
@@ -21,8 +21,7 @@ def write(suites):
reports = []
for suite in suites:
- for group in suite.test_groups:
- reports.extend(group.get_reports())
+ reports.extend(suite.test_group.get_reports())
combined_report_dict = _report.TestReport.combine(*reports).as_dict()
with open(config.REPORT_FILE, "w") as fp:
diff --git a/buildscripts/resmokelib/selector.py b/buildscripts/resmokelib/selector.py
index 30cc2d1b31d..ce1cf7ecbfd 100644
--- a/buildscripts/resmokelib/selector.py
+++ b/buildscripts/resmokelib/selector.py
@@ -88,27 +88,38 @@ def _filter_cpp_tests(kind, root, include_files, exclude_files):
def filter_cpp_unit_tests(root=config.DEFAULT_UNIT_TEST_LIST,
+ roots=None,
include_files=None,
exclude_files=None):
"""
Filters out what C++ unit tests to run.
"""
+ # 'roots' is provided only if a file list is given from the command line.
+ if roots is not None:
+ return roots
return _filter_cpp_tests("C++ unit test", root, include_files, exclude_files)
def filter_cpp_integration_tests(root=config.DEFAULT_INTEGRATION_TEST_LIST,
+ roots=None,
include_files=None,
exclude_files=None):
"""
Filters out what C++ integration tests to run.
"""
+ # 'roots' is provided only if a file list is given from the command line.
+ if roots is not None:
+ return roots
return _filter_cpp_tests("C++ integration test", root, include_files, exclude_files)
-def filter_dbtests(binary=None, include_suites=None):
+def filter_dbtests(binary=None, roots=None, include_suites=None):
"""
Filters out what dbtests to run.
"""
+ # 'roots' is provided only if a file list is given from the command line.
+ if roots is not None:
+ return roots
# TODO: SERVER-22170 Implement full tagging support
# If --includeWithAnyTags is supplied, then no tests should be run since
diff --git a/buildscripts/resmokelib/testing/suite.py b/buildscripts/resmokelib/testing/suite.py
index 11777c0e12f..dbaef7edfdd 100644
--- a/buildscripts/resmokelib/testing/suite.py
+++ b/buildscripts/resmokelib/testing/suite.py
@@ -17,8 +17,6 @@ class Suite(object):
A suite of tests.
"""
- TESTS_ORDER = ("cpp_unit_test", "cpp_integration_test", "db_test", "js_test", "mongos_test")
-
def __init__(self, suite_name, suite_config):
"""
Initializes the suite with the specified name and configuration.
@@ -27,13 +25,9 @@ class Suite(object):
self._suite_name = suite_name
self._suite_config = suite_config
- self.test_groups = []
- for test_kind in Suite.TESTS_ORDER:
- if test_kind not in suite_config["selector"]:
- continue
- tests = self._get_tests_for_group(test_kind)
- test_group = testgroup.TestGroup(test_kind, tests)
- self.test_groups.append(test_group)
+ test_kind = self.get_test_kind_config()
+ tests = self._get_tests_for_group(test_kind)
+ self.test_group = testgroup.TestGroup(test_kind, tests)
self.return_code = None
@@ -46,7 +40,7 @@ class Suite(object):
filtering policy.
"""
- test_info = self.get_selector_config()[test_kind]
+ test_info = self.get_selector_config()
# The mongos_test doesn't have to filter anything, the test_info is just the arguments to
# the mongos program to be used as the test case.
@@ -86,6 +80,12 @@ class Suite(object):
"""
return self._suite_config["executor"]
+ def get_test_kind_config(self):
+ """
+ Returns the "test_kind" section of the YAML configuration.
+ """
+ return self._suite_config["test_kind"]
+
def record_start(self):
"""
Records the start time of the suite.
@@ -105,28 +105,19 @@ class Suite(object):
# Only set 'return_code' if it hasn't been set already. It may have been set if there was
# an exception that happened during the execution of the suite.
if self.return_code is None:
- # The return code of the suite should be 2 if any test group has a return code of 2.
- # The return code of the suite should be 1 if any test group has a return code of 1,
- # and none have a return code of 2. Otherwise, the return code should be 0.
- self.return_code = max(test_group.return_code for test_group in self.test_groups)
+ self.return_code = self.test_group.return_code
def summarize(self, sb):
"""
- Appends a summary of each individual test group onto the string
- builder 'sb'.
+ Appends a summary of the test group onto the string builder 'sb'.
"""
- combined_summary = _summary.Summary(0, 0.0, 0, 0, 0, 0)
-
- summarized_groups = []
- for group in self.test_groups:
- group_sb = []
- summary = group.summarize(group_sb)
- summarized_groups.append(" %ss: %s" % (group.test_kind, "\n ".join(group_sb)))
+ summary = _summary.Summary(0, 0.0, 0, 0, 0, 0)
- combined_summary = _summary.combine(combined_summary, summary)
+ summary = self.test_group.summarize(sb)
+ summarized_group = " %ss: %s" % (self.test_group.test_kind, "\n ".join(sb))
- if combined_summary.num_run == 0:
+ if summary.num_run == 0:
sb.append("Suite did not run any tests.")
return
@@ -134,10 +125,9 @@ class Suite(object):
# information available.
if self._start_time is not None and self._end_time is not None:
time_taken = self._end_time - self._start_time
- combined_summary = combined_summary._replace(time_taken=time_taken)
+ summary = summary._replace(time_taken=time_taken)
sb.append("%d test(s) ran in %0.2f seconds"
- " (%d succeeded, %d were skipped, %d failed, %d errored)" % combined_summary)
+ " (%d succeeded, %d were skipped, %d failed, %d errored)" % summary)
- for summary_text in summarized_groups:
- sb.append(summary_text)
+ sb.append(summarized_group)