[Lldb-commits] [PATCH] D81516: [lldb/Test] Ensure inline tests have a unique build directory

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 9 18:15:52 PDT 2020


JDevlieghere updated this revision to Diff 269713.
JDevlieghere marked 2 inline comments as done.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81516/new/

https://reviews.llvm.org/D81516

Files:
  lldb/packages/Python/lldbsuite/test/lldbinline.py
  lldb/packages/Python/lldbsuite/test/lldbtest.py


Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1743,6 +1743,12 @@
         if original_testcase.NO_DEBUG_INFO_TESTCASE:
             return original_testcase
 
+        # Inline tests have one method named 'test' which means that multiple
+        # inline tests in the same file end up sharing the same build directory
+        # per variant. The '__inline_name__' attribute ensures that the
+        # (unique) test name is used instead.
+        inline_name = attrs.get('__inline_name__')
+
         newattrs = {}
         for attrname, attrvalue in attrs.items():
             if attrname.startswith("test") and not getattr(
@@ -1766,7 +1772,7 @@
                     def test_method(self, attrvalue=attrvalue):
                         return attrvalue(self)
 
-                    method_name = attrname + "_" + cat
+                    method_name = '_'.join(filter(None, [attrname, inline_name, cat]))
                     test_method.__name__ = method_name
                     test_method.debug_info = cat
                     newattrs[method_name] = test_method
Index: lldb/packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -206,7 +206,7 @@
     test_func = ApplyDecoratorsToFunction(InlineTest._test, decorators)
     # Build the test case
     test_class = type(name, (InlineTest,), dict(test=test_func,
-        name=name, _build_dict=build_dict))
+        name=name, __inline_name__=name, _build_dict=build_dict))
 
     # Add the test case to the globals, and hide InlineTest
     __globals.update({name: test_class})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81516.269713.patch
Type: text/x-patch
Size: 1892 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200610/3a9fbab4/attachment-0001.bin>


More information about the lldb-commits mailing list