llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-lldb Author: Augusto Noronha (augusto2112) <details> <summary>Changes</summary> `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 --- Full diff: https://github.com/llvm/llvm-project/pull/215400.diff 2 Files Affected: - (modified) lldb/packages/Python/lldbsuite/test/decorators.py (+14) - (modified) lldb/packages/Python/lldbsuite/test/lldbinline.py (+3-1) ``````````diff 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) `````````` </details> https://github.com/llvm/llvm-project/pull/215400 _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
