[Lldb-commits] [lldb] [lldb][test] Remove `reason` from `unittest2.expectedFailure` usage (PR #73028)

Jordan Rupprecht via lldb-commits lldb-commits at lists.llvm.org
Tue Nov 21 17:59:53 PST 2023


https://github.com/rupprecht updated https://github.com/llvm/llvm-project/pull/73028

>From a0805cfc2b2b1c84d58c0551ccf1acfaf2326a4a Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht <rupprecht at google.com>
Date: Tue, 21 Nov 2023 11:38:43 -0800
Subject: [PATCH 1/2] [lldb][test] Remove `reason` from
 `unittest2.expectedFailure` usage

When switching to the standard `unittest` library, various unittests fail because we provide a "bugnumber" (a github issue/rdar link), but there is no longer a way to provide an xfail reason. See: https://docs.python.org/3/library/unittest.html?highlight=unittest#unittest.expectedFailure
---
 .../API/functionalities/jitloader_gdb/TestJITLoaderGDB.py | 2 +-
 .../API/functionalities/thread/state/TestThreadStates.py  | 4 ++--
 lldb/test/API/lang/c/shared_lib/TestSharedLib.py          | 2 +-
 .../TestSharedLibStrippedSymbols.py                       | 2 +-
 lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py   | 8 ++++----
 .../TestCppReferenceToOuterClass.py                       | 2 +-
 lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py   | 2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py
index e93f566ea7ea63c..409dcf8e19d383b 100644
--- a/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py
+++ b/lldb/test/API/functionalities/jitloader_gdb/TestJITLoaderGDB.py
@@ -13,7 +13,7 @@ class JITLoaderGDBTestCase(TestBase):
         lambda: "Skipped because the test crashes the test runner",
         bugnumber="llvm.org/pr24702",
     )
-    @expectedFailure("llvm.org/pr24702")
+    @expectedFailure  # llvm.org/pr24702
     def test_bogus_values(self):
         """Test that we handle inferior misusing the GDB JIT interface"""
         self.build()
diff --git a/lldb/test/API/functionalities/thread/state/TestThreadStates.py b/lldb/test/API/functionalities/thread/state/TestThreadStates.py
index ad1edff6ae3f354..8e937d6c22a6758 100644
--- a/lldb/test/API/functionalities/thread/state/TestThreadStates.py
+++ b/lldb/test/API/functionalities/thread/state/TestThreadStates.py
@@ -40,14 +40,14 @@ def test_state_after_continue(self):
     @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24660")
     @expectedFailureNetBSD
     # thread states not properly maintained
-    @expectedFailure("llvm.org/pr16712")
+    @expectedFailure  # llvm.org/pr16712
     def test_state_after_expression(self):
         """Test thread state after expression."""
         self.build()
         self.thread_state_after_expression_test()
 
     # thread states not properly maintained
-    @expectedFailure("llvm.org/pr15824 and <rdar://problem/28557237>")
+    @expectedFailure  # llvm.org/pr15824 and <rdar://problem/28557237>
     @expectedFailureAll(
         oslist=["windows"],
         bugnumber="llvm.org/pr24668: Breakpoints not resolved correctly",
diff --git a/lldb/test/API/lang/c/shared_lib/TestSharedLib.py b/lldb/test/API/lang/c/shared_lib/TestSharedLib.py
index b375aa6a86e14fb..39f5a144703763e 100644
--- a/lldb/test/API/lang/c/shared_lib/TestSharedLib.py
+++ b/lldb/test/API/lang/c/shared_lib/TestSharedLib.py
@@ -34,7 +34,7 @@ def test_expr_no_preload(self):
         """Test that types work when defined in a shared library and forward-declared in the main executable, but with preloading disabled"""
         self.common_test_expr(False)
 
-    @expectedFailure("llvm.org/PR36712")
+    @expectedFailure  # llvm.org/PR36712
     def test_frame_variable(self):
         """Test that types work when defined in a shared library and forward-declared in the main executable"""
         self.build()
diff --git a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
index f7035edddaf09b8..5fd6cc1a3172f48 100644
--- a/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
+++ b/lldb/test/API/lang/c/shared_lib_stripped_symbols/TestSharedLibStrippedSymbols.py
@@ -27,7 +27,7 @@ def test_expr(self):
         )
 
     @expectedFailureAll(oslist=["windows"])
-    @expectedFailure("llvm.org/PR36712")
+    @expectedFailure  # llvm.org/PR36712
     def test_frame_variable(self):
         """Test that types work when defined in a shared library and forward-declared in the main executable"""
         self.build()
diff --git a/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py b/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py
index f88667b9dfa2ae9..1803fdcd4d87956 100644
--- a/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py
+++ b/lldb/test/API/lang/cpp/namespace/TestNamespaceLookup.py
@@ -40,7 +40,7 @@ def runToBkpt(self, command):
         )
 
     @skipIfWindows  # This is flakey on Windows: llvm.org/pr38373
-    @expectedFailure("CU-local objects incorrectly scoped")
+    @expectedFailure  # CU-local objects incorrectly scoped
     def test_scope_lookup_with_run_command_globals(self):
         """Test scope lookup of functions in lldb."""
         self.build()
@@ -210,7 +210,7 @@ def test_scope_lookup_with_run_command(self):
         # Evaluate B::func() - should call B::func()
         self.expect_expr("B::func()", result_type="int", result_value="4")
 
-    @expectedFailure("lldb scope lookup of functions bugs")
+    @expectedFailure  # lldb scope lookup of functions bugs
     def test_function_scope_lookup_with_run_command(self):
         """Test scope lookup of functions in lldb."""
         self.build()
@@ -271,7 +271,7 @@ def test_scope_after_using_directive_lookup_with_run_command(self):
         # Evaluate func2() - should call A::func2()
         self.expect_expr("func2()", result_type="int", result_value="3")
 
-    @expectedFailure("lldb scope lookup after using declaration bugs")
+    @expectedFailure  # lldb scope lookup after using declaration bugs
     # NOTE: this test may fail on older systems that don't emit import
     # emtries in DWARF - may need to add checks for compiler versions here.
     def test_scope_after_using_declaration_lookup_with_run_command(self):
@@ -293,7 +293,7 @@ def test_scope_after_using_declaration_lookup_with_run_command(self):
         # Evaluate func() - should call A::func()
         self.expect_expr("func()", result_type="int", result_value="3")
 
-    @expectedFailure("lldb scope lookup ambiguity after using bugs")
+    @expectedFailure  # lldb scope lookup ambiguity after using bugs
     def test_scope_ambiguity_after_using_lookup_with_run_command(self):
         """Test scope lookup ambiguity after using in lldb."""
         self.build()
diff --git a/lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py b/lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
index a7b02baeb13c58d..cbabce41b58f973 100644
--- a/lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
+++ b/lldb/test/API/lang/cpp/reference-to-outer-type/TestCppReferenceToOuterClass.py
@@ -5,7 +5,7 @@
 
 
 class TestCase(TestBase):
-    @expectedFailure("The fix for this was reverted due to llvm.org/PR52257")
+    @expectedFailure  # The fix for this was reverted due to llvm.org/PR52257
     def test(self):
         self.build()
         self.dbg.CreateTarget(self.getBuildArtifact("a.out"))
diff --git a/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py b/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
index 8153376b4c6feea..ead4d00c46c767b 100644
--- a/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
+++ b/lldb/test/API/lang/objc/hidden-ivars/TestHiddenIvars.py
@@ -57,7 +57,7 @@ def test_frame_variable(self):
             self.build()
             self.frame_var(False)
 
-    @expectedFailure("rdar://18683637")
+    @expectedFailure  # rdar://18683637
     def test_frame_variable_across_modules(self):
         if self.getArchitecture() == "i386":
             self.skipTest("requires modern objc runtime")

>From 938b47401f52ec2ca7244fb8992d6303b1fac6df Mon Sep 17 00:00:00 2001
From: Jordan Rupprecht <rupprecht at google.com>
Date: Tue, 21 Nov 2023 17:59:41 -0800
Subject: [PATCH 2/2] Add TestExprs usage

---
 lldb/test/API/commands/expression/test/TestExprs.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lldb/test/API/commands/expression/test/TestExprs.py b/lldb/test/API/commands/expression/test/TestExprs.py
index 76a5e9efebb1866..03c2c01a77abdde 100644
--- a/lldb/test/API/commands/expression/test/TestExprs.py
+++ b/lldb/test/API/commands/expression/test/TestExprs.py
@@ -43,9 +43,9 @@ def build_and_run(self):
 
         self.runCmd("run", RUN_SUCCEEDED)
 
-    @expectedFailure(
-        "llvm.org/pr17135 <rdar://problem/14874559> APFloat::toString does not identify the correct (i.e. least) precision."
-    )
+    # llvm.org/pr17135 <rdar://problem/14874559>
+    # APFloat::toString does not identify the correct (i.e. least) precision.
+    @expectedFailure
     def test_floating_point_expr_commands(self):
         self.build_and_run()
 



More information about the lldb-commits mailing list