[Lldb-commits] [PATCH] D43024: [test] Enable test category for	inline tests.
    Jonas Devlieghere via Phabricator via lldb-commits 
    lldb-commits at lists.llvm.org
       
    Wed Feb  7 08:09:07 PST 2018
    
    
  
JDevlieghere created this revision.
JDevlieghere added reviewers: vsk, davide, labath.
Herald added a subscriber: llvm-commits.
Inlined tests have a test function that is actually an instance method,
which requires a slightly different approach when it comes to setting
the category attribute. The attribute must be set on the actual
function, rather than on a particular instance.
Repository:
  rL LLVM
https://reviews.llvm.org/D43024
Files:
  lldb/packages/Python/lldbsuite/test/decorators.py
Index: lldb/packages/Python/lldbsuite/test/decorators.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/decorators.py
+++ lldb/packages/Python/lldbsuite/test/decorators.py
@@ -4,6 +4,7 @@
 # System modules
 from distutils.version import LooseVersion, StrictVersion
 from functools import wraps
+import inspect
 import os
 import platform
 import re
@@ -305,7 +306,11 @@
                 "@add_test_categories can only be used to decorate a test method")
         if hasattr(func, "categories"):
             cat.extend(func.categories)
-        func.categories = cat
+        # For instance methods, the attribute must be set on the actual function.
+        if inspect.ismethod(func):
+            func.__func__.categories = cat
+        else:
+            func.categories = cat
         return func
 
     return impl
@@ -518,7 +523,7 @@
                 'LLDB.h')
             if os.path.exists(header):
                 return None
-        
+
         header = os.path.join(
             os.environ["LLDB_SRC"],
             "include",
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43024.133218.patch
Type: text/x-patch
Size: 1102 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180207/0bbb4713/attachment.bin>
    
    
More information about the lldb-commits
mailing list