[Piglit] [PATCH 06/35] framework/profile: Add a __len__ method to TestProfile

Dylan Baker dylan at pnwbakers.com
Wed Apr 4 22:26:54 UTC 2018


This exposes a standard interface for getting the number of tests in a
profile, which is itself nice. It will also allow us to encapsulate the
differences between the various profiles added in this series.
---
 framework/profile.py | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/framework/profile.py b/framework/profile.py
index b6deed0..925271e 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -284,6 +284,9 @@ class TestProfile(object):
             'ignore_missing': False,
         }
 
+    def __len__(self):
+        return sum(1 for _ in self.itertests())
+
     def setup(self):
         """Method to do pre-run setup."""
 
@@ -381,15 +384,12 @@ def run(profiles, logger, backend, concurrency):
     """
     chunksize = 1
 
-    # The logger needs to know how many tests are running. Because of filters
-    # there's no way to do that without making a concrete list out of the
-    # filters profiles.
-    profiles = [(p, list(p.itertests())) for p in profiles]
-    log = LogManager(logger, sum(len(l) for _, l in profiles))
+    profiles = [(p, p.itertests()) for p in profiles]
+    log = LogManager(logger, sum(len(p) for p, _ in profiles))
 
     # check that after the filters are run there are actually tests to run.
-    if not any(l for _, l in profiles):
-        raise exceptions.PiglitUserError('no matching tests')
+    # if not any(l for _, l in profiles):
+        # raise exceptions.PiglitUserError('no matching tests')
 
     def test(name, test, profile, this_pool=None):
         """Function to call test.execute from map"""
-- 
git-series 0.9.1


More information about the Piglit mailing list