summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/resmokelib/config.py18
-rw-r--r--buildscripts/resmokelib/parser.py27
-rw-r--r--buildscripts/resmokelib/selector.py48
3 files changed, 76 insertions, 17 deletions
diff --git a/buildscripts/resmokelib/config.py b/buildscripts/resmokelib/config.py
index 4868e2edef4..ecb7fec7fa3 100644
--- a/buildscripts/resmokelib/config.py
+++ b/buildscripts/resmokelib/config.py
@@ -39,6 +39,10 @@ DEFAULTS = {
"dbpathPrefix": None,
"dbtest": None,
"dryRun": None,
+ "excludeWithAllTags": None,
+ "excludeWithAnyTags": None,
+ "includeWithAllTags": None,
+ "includeWithAnyTags": None,
"jobs": 1,
"mongo": None,
"mongod": None,
@@ -81,9 +85,23 @@ DBTEST_EXECUTABLE = None
# actually running them).
DRY_RUN = None
+# If set, then any jstests that have all of the specified tags will be excluded from the suite(s).
+EXCLUDE_WITH_ALL_TAGS = None
+
+# If set, then any jstests that have any of the specified tags will be excluded from the suite(s).
+EXCLUDE_WITH_ANY_TAGS = None
+
# If true, then a test failure or error will cause resmoke.py to exit and not run any more tests.
FAIL_FAST = None
+# If set, then only jstests that have all of the specified tags will be run during the jstest
+# portion of the suite(s).
+INCLUDE_WITH_ALL_TAGS = None
+
+# If set, then only jstests that have at least one of the specified tags will be run during the
+# jstest portion of the suite(s).
+INCLUDE_WITH_ANY_TAGS = None
+
# If set, then resmoke.py starts the specified number of Job instances to run tests.
JOBS = None
diff --git a/buildscripts/resmokelib/parser.py b/buildscripts/resmokelib/parser.py
index f3f11012fb3..4bcc7bfb137 100644
--- a/buildscripts/resmokelib/parser.py
+++ b/buildscripts/resmokelib/parser.py
@@ -23,6 +23,10 @@ DEST_TO_CONFIG = {
"dbpath_prefix": "dbpathPrefix",
"dbtest_executable": "dbtest",
"dry_run": "dryRun",
+ "exclude_with_all_tags": "excludeWithAllTags",
+ "exclude_with_any_tags": "excludeWithAnyTags",
+ "include_with_all_tags": "includeWithAllTags",
+ "include_with_any_tags": "includeWithAnyTags",
"jobs": "jobs",
"mongo_executable": "mongo",
"mongod_executable": "mongod",
@@ -84,12 +88,29 @@ def parse_command_line():
help="Executes all tests in all suites, even if some of them fail.")
parser.add_option("--dbpathPrefix", dest="dbpath_prefix", metavar="PATH",
- help=("The directory which will contain the dbpaths of any mongod's started "
+ help=("The directory which will contain the dbpaths of any mongod's started"
" by resmoke.py or the tests themselves."))
parser.add_option("--dbtest", dest="dbtest_executable", metavar="PATH",
help="The path to the dbtest executable for resmoke to use.")
+ parser.add_option("--excludeWithAllTags", dest="exclude_with_all_tags", metavar="TAG1,TAG2",
+ help=("Comma separated list of tags. Any jstest that contains all of the"
+ " specified tags will be excluded from any suites that are run."))
+
+ parser.add_option("--excludeWithAnyTags", dest="exclude_with_any_tags", metavar="TAG1,TAG2",
+ help=("Comma separated list of tags. Any jstest that contains any of the"
+ " specified tags will be excluded from any suites that are run."))
+
+ parser.add_option("--includeWithAllTags", dest="include_with_all_tags", metavar="TAG1,TAG2",
+ help=("Comma separated list of tags. For the jstest portion of the suite(s),"
+ " only tests which have all of the specified tags will be run."))
+
+ parser.add_option("--includeWithAnyTags", dest="include_with_any_tags", metavar="TAG1,TAG2",
+ help=("Comma separated list of tags. For the jstest portion of the suite(s),"
+ " only tests which have at least one of the specified tags will be"
+ " run."))
+
parser.add_option("-n", action="store_const", const="tests", dest="dry_run",
help=("Output the tests that would be run."))
@@ -203,7 +224,11 @@ def update_config_vars(values):
_config.DBPATH_PREFIX = _expand_user(config.pop("dbpathPrefix"))
_config.DBTEST_EXECUTABLE = _expand_user(config.pop("dbtest"))
_config.DRY_RUN = config.pop("dryRun")
+ _config.EXCLUDE_WITH_ALL_TAGS = config.pop("excludeWithAllTags")
+ _config.EXCLUDE_WITH_ANY_TAGS = config.pop("excludeWithAnyTags")
_config.FAIL_FAST = not config.pop("continueOnFailure")
+ _config.INCLUDE_WITH_ALL_TAGS = config.pop("includeWithAllTags")
+ _config.INCLUDE_WITH_ANY_TAGS = config.pop("includeWithAnyTags")
_config.JOBS = config.pop("jobs")
_config.MONGO_EXECUTABLE = _expand_user(config.pop("mongo"))
_config.MONGOD_EXECUTABLE = _expand_user(config.pop("mongod"))
diff --git a/buildscripts/resmokelib/selector.py b/buildscripts/resmokelib/selector.py
index 61bc8921183..c2dc0fca41b 100644
--- a/buildscripts/resmokelib/selector.py
+++ b/buildscripts/resmokelib/selector.py
@@ -116,24 +116,40 @@ def filter_jstests(roots,
include_files = utils.default_if_none(include_files, [])
exclude_files = utils.default_if_none(exclude_files, [])
- include_with_all_tags = set(utils.default_if_none(include_with_all_tags, []))
- include_with_any_tags = set(utils.default_if_none(include_with_any_tags, []))
- exclude_with_all_tags = set(utils.default_if_none(exclude_with_all_tags, []))
- exclude_with_any_tags = set(utils.default_if_none(exclude_with_any_tags, []))
+ # Command line options override the YAML options, and all should be defaulted to an empty list
+ # if not specified.
+ tags = {
+ "exclude_with_all_tags": exclude_with_all_tags,
+ "exclude_with_any_tags": exclude_with_any_tags,
+ "include_with_all_tags": include_with_all_tags,
+ "include_with_any_tags": include_with_any_tags,
+ }
+ cmd_line_values = (
+ ("exclude_with_all_tags", config.EXCLUDE_WITH_ALL_TAGS),
+ ("exclude_with_any_tags", config.EXCLUDE_WITH_ANY_TAGS),
+ ("include_with_all_tags", config.INCLUDE_WITH_ALL_TAGS),
+ ("include_with_any_tags", config.INCLUDE_WITH_ANY_TAGS),
+ )
+ for (tag_category, cmd_line_val) in cmd_line_values:
+ if cmd_line_val is not None:
+ # Ignore the empty string when it is used as a tag. Specifying an empty string on the
+ # command line allows a user to unset the list of tags specified in the YAML
+ # configuration.
+ tags[tag_category] = set([tag for tag in cmd_line_val.split(",") if tag != ""])
+ else:
+ tags[tag_category] = set(utils.default_if_none(tags[tag_category], []))
using_tags = 0
- for (name, value) in (("include_with_all_tags", include_with_all_tags),
- ("include_with_any_tags", include_with_any_tags),
- ("exclude_with_all_tags", exclude_with_all_tags),
- ("exclude_with_any_tags", exclude_with_any_tags)):
- if not utils.is_string_set(value):
+ for name in tags:
+ if not utils.is_string_set(tags[name]):
raise TypeError("%s must be a list of strings" % (name))
- if len(value) > 0:
+ if len(tags[name]) > 0:
using_tags += 1
if using_tags > 1:
raise ValueError("Can only specify one of 'include_with_all_tags', 'include_with_any_tags',"
- " 'exclude_with_all_tags', and 'exclude_with_any_tags'")
+ " 'exclude_with_all_tags', and 'exclude_with_any_tags'. If you wish to"
+ " unset one of these options, use --includeWithAllTags='' or similar")
jstests = []
for root in roots:
@@ -157,16 +173,16 @@ def filter_jstests(roots,
for filename in jstests:
file_tags = set(jscomment.get_tags(filename))
- if include_with_all_tags and not include_with_all_tags - file_tags:
+ if tags["include_with_all_tags"] and not tags["include_with_all_tags"] - file_tags:
included.add(filename)
- elif include_with_any_tags and include_with_any_tags & file_tags:
+ elif tags["include_with_any_tags"] and tags["include_with_any_tags"] & file_tags:
included.add(filename)
- elif exclude_with_all_tags and not exclude_with_all_tags - file_tags:
+ elif tags["exclude_with_all_tags"] and not tags["exclude_with_all_tags"] - file_tags:
excluded.add(filename)
- elif exclude_with_any_tags and exclude_with_any_tags & file_tags:
+ elif tags["exclude_with_any_tags"] and tags["exclude_with_any_tags"] & file_tags:
excluded.add(filename)
- if include_with_all_tags or include_with_any_tags:
+ if tags["include_with_all_tags"] or tags["include_with_any_tags"]:
if exclude_files:
return list((included & jstests) - excluded)
return list(included)