Clean up this test.
authorJim Ingham <jingham@apple.com>
Wed, 18 Sep 2019 01:53:52 +0000 (01:53 +0000)
committerJim Ingham <jingham@apple.com>
Wed, 18 Sep 2019 01:53:52 +0000 (01:53 +0000)
I don't know what the intent of parts of this test were.  We set a
bunch of breakpoints and ran from one to the other, doing "self.runCmd("thread backtrace")"
then continuing to the next one.  We didn't actually verify the contents of the backtrace,
nor that we hit the breakpoints we set in any particular order.  The only actual test was
to run sel_getName at two of these stops.

So I reduced the test to just stopping at the places where we were actually going to run
an expression, and tested the expression.

llvm-svn: 372196

lldb/packages/Python/lldbsuite/test/lang/objc/foundation/TestObjCMethods2.py

index 20137e3..28d3558 100644 (file)
@@ -16,61 +16,26 @@ class FoundationTestCase2(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
+    NO_DEBUG_INFO_TESTCASE = True
+
     def test_expr_commands(self):
         """More expression commands for objective-c."""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-        lines = []
-        lines.append(
-            line_number(
-                'main.m',
-                '// Break here for selector: tests'))
-        lines.append(
-            line_number(
-                'main.m',
-                '// Break here for NSArray tests'))
-        lines.append(
-            line_number(
-                'main.m',
-                '// Break here for NSString tests'))
-        lines.append(
-            line_number(
-                'main.m',
-                '// Break here for description test'))
-        lines.append(
-            line_number(
-                'main.m',
-                '// Set break point at this line'))
-
-        # Create a bunch of breakpoints.
-        for line in lines:
-            lldbutil.run_break_set_by_file_and_line(
-                self, "main.m", line, num_expected_locations=1, loc_exact=True)
-
-        self.runCmd("run", RUN_SUCCEEDED)
+        main_spec = lldb.SBFileSpec("main.m")
 
+        (target, process, thread, bp) = lldbutil.run_to_source_breakpoint(
+            self, "Break here for selector: tests", main_spec)
+        
         # Test_Selector:
-        self.runCmd("thread backtrace")
         self.expect("expression (char *)sel_getName(sel)",
                     substrs=["(char *)",
                              "length"])
 
-        self.runCmd("process continue")
-
-        # Test_NSArray:
-        self.runCmd("thread backtrace")
-        self.runCmd("process continue")
-
-        # Test_NSString:
-        self.runCmd("thread backtrace")
-        self.runCmd("process continue")
-
-        # Test_MyString:
-        self.runCmd("thread backtrace")
+        desc_bkpt = target.BreakpointCreateBySourceRegex("Break here for description test",
+                                                          main_spec)
+        self.assertEqual(desc_bkpt.GetNumLocations(), 1, "description breakpoint has a location")
+        lldbutil.continue_to_breakpoint(process, desc_bkpt)
+        
         self.expect("expression (char *)sel_getName(_cmd)",
                     substrs=["(char *)",
                              "description"])
-
-        self.runCmd("process continue")