[Piglit] [PATCH 3/4] framework: make use of Filter.run in Profile classes

Dylan Baker dylan at pnwbakers.com
Tue May 8 21:22:06 UTC 2018


---
 framework/profile.py | 37 +++++++++++++++++++++----------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/framework/profile.py b/framework/profile.py
index b0233866b..aff0ffa2c 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -369,17 +369,20 @@ class XMLProfile(object):
 
     def _itertests(self):
         """Always iterates tests instead of using the forced test_list."""
-        with gzip.open(self.filename, 'rt') as f:
-            doc = et.iterparse(f, events=(b'end', ))
-            _, root = next(doc)  # get the root so we can keep clearing it
-            for _, e in doc:
-                if e.tag != 'Test':
-                    continue
-                k = e.attrib['name']
-                v = make_test(e)
-                if all(f(k, v) for f in self.filters):
+        def _iter():
+            with gzip.open(self.filename, 'rt') as f:
+                doc = et.iterparse(f, events=(b'end', ))
+                _, root = next(doc)  # get the root so we can keep clearing it
+                for _, e in doc:
+                    if e.tag != 'Test':
+                        continue
+                    k = e.attrib['name']
+                    v = make_test(e)
                     yield k, v
-                root.clear()
+                    root.clear()
+
+        for k, v in self.filters.run(_iter()):
+            yield k, v
 
     def itertests(self):
         if self.forced_test_list:
@@ -432,11 +435,14 @@ class MetaProfile(object):
         pass
 
     def _itertests(self):
-        for p in self._profiles:
-            for k, v in p.itertests():
-                if all(f(k, v) for f in self.filters):
+        def _iter():
+            for p in self._profiles:
+                for k, v in p.itertests():
                     yield k, v
 
+        for k, v in self.filters.run(_iter()):
+            yield k, v
+
     def itertests(self):
         if self.forced_test_list:
             alltests = dict(self._itertests())
@@ -516,9 +522,8 @@ class TestProfile(object):
         else:
             opts = self.test_list  # pylint: disable=redefined-variable-type
 
-        for k, v in six.iteritems(opts):
-            if all(f(k, v) for f in self.filters):
-                yield k, v
+        for k, v in self.filters.run(six.iteritems(opts)):
+            yield k, v
 
 
 def load_test_profile(filename, python=None):
-- 
2.17.0



More information about the Piglit mailing list