[Piglit] [PATCH 3/3] framework/options: Handle '/' in -t and -x options
baker.dylan.c at gmail.com
baker.dylan.c at gmail.com
Fri Nov 20 17:10:03 PST 2015
From: Dylan Baker <baker.dylan.c at gmail.com>
This patch allows passing '/' separated tests into the
-t/--include-tests -x/--exclude-tests options. This becomes
particularly important to fix since the verbose logger now prints '/'
separated names, as does the console logger.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/options.py | 27 ++++++++++++++++++++++-----
framework/tests/options_tests.py | 14 ++++++++++++++
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/framework/options.py b/framework/options.py
index 4a39ae9..07e1434 100644
--- a/framework/options.py
+++ b/framework/options.py
@@ -106,6 +106,22 @@ class _ReList(collections.MutableSequence):
return [l.pattern for l in self]
+class _FilterReList(_ReList):
+ """A version of ReList that handles group maddness.
+
+ Groups are printed with '/' as a separator, but internall something else
+ may be used. This version replaces '/' with '.'.
+
+ """
+ def __setitem__(self, index, value):
+ # Replace '/' with '.', this solves the problem of '/' not matching
+ # grouptools.SEPARATOR, but without needing to import grouptools
+ super(_FilterReList, self).__setitem__(index, value.replace('/', '.'))
+
+ def insert(self, index, value):
+ super(_FilterReList, self).insert(index, value.replace('/', '.'))
+
+
class _ReListDescriptor(object):
"""A Descriptor than ensures reassignment of _{in,ex}clude_filter is an
_ReList
@@ -115,8 +131,9 @@ class _ReListDescriptor(object):
point.
"""
- def __init__(self, name):
+ def __init__(self, name, type_=_ReList):
self.__name = name
+ self.__type = type_
def __get__(self, instance, cls):
try:
@@ -131,10 +148,10 @@ class _ReListDescriptor(object):
def __set__(self, instance, value):
assert isinstance(value, (collections.Sequence, collections.Set))
- if isinstance(value, _ReList):
+ if isinstance(value, self.__type):
setattr(instance, self.__name, value)
else:
- setattr(instance, self.__name, _ReList(value))
+ setattr(instance, self.__name, self.__type(value))
def __delete__(self, instance):
raise NotImplementedError('Cannot delete {} from {}'.format(
@@ -160,8 +177,8 @@ class _Options(object): # pylint: disable=too-many-instance-attributes
env -- environment variables set for each test before run
"""
- include_filter = _ReListDescriptor('_include_filter')
- exclude_filter = _ReListDescriptor('_exclude_filter')
+ include_filter = _ReListDescriptor('_include_filter', type_=_FilterReList)
+ exclude_filter = _ReListDescriptor('_exclude_filter', type_=_FilterReList)
def __init__(self):
self.concurrent = True
diff --git a/framework/tests/options_tests.py b/framework/tests/options_tests.py
index ec6318d..695935d 100644
--- a/framework/tests/options_tests.py
+++ b/framework/tests/options_tests.py
@@ -185,3 +185,17 @@ def test_options_clear():
test.clear()
nt.eq_(list(iter(baseline)), list(iter(test)))
+
+
+def test_filterrelist_set():
+ """options._FilterReList.__setitem__: replaces '/' with '.'"""
+ test = options._FilterReList(['foo'])
+ test[0] = 'foo/bar'
+ nt.eq_(test[0].pattern, 'foo.bar')
+
+
+def test_filterrelist_insert():
+ """options._FilterReList.insert: replaces '/' with '.'"""
+ test = options._FilterReList()
+ test.insert(0, 'foo/bar')
+ nt.eq_(test[0].pattern, 'foo.bar')
--
2.6.2
More information about the Piglit
mailing list