[Lldb-commits] [PATCH] D47579: dotest: make inline tests compatible with -f

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu May 31 03:22:18 PDT 2018


labath created this revision.
labath added reviewers: JDevlieghere, aprantl, tberghammer.
Herald added a subscriber: eraman.

This is split off from https://reviews.llvm.org/D47265 where I needed to be able to invoke every test
with -f. That patch is kinda dead now, but this part seems like a good
cleanup anyway.

The problem with inline tests was in the way we were adding methods to
the class, which left them with an incorrect __name__ property. This
prevented dotest from finding them with -f.

I fix this with (what I think is) the correct way of dynamically
creating classes -- passing the list of methods during type construction
instead of fixing up the class afterwards. Among other things this has
the advantage of not needing to do anything special for debug info
variants. As our test method will be visible to the metaclass, it will
automagically to the multiplication for us.


https://reviews.llvm.org/D47579

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


Index: packages/Python/lldbsuite/test/lldbinline.py
===================================================================
--- packages/Python/lldbsuite/test/lldbinline.py
+++ packages/Python/lldbsuite/test/lldbinline.py
@@ -135,37 +135,11 @@
         makefile.flush()
         makefile.close()
 
-    @add_test_categories(["dsym"])
-    def __test_with_dsym(self):
+    def _test(self):
         self.using_dsym = True
         self.BuildMakefile()
         self.build()
         self.do_test()
-    __test_with_dsym.debug_info = "dsym"
-
-    @add_test_categories(["dwarf"])
-    def __test_with_dwarf(self):
-        self.using_dsym = False
-        self.BuildMakefile()
-        self.build()
-        self.do_test()
-    __test_with_dwarf.debug_info = "dwarf"
-
-    @add_test_categories(["dwo"])
-    def __test_with_dwo(self):
-        self.using_dsym = False
-        self.BuildMakefile()
-        self.build()
-        self.do_test()
-    __test_with_dwo.debug_info = "dwo"
-
-    @add_test_categories(["gmodules"])
-    def __test_with_gmodules(self):
-        self.using_dsym = False
-        self.BuildMakefile()
-        self.build()
-        self.do_test()
-    __test_with_gmodules.debug_info = "gmodules"
 
     def execute_user_command(self, __command):
         exec(__command, globals(), locals())
@@ -237,18 +211,11 @@
     InlineTest.mydir = TestBase.compute_mydir(__file)
 
     test_name, _ = os.path.splitext(file_basename)
+
+    test = ApplyDecoratorsToFunction(InlineTest._test, decorators)
     # Build the test case
-    test = type(test_name, (InlineTest,), {'using_dsym': None})
-    test.name = test_name
-
-    test.test_with_dsym = ApplyDecoratorsToFunction(
-        test._InlineTest__test_with_dsym, decorators)
-    test.test_with_dwarf = ApplyDecoratorsToFunction(
-        test._InlineTest__test_with_dwarf, decorators)
-    test.test_with_dwo = ApplyDecoratorsToFunction(
-        test._InlineTest__test_with_dwo, decorators)
-    test.test_with_gmodules = ApplyDecoratorsToFunction(
-        test._InlineTest__test_with_gmodules, decorators)
+    test = type(test_name, (InlineTest,), dict(using_dsym=None, test=test,
+                                               name=test_name))
 
     # Add the test case to the globals, and hide InlineTest
     __globals.update({test_name: test})


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47579.149257.patch
Type: text/x-patch
Size: 2324 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20180531/c3b53e26/attachment.bin>


More information about the lldb-commits mailing list