summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorYves Duhem <yves.duhem@mongodb.com>2017-10-03 15:20:08 -0400
committerYves Duhem <yves.duhem@mongodb.com>2017-10-03 15:20:08 -0400
commit420c06608a367c97ed5016c558ee4001f62a9896 (patch)
tree0a85ac6116f779dab5b04f424b764c3752c6ad95 /buildscripts
parente0359268121833e7c29d62e5dff28532910b996f (diff)
downloadmongo-420c06608a367c97ed5016c558ee4001f62a9896.tar.gz
SERVER-31309 Fix use of resmoke args for cpp tests
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/resmokelib/selector.py16
-rw-r--r--buildscripts/tests/resmokelib/test_selector.py19
2 files changed, 32 insertions, 3 deletions
diff --git a/buildscripts/resmokelib/selector.py b/buildscripts/resmokelib/selector.py
index 710ab660c4c..920b4ad01f3 100644
--- a/buildscripts/resmokelib/selector.py
+++ b/buildscripts/resmokelib/selector.py
@@ -451,10 +451,16 @@ class _JSTestSelector(_Selector):
class _CppTestSelectorConfig(_SelectorConfig):
"""_SelectorConfig subclass for cpp_integration_test and cpp_unit_test tests."""
- def __init__(self, root=config.DEFAULT_INTEGRATION_TEST_LIST,
+ def __init__(self, root=config.DEFAULT_INTEGRATION_TEST_LIST, roots=None,
include_files=None, exclude_files=None):
- _SelectorConfig.__init__(self, root=root,
- include_files=include_files, exclude_files=exclude_files)
+ if roots:
+ # The 'roots' argument is only present when tests are specified on the command line
+ # and in that case they take precedence over the tests in the root file.
+ _SelectorConfig.__init__(self, roots=roots,
+ include_files=include_files, exclude_files=exclude_files)
+ else:
+ _SelectorConfig.__init__(self, root=root,
+ include_files=include_files, exclude_files=exclude_files)
class _CppTestSelector(_Selector):
@@ -464,6 +470,8 @@ class _CppTestSelector(_Selector):
def select(self, selector_config):
if selector_config.roots:
+ # Tests have been specified on the command line. We use them without additional
+ # filtering.
return selector_config.roots
return _Selector.select(self, selector_config)
@@ -496,6 +504,8 @@ class _DbTestSelector(_Selector):
return []
if selector_config.roots:
+ # Tests have been specified on the command line. We use them without additional
+ # filtering.
return selector_config.roots
if not self._test_file_explorer.isfile(selector_config.binary):
diff --git a/buildscripts/tests/resmokelib/test_selector.py b/buildscripts/tests/resmokelib/test_selector.py
index 63c03a4d32d..5dd84e88494 100644
--- a/buildscripts/tests/resmokelib/test_selector.py
+++ b/buildscripts/tests/resmokelib/test_selector.py
@@ -329,6 +329,16 @@ class TestFilterTests(unittest.TestCase):
selected = selector.filter_tests("cpp_integration_test", config, self.test_file_explorer)
self.assertEqual(["dir/root/testA.cpp", "dir/root/testB.cpp"], selected)
+ def test_cpp_roots_override(self):
+ # When roots are specified for cpp tests they override all filtering since
+ # 'roots' are populated with the command line arguments.
+ config = {"include_files": "unknown_file",
+ "roots": ["cpptestOverride"]}
+ selected = selector.filter_tests("cpp_unit_test", config, self.test_file_explorer)
+ self.assertEqual(["cpptestOverride"], selected)
+ selected = selector.filter_tests("cpp_integration_test", config, self.test_file_explorer)
+ self.assertEqual(["cpptestOverride"], selected)
+
def test_cpp_with_any_tags(self):
buildscripts.resmokelib.config.INCLUDE_WITH_ANY_TAGS = ["tag1"]
try:
@@ -397,6 +407,15 @@ class TestFilterTests(unittest.TestCase):
selected = selector.filter_tests("db_test", config, self.test_file_explorer)
self.assertEqual(["dbtestA", "dbtestB", "dbtestC"], selected)
+ def test_db_tests_roots_override(self):
+ # When roots are specified for db_tests they override all filtering since
+ # 'roots' are populated with the command line arguments.
+ config = {"binary": self.test_file_explorer.binary,
+ "include_suites": ["dbtestB"],
+ "roots": ["dbtestOverride"]}
+ selected = selector.filter_tests("db_test", config, self.test_file_explorer)
+ self.assertEqual(["dbtestOverride"], selected)
+
def test_db_tests_include_suites(self):
config = {"binary": self.test_file_explorer.binary,
"include_suites": ["dbtestB"]}