[Piglit] [PATCH] framework: improve the TestProfile::remove_test() method

Brian Paul brianp at vmware.com
Thu May 2 13:56:58 PDT 2013


The previous implementation didn't really work too well.

If you tried something like
profile.remove_test(""spec/!OpenGL 3.1/primitive-restart-xfb generated")
you'd just get a Python exception and die.

Also, it was painful to remove whole categories of tests, such as
"spec/!OpenGL 3.1/".

The new version allows you to specify a full test name with arguments
as seen above.

Also, it supports *-style wildcards so that and entire category of tests
can be easily removed with something like remove_test("spec/!OpenGL 3.1/*")
---
 framework/core.py |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/framework/core.py b/framework/core.py
index 6a3b97a..6e8a8c2 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -518,6 +518,7 @@ class TestProfile:
 	def __init__(self):
 		self.tests = Group()
 		self.test_list = {}
+		self.remove_list = []
 
 	def flatten_group_hierarchy(self):
 		'''
@@ -541,6 +542,14 @@ class TestProfile:
 		# Clear out the old Group()
 		self.tests = Group()
 
+	def in_remove_list(self, test):
+		"""Is the given test in the list previously specified by calls to
+		remove_test()?"""
+		for t in self.remove_list:
+			if t.match(test):
+				return True
+		return False
+
 	def prepare_test_list(self, env):
 		self.flatten_group_hierarchy()
 
@@ -551,6 +560,7 @@ class TestProfile:
 			path, test = item
 			return ((not env.filter or matches_any_regexp(path, env.filter)) and
 			        not path in env.exclude_tests and
+			        not self.in_remove_list(path) and
 			        not matches_any_regexp(path, env.exclude_filter))
 
 		# Filter out unwanted tests
@@ -578,19 +588,20 @@ class TestProfile:
 				test.doRun(env, path, json_writer)
 		ConcurrentTestPool().join()
 
-	def remove_test(self, test_path):
-		"""Remove a fully qualified test from the profile.
-
-		``test_path`` is a string with slash ('/') separated
-		components. It has no leading slash. For example::
-			test_path = 'spec/glsl-1.30/linker/do-stuff'
+	def remove_test(self, test_pattern):
+		"""Remove a test from the profile.
+		``test_path`` may be a fully-qualified test name (with arguemnts)
+		or a pattern containing '*' wildcard characters.  Example:
+			'spec/glsl-1.30/linker/do-stuff'
+			'spec/EXT_framebuffer_multisample/polygon-smooth 4'
+			'spec/!OpenGL 3.1/*'
 		"""
+		test_pattern = string.replace(test_pattern, ".", "\.")
+		test_pattern = string.replace(test_pattern, "*", ".*")
+		t = re.compile(test_pattern)
+		self.remove_list.append(t)
+
 
-		l = test_path.split('/')
-		group = self.tests[l[0]]
-		for group_name in l[1:-2]:
-			group = group[group_name]
-		del group[l[-1]]
 
 #############################################################################
 ##### Loaders
-- 
1.7.3.4



More information about the Piglit mailing list