about summary refs log tree commit diff stats
path: root/test/utils/testset.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/utils/testset.py')
-rw-r--r--test/utils/testset.py50
1 files changed, 30 insertions, 20 deletions
diff --git a/test/utils/testset.py b/test/utils/testset.py
index 4336f4fa..e1df01a4 100644
--- a/test/utils/testset.py
+++ b/test/utils/testset.py
@@ -267,26 +267,36 @@ class TestSet(object):
         """Filter tests by tags
         @include_tags: list of tags' name (whitelist)
         @exclude_tags: list of tags' name (blacklist)
-        @include_tags and @exclude_tags cannot be used together"""
-
-        if include_tags and exclude_tags:
-            raise ValueError("Include and Exclude cannot be used together")
+        If @include_tags and @exclude_tags are used together, @exclude_tags will
+        act as a blacklist on @include_tags generated tests
+        """
 
-        new_testset_include = []
-        new_testset_exclude = list(self.tests)
+        new_testset = []
 
-        # Update include and exclude lists
-        for index, test in enumerate(self.tests):
-            for tag in test.tags:
-                if exclude_tags and tag in exclude_tags:
-                    new_testset_exclude.remove(test)
-                    break
-                if include_tags and tag in include_tags:
-                    new_testset_include.append(test)
-                    break
+        include_tags = set(include_tags)
+        exclude_tags = set(exclude_tags)
+        if include_tags.intersection(exclude_tags):
+            raise ValueError("Tags are mutually included and excluded: %s" % include_tags.intersection(exclude_tags))
 
-        # Update testset list
-        if include_tags:
-            self.tests = new_testset_include
-        elif exclude_tags:
-            self.tests = new_testset_exclude
+        for test in self.tests:
+            tags = set(test.tags)
+            if exclude_tags.intersection(tags):
+                # Ignore the current test because it is excluded
+                continue
+            if not include_tags:
+                new_testset.append(test)
+            else:
+                if include_tags.intersection(tags):
+                    new_testset.append(test)
+
+                    # Add tests dependencies
+                    dependency = list(test.depends)
+                    while dependency:
+                        subtest = dependency.pop()
+                        if subtest not in new_testset:
+                            new_testset.append(subtest)
+                        for subdepends in subtest.depends:
+                            if subdepends not in new_testset:
+                                dependency.append(subdepends)
+
+        self.tests = new_testset