labath created this revision.
Herald added subscribers: JDevlieghere, eraman.

This needs to be cleaned up before we can consider submitting it.
However, I am putting it out here, so we you can test it's impact on
your setup.

PS: This does not prevent the debug-info replication for "inline" tests.
It just implements it more nicely.


https://reviews.llvm.org/D47265

Files:
  lit/Suite/lldbtest.py
  packages/Python/lldbsuite/test/example/TestSequenceFunctions.py
  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,13 @@
     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 = type(test_name, (InlineTest,), dict(using_dsym=None, test=test))
     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)
 
     # Add the test case to the globals, and hide InlineTest
     __globals.update({test_name: test})
Index: packages/Python/lldbsuite/test/example/TestSequenceFunctions.py
===================================================================
--- packages/Python/lldbsuite/test/example/TestSequenceFunctions.py
+++ /dev/null
@@ -1,34 +0,0 @@
-"""An example unittest copied from python tutorial."""
-
-import random
-import unittest
-import traceback
-
-
-class SequenceFunctionsTestCase(unittest.TestCase):
-
-    def setUp(self):
-        # traceback.print_stack()
-        self.seq = list(range(10))
-
-    def tearDown(self):
-        # traceback.print_stack()
-        pass
-
-    def test_shuffle(self):
-        # make sure the shuffled sequence does not lose any elements
-        random.shuffle(self.seq)
-        self.seq.sort()
-        self.assertEqual(self.seq, list(range(10)))
-
-    def test_choice(self):
-        element = random.choice(self.seq)
-        self.assertTrue(element in self.seq)
-
-    def test_sample(self):
-        self.assertRaises(ValueError, random.sample, self.seq, 20)
-        for element in random.sample(self.seq, 5):
-            self.assertTrue(element in self.seq)
-
-if __name__ == '__main__':
-    unittest.main()
Index: lit/Suite/lldbtest.py
===================================================================
--- lit/Suite/lldbtest.py
+++ lit/Suite/lldbtest.py
@@ -13,38 +13,41 @@
 class LLDBTest(TestFormat):
     def __init__(self, dotest_cmd):
         self.dotest_cmd = dotest_cmd
+        self.tests = None
+
+    def getTests(self, bin_dir):
+        if self.tests:
+            return self.tests
+        dumper = os.path.join(os.path.dirname(__file__), "lldbtestdumper.py")
+        lldb_path = os.path.join(bin_dir, "lldb")
+        output = subprocess.check_output([sys.executable, dumper, lldb_path])
+        self.tests = [line.split() for line in output.splitlines()]
+        return self.tests
+
 
     def getTestsInDirectory(self, testSuite, path_in_suite, litConfig,
                             localConfig):
-        source_path = testSuite.getSourcePath(path_in_suite)
-        for filename in os.listdir(source_path):
-            # Ignore dot files and excluded tests.
-            if (filename.startswith('.') or filename in localConfig.excludes):
-                continue
-
-            # Ignore files that don't start with 'Test'.
-            if not filename.startswith('Test'):
+        for test in self.getTests(testSuite.config.llvm_tools_dir):
+            if test[0:-3] != list(path_in_suite):
                 continue
-
-            filepath = os.path.join(source_path, filename)
-            if not os.path.isdir(filepath):
-                base, ext = os.path.splitext(filename)
-                if ext in localConfig.suffixes:
-                    yield lit.Test.Test(testSuite, path_in_suite +
-                                        (filename, ), localConfig)
+            yield lit.Test.Test(testSuite, test, localConfig)
 
     def execute(self, test, litConfig):
         if litConfig.noExecute:
             return lit.Test.PASS, ''
 
         if test.config.unsupported:
             return (lit.Test.UNSUPPORTED, 'Test is unsupported')
 
-        testPath, testFile = os.path.split(test.getSourcePath())
+        testDir = test.getSourcePath()
+        testDir, testMethod = os.path.split(testDir)
+        testDir, testClass = os.path.split(testDir)
+        testDir, testFile = os.path.split(testDir)
+
         # On Windows, the system does not always correctly interpret shebang lines.
         # To make sure we can execute the tests, add python exe as the first parameter
         # of the command.
-        cmd = [sys.executable] + self.dotest_cmd + [testPath, '-p', testFile]
+        cmd = [sys.executable] + self.dotest_cmd + [testDir, '-p', testFile, '-f', testClass+"."+testMethod]
 
         try:
             out, err, exitCode = lit.util.executeCommand(
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
  • [Lldb-commits] [PATCH] D4726... Pavel Labath via Phabricator via lldb-commits

Reply via email to