https://github.com/augusto2112 created 
https://github.com/llvm/llvm-project/pull/215400

`MakeInlineTest` handed every generated test class the one shared 
`InlineTest._test` function object, and several decorators record their state 
on the function object they are handed rather than on a wrapper. Some tests 
would mutate this state, causing some tests to unexpectedly run with decorators 
thei weren't annotated with.

Assisted-by: Claude

>From af660aae309d59289ac1b7f92d72cbf4160e449e Mon Sep 17 00:00:00 2001
From: Augusto Noronha <[email protected]>
Date: Mon, 10 Aug 2026 13:02:16 -0700
Subject: [PATCH] [lldb][test] Give each inline test its own function object

`MakeInlineTest` handed every generated test class the one shared
`InlineTest._test` function object, and several decorators record their state
on the function object they are handed rather than on a wrapper. Some tests
would mutate this state, causing some tests to unexpectedly run with
decorators thei weren't annotated with.

Assisted-by: Claude
---
 lldb/packages/Python/lldbsuite/test/decorators.py | 14 ++++++++++++++
 lldb/packages/Python/lldbsuite/test/lldbinline.py |  4 +++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index 6524d73e4a349..5b4308a619670 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -263,6 +263,20 @@ def expectedFailure_impl(func):
         return expectedFailure_impl
 
 
+def FreshTestFunction(src):
+    """Return a private copy of *src* for one generated test class to own.
+
+    Several decorators record their state on the function object they are
+    handed instead of on a wrapper.
+    """
+
+    @wraps(src)
+    def copy(self):
+        return src(self)
+
+    return copy
+
+
 def _skipForVariant(variant_name, expected_fn, bugnumber=None):
     """Mark a test method as skipped for a specific variant dimension.
 
diff --git a/lldb/packages/Python/lldbsuite/test/lldbinline.py 
b/lldb/packages/Python/lldbsuite/test/lldbinline.py
index d1225db4d61a9..0b92e25af1a20 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbinline.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbinline.py
@@ -197,7 +197,9 @@ def MakeInlineTest(__file, __globals, decorators=None, 
name=None, build_dict=Non
         file_basename = os.path.basename(__file)
         name, _ = os.path.splitext(file_basename)
 
-    test_func = ApplyDecoratorsToFunction(InlineTest._test, decorators)
+    test_func = ApplyDecoratorsToFunction(
+        FreshTestFunction(InlineTest._test), decorators
+    )
     # Build the test case
     test_class = type(
         name, (InlineTest,), dict(test=test_func, name=name, 
_build_dict=build_dict)

_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to