[Piglit] [PATCH 1/4] framework: Fix filtering of excluded tests.

Kenneth Graunke kenneth at whitecape.org
Fri Feb 17 01:38:48 PST 2012


del dict[key] will raise a KeyError if the key isn't actually in the
dictionary.  This can happen if, say, a test didn't match the -t option
and subsequently matched a -x option.

Also, deleting dictionary items while iterating over them is apparently
not safe in Python 3, so we may as well just create a new dictionary
with only the entries we want.

This is simpler anyway.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 framework/core.py |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index 2414709..a84c68f 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -520,15 +520,12 @@ class TestProfile:
 		def matches_any_regexp(x, re_list):
 			return True in map(lambda r: r.search(x) != None, re_list)
 
+		def test_matches((path, test)):
+			return (matches_any_regexp(path, env.filter) and
+			        not matches_any_regexp(path, env.exclude_filter))
+
 		# Filter out unwanted tests
-		for path in self.test_list.keys():
-			# Exclude tests that don't match any of the `filter' regexps (-t options)
-			if env.filter and not matches_any_regexp(path, env.filter):
-				del self.test_list[path]
-
-			# Exclude tests that match an `exclude_filter' regexp (-x options)
-			if env.exclude_filter and matches_any_regexp(path, env.exclude_filter):
-				del self.test_list[path]
+		self.test_list = dict(filter(test_matches, self.test_list.items()))
 
 		# Queue up all the concurrent tests, so the pool is filled
 		# at the start of the test run.
-- 
1.7.7.6



More information about the Piglit mailing list