[Lldb-commits] [lldb] 8be41c7 - [test] Allow skipTestIfFn to apply to entire classes for skipIfNoSBHeaders

Jordan Rupprecht via lldb-commits lldb-commits at lists.llvm.org
Thu Nov 17 08:17:17 PST 2022


Author: Jordan Rupprecht
Date: 2022-11-17T08:17:10-08:00
New Revision: 8be41c787f9e12a4eb101e2dcad67ddc2da7ec1f

URL: https://github.com/llvm/llvm-project/commit/8be41c787f9e12a4eb101e2dcad67ddc2da7ec1f
DIFF: https://github.com/llvm/llvm-project/commit/8be41c787f9e12a4eb101e2dcad67ddc2da7ec1f.diff

LOG: [test] Allow skipTestIfFn to apply to entire classes for skipIfNoSBHeaders

Some test cases are already marked @skipIfNoSBHeaders, but they make use of SBAPI headers in test setup. The setup will fail if the headers are missing, so it is too late to wait until the test case to apply the skip annotation.

In addition to allowing this to apply to entire classes, I also changed all the existing annotations from test cases to test classes where necessary/appropriate.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D138181

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/decorators.py
    lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
    lldb/test/API/api/multithreaded/TestMultithreaded.py
    lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py b/lldb/packages/Python/lldbsuite/test/decorators.py
index dd47f6845ef2f..0c5f55f66246a 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -140,8 +140,10 @@ def wrapper(*args, **kwargs):
 def skipTestIfFn(expected_fn, bugnumber=None):
     def skipTestIfFn_impl(func):
         if isinstance(func, type) and issubclass(func, unittest2.TestCase):
-            raise Exception(
-                "@skipTestIfFn can only be used to decorate a test method")
+            reason = expected_fn()
+            # The return value is the reason (or None if we don't skip), so
+            # reason is used for both args.
+            return unittest2.skipIf(condition=reason, reason=reason)(func)
 
         @wraps(func)
         def wrapper(*args, **kwargs):

diff  --git a/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py b/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
index 1980b1434595f..b74e395b3e671 100644
--- a/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
+++ b/lldb/test/API/api/check_public_api_headers/TestPublicAPIHeaders.py
@@ -8,6 +8,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfNoSBHeaders
 class SBDirCheckerCase(TestBase):
     NO_DEBUG_INFO_TESTCASE = True
 
@@ -16,7 +17,6 @@ def setUp(self):
         self.source = 'main.cpp'
         self.generateSource(self.source)
 
-    @skipIfNoSBHeaders
     def test_sb_api_directory(self):
         """Test the SB API directory and make sure there's no unwanted stuff."""
 

diff  --git a/lldb/test/API/api/multithreaded/TestMultithreaded.py b/lldb/test/API/api/multithreaded/TestMultithreaded.py
index 33759906243a4..c8e89b580c40e 100644
--- a/lldb/test/API/api/multithreaded/TestMultithreaded.py
+++ b/lldb/test/API/api/multithreaded/TestMultithreaded.py
@@ -9,6 +9,7 @@
 from lldbsuite.test import lldbutil
 
 
+ at skipIfNoSBHeaders
 class SBBreakpointCallbackCase(TestBase):
 
     NO_DEBUG_INFO_TESTCASE = True
@@ -25,7 +26,6 @@ def setUp(self):
         self.generateSource('test_stop-hook.cpp')
 
     @skipIfRemote
-    @skipIfNoSBHeaders
     # clang-cl does not support throw or catch (llvm.org/pr24538)
     @skipIfWindows
     def test_python_stop_hook(self):
@@ -34,7 +34,6 @@ def test_python_stop_hook(self):
                             'test_python_stop_hook')
 
     @skipIfRemote
-    @skipIfNoSBHeaders
     # clang-cl does not support throw or catch (llvm.org/pr24538)
     @skipIfWindows
     def test_breakpoint_callback(self):
@@ -43,7 +42,6 @@ def test_breakpoint_callback(self):
                             'test_breakpoint_callback')
 
     @skipIfRemote
-    @skipIfNoSBHeaders
     # clang-cl does not support throw or catch (llvm.org/pr24538)
     @skipIfWindows
     def test_breakpoint_location_callback(self):
@@ -52,7 +50,6 @@ def test_breakpoint_location_callback(self):
                             'test_breakpoint_location_callback')
 
     @skipIfRemote
-    @skipIfNoSBHeaders
     # clang-cl does not support throw or catch (llvm.org/pr24538)
     @skipIfWindows
     @expectedFlakeyFreeBSD
@@ -63,7 +60,6 @@ def test_sb_api_listener_event_description(self):
             'test_listener_event_description')
 
     @skipIfRemote
-    @skipIfNoSBHeaders
     # clang-cl does not support throw or catch (llvm.org/pr24538)
     @skipIfWindows
     @expectedFlakeyFreeBSD
@@ -76,7 +72,6 @@ def test_sb_api_listener_event_process_state(self):
             'test_listener_event_process_state')
 
     @skipIfRemote
-    @skipIfNoSBHeaders
     # clang-cl does not support throw or catch (llvm.org/pr24538)
     @skipIfWindows
     @expectedFlakeyFreeBSD

diff  --git a/lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py b/lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
index 3ac2cdd6419ae..cde75dd1131ef 100644
--- a/lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
+++ b/lldb/test/API/functionalities/plugins/command_plugin/TestPluginCommands.py
@@ -12,7 +12,6 @@ class PluginCommandTestCase(TestBase):
 
     def setUp(self):
         TestBase.setUp(self)
-        self.generateSource('plugin.cpp')
 
     @skipIfNoSBHeaders
     # Requires a compatible arch and platform to link against the host's built
@@ -22,6 +21,7 @@ def setUp(self):
     @no_debug_info_test
     def test_load_plugin(self):
         """Test that plugins that load commands work correctly."""
+        self.generateSource('plugin.cpp')
 
         plugin_name = "plugin"
         if sys.platform.startswith("darwin"):


        


More information about the lldb-commits mailing list