OSDN Git Service

[lldb/Test] Fix substrs order in self.expect for the remaining tests (NFC)
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 31 Jan 2020 21:26:51 +0000 (13:26 -0800)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 31 Jan 2020 21:35:33 +0000 (13:35 -0800)
Currently the substrs parameter takes a list of strings that need to be
found but the ordering isn't checked. D73766 might change that so this
changes a several tests so that the order of the strings in the substrs
list is in the order in which they appear in the output.

lldb/packages/Python/lldbsuite/test/commands/watchpoints/watchpoint_commands/command/TestWatchpointCommandLLDB.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-advanced/TestDataFormatterAdv.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-cpp/TestDataFormatterCpp.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCCF.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSContainer.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-objc/TestDataFormatterObjCNSError.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multimap/TestDataFormatterLibccMultiMap.py
lldb/packages/Python/lldbsuite/test/functionalities/data-formatter/data-formatter-stl/libcxx/multiset/TestDataFormatterLibcxxMultiSet.py

index cb5a535..b604d56 100644 (file)
@@ -1,4 +1,4 @@
-"""
+"""
 Test 'watchpoint command'.
 """
 
@@ -83,9 +83,12 @@ class WatchpointLLDBCommandTestCase(TestBase):
                     substrs=['stop reason = watchpoint'])
 
         # Check that the watchpoint snapshoting mechanism is working.
-        self.expect("watchpoint list -v",
-                    substrs=['old value:', ' = 0',
-                             'new value:', ' = 1'])
+        self.expect(
+            "watchpoint list -v",
+            substrs=[
+                'old value: 0', 'new value: 1', 'hw_index = 0',
+                'hit_count = 1', 'ignore_count = 0'
+            ])
 
         # The watchpoint command "forced" our global variable 'cookie' to
         # become 777.
index 246ebb3..d29547b 100644 (file)
@@ -147,15 +147,30 @@ class AdvDataFormatterTestCase(TestBase):
         self.runCmd("type summary add -c -x \"i_am_cool \[[0-9]\]\"")
         self.runCmd("type summary add -c i_am_cool")
 
-        self.expect("frame variable cool_array",
-                    substrs=['[0]',
-                             '[1]',
-                             '[2]',
-                             '[3]',
-                             '[4]',
-                             'integer',
-                             'character',
-                             'floating'])
+        self.expect(
+            "frame variable cool_array",
+            substrs=[
+                '[0]',
+                'integer',
+                'floating',
+                'character',
+                '[1]',
+                'integer',
+                'floating',
+                'character',
+                '[2]',
+                'integer',
+                'floating',
+                'character',
+                '[3]',
+                'integer',
+                'floating',
+                'character',
+                '[4]',
+                'integer',
+                'floating',
+                'character',
+            ])
 
         self.runCmd(
             "type summary add --summary-string \"int = ${*var.int_pointer}, float = ${*var.float_pointer}\" IWrapPointers")
@@ -315,11 +330,12 @@ class AdvDataFormatterTestCase(TestBase):
             matching=True,
             substrs=[
                 'e_2',
-                'n_2',
-                'r_2',
                 'i_2',
                 'k_2',
-                'o_2'])
+                'n_2',
+                'o_2',
+                'r_2',
+            ])
         self.expect(
             'frame variable a_long_guy --show-all-children',
             matching=False,
index 733c427..7a82991 100644 (file)
@@ -56,12 +56,9 @@ class CppDataFormatterTestCase(TestBase):
         self.runCmd("type format add -C yes -f c Type1")
 
         # The type format list should show our custom formats.
-        self.expect("type format list",
-                    substrs=['RealNumber',
-                             'Speed',
-                             'BitField',
-                             'Type1',
-                             'Type2'])
+        self.expect(
+            "type format list",
+            substrs=['Speed', 'BitField', 'RealNumber', 'Type2', 'Type1'])
 
         self.expect("frame variable",
                     patterns=['\(Speed\) SPILookHex = 0x[0-9a-f]+'  # Speed should look hex-ish now.
index 8671146..5b82bb6 100644 (file)
@@ -31,6 +31,7 @@ class ObjCDataFormatterCF(ObjCDataFormatterTestCase):
         # check formatters for common Objective-C types
         expect_strings = [
             '(CFGregorianUnits) cf_greg_units = 1 years, 3 months, 5 days, 12 hours, 5 minutes 7 seconds',
+            '(CFGregorianDate) cf_greg_date = @"4/11/1985 2:0:0"',
             '(CFRange) cf_range = location=4 length=4',
             '(NSPoint) ns_point = (x = 4, y = 4)',
             '(NSRange) ns_range = location=4, length=4',
@@ -43,17 +44,16 @@ class ObjCDataFormatterCF(ObjCDataFormatterTestCase):
             '(Rect) rect = (t=4, l=8, b=4, r=7)',
             '(Rect *) rect_ptr = (t=4, l=8, b=4, r=7)',
             '(Point) point = (v=7, h=12)', '(Point *) point_ptr = (v=7, h=12)',
-            '1985', 'foo_selector_impl'
+            '(SEL) foo_selector = "foo_selector_impl"'
         ]
 
-        if self.getArchitecture() in ['i386', 'x86_64']:
-            expect_strings.append('(HIPoint) hi_point = (x=7, y=12)')
-            expect_strings.append(
-                '(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)'
-            )
-            expect_strings.append(
-                '(RGBColor) rgb_color = red=3 green=56 blue=35')
-            expect_strings.append(
-                '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35')
-
         self.expect("frame variable", substrs=expect_strings)
+
+        if self.getArchitecture() in ['i386', 'x86_64']:
+            extra_string = [
+                '(RGBColor) rgb_color = red=3 green=56 blue=35',
+                '(RGBColor *) rgb_color_ptr = red=3 green=56 blue=35',
+                '(HIPoint) hi_point = (x=7, y=12)',
+                '(HIRect) hi_rect = origin=(x = 3, y = 5) size=(width = 4, height = 6)',
+            ]
+            self.expect("frame variable", substrs=extra_string)
index 2bd22ff..5217008 100644 (file)
@@ -23,14 +23,20 @@ class ObjCDataFormatterNSContainer(ObjCDataFormatterTestCase):
         self.expect(
             'frame variable newArray nsDictionary newDictionary nscfDictionary cfDictionaryRef newMutableDictionary cfarray_ref mutable_array_ref',
             substrs=[
-                '(NSArray *) newArray = ', '@"50 elements"',
-                '(NSDictionary *) newDictionary = ', ' 12 key/value pairs',
+                '(NSArray *) newArray = ',
+                ' @"50 elements"',
+                '(NSDictionary *) nsDictionary = ',
+                ' 2 key/value pairs',
+                '(NSDictionary *) newDictionary = ',
+                ' 12 key/value pairs',
+                '(CFDictionaryRef) cfDictionaryRef = ',
+                ' 3 key/value pairs',
                 '(NSDictionary *) newMutableDictionary = ',
-                ' 21 key/value pairs', '(NSDictionary *) nsDictionary = ',
-                ' 2 key/value pairs', '(CFDictionaryRef) cfDictionaryRef = ',
-                ' 3 key/value pairs', '(CFArrayRef) cfarray_ref = ',
-                '@"3 elements"', '(CFMutableArrayRef) mutable_array_ref = ',
-                '@"11 elements"'
+                ' 21 key/value pairs',
+                '(CFArrayRef) cfarray_ref = ',
+                ' @"3 elements"',
+                '(CFMutableArrayRef) mutable_array_ref = ',
+                ' @"11 elements"',
             ])
 
         self.expect(
index df380ae..2da1b51 100644 (file)
@@ -32,4 +32,4 @@ class ObjCDataFormatterNSError(ObjCDataFormatterTestCase):
 
         self.expect(
             'frame variable nserror->_userInfo --ptr-depth 1 -d run-target',
-            substrs=['@"a"', '@"b"', "1", "2"])
+            substrs=['@"a"', "1", '@"b"', "2"])
index d9da0c3..5cd6e45 100644 (file)
@@ -152,35 +152,27 @@ class LibcxxMapDataFormatterTestCase(TestBase):
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-        self.expect("frame variable si",
-                    substrs=['%s::map' % ns, 'size=4',
-                             '[0] = ',
-                             'first = \"zero\"',
-                             'second = 0',
-                             '[1] = ',
-                             'first = \"one\"',
-                             'second = 1',
-                             '[2] = ',
-                             'first = \"two\"',
-                             'second = 2',
-                             '[3] = ',
-                             'first = \"three\"',
-                             'second = 3'])
-
-        self.expect("p si",
-                    substrs=['%s::map' % ns, 'size=4',
-                             '[0] = ',
-                             'first = \"zero\"',
-                             'second = 0',
-                             '[1] = ',
-                             'first = \"one\"',
-                             'second = 1',
-                             '[2] = ',
-                             'first = \"two\"',
-                             'second = 2',
-                             '[3] = ',
-                             'first = \"three\"',
-                             'second = 3'])
+        self.expect(
+            "frame variable si",
+            substrs=[
+                '%s::map' % ns,
+                'size=4',
+                '[0] = (first = "one", second = 1)',
+                '[1] = (first = "three", second = 3)',
+                '[2] = (first = "two", second = 2)',
+                '[3] = (first = "zero", second = 0)',
+            ])
+
+        self.expect(
+            "p si",
+            substrs=[
+                '%s::map' % ns,
+                'size=4',
+                '[0] = (first = "one", second = 1)',
+                '[1] = (first = "three", second = 3)',
+                '[2] = (first = "two", second = 2)',
+                '[3] = (first = "zero", second = 0)',
+            ])
 
         # check that MightHaveChildren() gets it right
         self.assertTrue(
@@ -214,35 +206,27 @@ class LibcxxMapDataFormatterTestCase(TestBase):
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-        self.expect("frame variable is",
-                    substrs=['%s::map' % ns, 'size=4',
-                             '[0] = ',
-                             'second = \"goofy\"',
-                             'first = 85',
-                             '[1] = ',
-                             'second = \"is\"',
-                             'first = 1',
-                             '[2] = ',
-                             'second = \"smart\"',
-                             'first = 2',
-                             '[3] = ',
-                             'second = \"!!!\"',
-                             'first = 3'])
-
-        self.expect("p is",
-                    substrs=['%s::map' % ns, 'size=4',
-                             '[0] = ',
-                             'second = \"goofy\"',
-                             'first = 85',
-                             '[1] = ',
-                             'second = \"is\"',
-                             'first = 1',
-                             '[2] = ',
-                             'second = \"smart\"',
-                             'first = 2',
-                             '[3] = ',
-                             'second = \"!!!\"',
-                             'first = 3'])
+        self.expect(
+            "frame variable is",
+            substrs=[
+                '%s::map' % ns,
+                'size=4',
+                '[0] = (first = 1, second = "is")',
+                '[1] = (first = 2, second = "smart")',
+                '[2] = (first = 3, second = "!!!")',
+                '[3] = (first = 85, second = "goofy")',
+            ])
+
+        self.expect(
+            "p is",
+            substrs=[
+                '%s::map' % ns,
+                'size=4',
+                '[0] = (first = 1, second = "is")',
+                '[1] = (first = 2, second = "smart")',
+                '[2] = (first = 3, second = "!!!")',
+                '[3] = (first = 85, second = "goofy")',
+            ])
 
         # check that MightHaveChildren() gets it right
         self.assertTrue(
@@ -276,29 +260,25 @@ class LibcxxMapDataFormatterTestCase(TestBase):
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-        self.expect("frame variable ss",
-                    substrs=['%s::map' % ns, 'size=3',
-                             '[0] = ',
-                             'second = \"hello\"',
-                             'first = \"ciao\"',
-                             '[1] = ',
-                             'second = \"house\"',
-                             'first = \"casa\"',
-                             '[2] = ',
-                             'second = \"cat\"',
-                             'first = \"gatto\"'])
-
-        self.expect("p ss",
-                    substrs=['%s::map' % ns, 'size=3',
-                             '[0] = ',
-                             'second = \"hello\"',
-                             'first = \"ciao\"',
-                             '[1] = ',
-                             'second = \"house\"',
-                             'first = \"casa\"',
-                             '[2] = ',
-                             'second = \"cat\"',
-                             'first = \"gatto\"'])
+        self.expect(
+            "frame variable ss",
+            substrs=[
+                '%s::map' % ns,
+                'size=3',
+                '[0] = (first = "casa", second = "house")',
+                '[1] = (first = "ciao", second = "hello")',
+                '[2] = (first = "gatto", second = "cat")',
+            ])
+
+        self.expect(
+            "p ss",
+            substrs=[
+                '%s::map' % ns,
+                'size=3',
+                '[0] = (first = "casa", second = "house")',
+                '[1] = (first = "ciao", second = "hello")',
+                '[2] = (first = "gatto", second = "cat")',
+            ])
 
         # check that MightHaveChildren() gets it right
         self.assertTrue(
index 39adc04..022a46b 100644 (file)
@@ -58,14 +58,14 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-        self.expect('frame variable ii',
-                    substrs=[multimap, 'size=2',
-                             '[0] = ',
-                             'first = 0',
-                             'second = 0',
-                             '[1] = ',
-                             'first = 1',
-                             'second = 1'])
+        self.expect(
+            'frame variable ii',
+            substrs=[
+                multimap,
+                'size=2',
+                '[0] = (first = 0, second = 0)',
+                '[1] = (first = 1, second = 1)',
+            ])
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
@@ -139,35 +139,24 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-        self.expect("frame variable si",
-                    substrs=[multimap, 'size=4',
-                             '[0] = ',
-                             'first = \"zero\"',
-                             'second = 0',
-                             '[1] = ',
-                             'first = \"one\"',
-                             'second = 1',
-                             '[2] = ',
-                             'first = \"two\"',
-                             'second = 2',
-                             '[3] = ',
-                             'first = \"three\"',
-                             'second = 3'])
+        self.expect(
+            "frame variable si",
+            substrs=[
+                multimap,
+                'size=4',
+                '[0] = (first = "one", second = 1)',
+                '[1] = (first = "three", second = 3)',
+                '[2] = (first = "two", second = 2)',
+                '[3] = (first = "zero", second = 0)',
+            ])
 
         self.expect("p si",
                     substrs=[multimap, 'size=4',
-                             '[0] = ',
-                             'first = \"zero\"',
-                             'second = 0',
-                             '[1] = ',
-                             'first = \"one\"',
-                             'second = 1',
-                             '[2] = ',
-                             'first = \"two\"',
-                             'second = 2',
-                             '[3] = ',
-                             'first = \"three\"',
-                             'second = 3'])
+                '[0] = (first = "one", second = 1)',
+                '[1] = (first = "three", second = 3)',
+                '[2] = (first = "two", second = 2)',
+                '[3] = (first = "zero", second = 0)',
+            ])
 
         # check that MightHaveChildren() gets it right
         self.assertTrue(
@@ -201,35 +190,27 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-        self.expect("frame variable is",
-                    substrs=[multimap, 'size=4',
-                             '[0] = ',
-                             'second = \"goofy\"',
-                             'first = 85',
-                             '[1] = ',
-                             'second = \"is\"',
-                             'first = 1',
-                             '[2] = ',
-                             'second = \"smart\"',
-                             'first = 2',
-                             '[3] = ',
-                             'second = \"!!!\"',
-                             'first = 3'])
-
-        self.expect("p is",
-                    substrs=[multimap, 'size=4',
-                             '[0] = ',
-                             'second = \"goofy\"',
-                             'first = 85',
-                             '[1] = ',
-                             'second = \"is\"',
-                             'first = 1',
-                             '[2] = ',
-                             'second = \"smart\"',
-                             'first = 2',
-                             '[3] = ',
-                             'second = \"!!!\"',
-                             'first = 3'])
+        self.expect(
+            "frame variable is",
+            substrs=[
+                multimap,
+                'size=4',
+                '[0] = (first = 1, second = "is")',
+                '[1] = (first = 2, second = "smart")',
+                '[2] = (first = 3, second = "!!!")',
+                '[3] = (first = 85, second = "goofy")',
+            ])
+
+        self.expect(
+            "p is",
+            substrs=[
+                multimap,
+                'size=4',
+                '[0] = (first = 1, second = "is")',
+                '[1] = (first = 2, second = "smart")',
+                '[2] = (first = 3, second = "!!!")',
+                '[3] = (first = 85, second = "goofy")',
+            ])
 
         # check that MightHaveChildren() gets it right
         self.assertTrue(
@@ -263,29 +244,25 @@ class LibcxxMultiMapDataFormatterTestCase(TestBase):
 
         lldbutil.continue_to_breakpoint(self.process(), bkpt)
 
-        self.expect("frame variable ss",
-                    substrs=[multimap, 'size=3',
-                             '[0] = ',
-                             'second = \"hello\"',
-                             'first = \"ciao\"',
-                             '[1] = ',
-                             'second = \"house\"',
-                             'first = \"casa\"',
-                             '[2] = ',
-                             'second = \"cat\"',
-                             'first = \"gatto\"'])
-
-        self.expect("p ss",
-                    substrs=[multimap, 'size=3',
-                             '[0] = ',
-                             'second = \"hello\"',
-                             'first = \"ciao\"',
-                             '[1] = ',
-                             'second = \"house\"',
-                             'first = \"casa\"',
-                             '[2] = ',
-                             'second = \"cat\"',
-                             'first = \"gatto\"'])
+        self.expect(
+            "frame variable ss",
+            substrs=[
+                multimap,
+                'size=3',
+                '[0] = (first = "casa", second = "house")',
+                '[1] = (first = "ciao", second = "hello")',
+                '[2] = (first = "gatto", second = "cat")',
+            ])
+
+        self.expect(
+            "p ss",
+            substrs=[
+                multimap,
+                'size=3',
+                '[0] = (first = "casa", second = "house")',
+                '[1] = (first = "ciao", second = "hello")',
+                '[2] = (first = "gatto", second = "cat")',
+            ])
 
         # check that MightHaveChildren() gets it right
         self.assertTrue(
index 621b22a..021307e 100644 (file)
@@ -104,18 +104,20 @@ class LibcxxMultiSetDataFormatterTestCase(TestBase):
             "frame variable ss",
             substrs=[
                 "size=4",
+                '[0] = "a"',
+                '[1] = "a very long string is right here"',
                 '[2] = "b"',
                 '[3] = "c"',
-                '[0] = "a"',
-                '[1] = "a very long string is right here"'])
+            ])
         self.expect(
             "p ss",
             substrs=[
                 "size=4",
+                '[0] = "a"',
+                '[1] = "a very long string is right here"',
                 '[2] = "b"',
                 '[3] = "c"',
-                '[0] = "a"',
-                '[1] = "a very long string is right here"'])
+            ])
         self.expect("frame variable ss[2]", substrs=[' = "b"'])
         lldbutil.continue_to_breakpoint(process, bkpt)
         self.expect(