summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite/test/lldbtest.py
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2015-12-14 13:17:18 +0000
committerPavel Labath <labath@google.com>2015-12-14 13:17:18 +0000
commitffbf9e86b2e542cfff2b293e7eb9e2d535fc7cc8 (patch)
tree805a313f9268f35e65695bf3d106ebb8a530bf5e /lldb/packages/Python/lldbsuite/test/lldbtest.py
parentb8ea7a0ed30b391cfb35762a660393bd3c601216 (diff)
downloadbcm5719-llvm-ffbf9e86b2e542cfff2b293e7eb9e2d535fc7cc8.tar.gz
bcm5719-llvm-ffbf9e86b2e542cfff2b293e7eb9e2d535fc7cc8.zip
Make test categories composable
Summary: Previously the add_test_categories would simply overwrite the current set of categories for a method. This change makes the decorator truly "add" categories, by extending the current set of categories instead of replacing it. To do this, I have: - replaced the getCategories() property on a method (which was itself a method), with a simple list property "categories". This makes add_test_categories easier to implement, and test categories isn't something which should change between calls anyway. - rewritten the getCategoriesForTest function to merge method categories with the categories of the test case. Previously, it would just use the method categories if they were present. I have also greatly simplified this method. Originally, it would use a lot of introspection to enable it being called on various types of objects. Based on my tests, it was only ever being called on a test case. The new function uses much less introspection then the preivous one, so we should easily catch any stray uses, if there are any, as they will generate exceptions now. Reviewers: zturner, tfiala, tberghammer Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D15451 llvm-svn: 255493
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test/lldbtest.py')
-rw-r--r--lldb/packages/Python/lldbsuite/test/lldbtest.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 77caab5f6f0..7fed0c47eea 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -509,12 +509,18 @@ def check_expected_version(comparison, expected, actual):
# Decorators for categorizing test cases.
#
from functools import wraps
+
def add_test_categories(cat):
- """Decorate an item with test categories"""
+ """Add test categories to a TestCase method"""
cat = test_categories.validate(cat, True)
def impl(func):
- func.getCategories = lambda test: cat
+ if isinstance(func, type) and issubclass(func, unittest2.TestCase):
+ raise Exception("@add_test_categories can only be used to decorate a test method")
+ if hasattr(func, "categories"):
+ cat.extend(func.categories)
+ func.categories = cat
return func
+
return impl
def benchmarks_test(func):
OpenPOWER on IntegriCloud