summaryrefslogtreecommitdiff
path: root/buildscripts/smoke.py
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/smoke.py')
-rwxr-xr-xbuildscripts/smoke.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/buildscripts/smoke.py b/buildscripts/smoke.py
index 37b533f2cc5..9c185079462 100755
--- a/buildscripts/smoke.py
+++ b/buildscripts/smoke.py
@@ -54,6 +54,7 @@ from pymongo import Connection
from pymongo.errors import OperationFailure
import cleanbb
+import smoke
import utils
try:
@@ -1002,11 +1003,36 @@ def expand_suites(suites,expandUseDB=True):
return tests
+
+def filter_tests_by_tag(tests, tag_query):
+ """Selects tests from a list based on a query over the tags in the tests."""
+
+ test_map = {}
+ roots = []
+ for test in tests:
+ root = os.path.abspath(test[0])
+ roots.append(root)
+ test_map[root] = test
+
+ new_style_tests = smoke.tests.build_tests(roots, extract_metadata=True)
+ new_style_tests = smoke.suites.build_suite(new_style_tests, tag_query)
+
+ print "\nTag query matches %s tests out of %s.\n" % (len(new_style_tests),
+ len(tests))
+
+ tests = []
+ for new_style_test in new_style_tests:
+ tests.append(test_map[os.path.abspath(new_style_test.filename)])
+
+ return tests
+
+
def add_exe(e):
if os.sys.platform.startswith( "win" ) and not e.endswith( ".exe" ):
e += ".exe"
return e
+
def set_globals(options, tests):
global mongod_executable, mongod_port, shell_executable, continue_on_failure
global small_oplog, small_oplog_rs
@@ -1259,6 +1285,14 @@ def main():
parser.add_option('--shell-write-mode', dest='shell_write_mode', default="commands",
help='Sets the shell to use a specific write mode: commands/compatibility/legacy (default:legacy)')
+ parser.add_option('--include-tags', dest='include_tags', default="", action='store',
+ help='Filters jstests run by tag regex(es) - a tag in the test must match the regexes. ' +
+ 'Specify single regex string or JSON array.')
+
+ parser.add_option('--exclude-tags', dest='exclude_tags', default="", action='store',
+ help='Filters jstests run by tag regex(es) - no tags in the test must match the regexes. ' +
+ 'Specify single regex string or JSON array.')
+
global tests
(options, tests) = parser.parse_args()
@@ -1313,6 +1347,22 @@ def main():
tests = filter( ignore_test, tests )
+ if options.include_tags or options.exclude_tags:
+
+ def to_regex_array(tags_option):
+ if not tags_option:
+ return []
+
+ tags_list = smoke.json_options.json_coerce(tags_option)
+ if isinstance(tags_list, basestring):
+ tags_list = [tags_list]
+
+ return map(re.compile, tags_list)
+
+ tests = filter_tests_by_tag(tests,
+ smoke.suites.RegexQuery(include_res=to_regex_array(options.include_tags),
+ exclude_res=to_regex_array(options.exclude_tags)))
+
if not tests:
print "warning: no tests specified"
return