[lldb] Replace assertRegexpMatches with assertRegex (NFC) (#82074)

assertRegexpMatches is a deprecated alias for assertRegex and has been
removed in Python 3.12. This wasn't an issue previously because we used
a vendored version of the unittest module. Now that we use the built-in
version this gets updated together with the Python version used to run
the test suite.
This commit is contained in:
Jonas Devlieghere 2024-02-16 21:45:08 -08:00 committed by GitHub
parent 0bf4f82f66
commit 737bc9f76a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 28 additions and 30 deletions

View File

@ -249,13 +249,13 @@ class DAPTestCaseBase(TestBase):
def continue_to_exit(self, exitCode=0):
self.dap_server.request_continue()
stopped_events = self.dap_server.wait_for_stopped()
self.assertEquals(
self.assertEqual(
len(stopped_events), 1, "stopped_events = {}".format(stopped_events)
)
self.assertEquals(
self.assertEqual(
stopped_events[0]["event"], "exited", "make sure program ran to completion"
)
self.assertEquals(
self.assertEqual(
stopped_events[0]["body"]["exitCode"],
exitCode,
"exitCode == %i" % (exitCode),

View File

@ -2,7 +2,6 @@
Test the 'memory region' command.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@ -62,7 +61,7 @@ class MemoryCommandRegion(TestBase):
# We allow --all or an address argument, not both
interp.HandleCommand("memory region --all 0", result)
self.assertFalse(result.Succeeded())
self.assertRegexpMatches(
self.assertRegex(
result.GetError(),
'The "--all" option cannot be used when an address argument is given',
)
@ -81,7 +80,7 @@ class MemoryCommandRegion(TestBase):
# Now let's print the memory region starting at 0 which should always work.
interp.HandleCommand("memory region 0x0", result)
self.assertTrue(result.Succeeded())
self.assertRegexpMatches(result.GetOutput(), "\\[0x0+-")
self.assertRegex(result.GetOutput(), "\\[0x0+-")
all_regions += result.GetOutput()
# Keep printing memory regions until we printed all of them.
@ -94,7 +93,7 @@ class MemoryCommandRegion(TestBase):
# Now that we reached the end, 'memory region' should again print the usage.
interp.HandleCommand("memory region", result)
self.assertFalse(result.Succeeded())
self.assertRegexpMatches(
self.assertRegex(
result.GetError(),
"Usage: memory region <address\-expression> \(or \-\-all\)",
)

View File

@ -2,7 +2,6 @@
Test how lldb reacts to wrong commands
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@ -18,11 +17,9 @@ class UnknownCommandTestCase(TestBase):
command_interpreter.HandleCommand("g", result)
self.assertFalse(result.Succeeded())
self.assertRegexpMatches(
result.GetError(), "Ambiguous command 'g'. Possible matches:"
)
self.assertRegexpMatches(result.GetError(), "gui")
self.assertRegexpMatches(result.GetError(), "gdb-remote")
self.assertRegex(result.GetError(), "Ambiguous command 'g'. Possible matches:")
self.assertRegex(result.GetError(), "gui")
self.assertRegex(result.GetError(), "gdb-remote")
self.assertEqual(1, result.GetError().count("gdb-remote"))
@no_debug_info_test

View File

@ -6,7 +6,6 @@ These tests use the top byte ignore feature of AArch64. Which Linux
always enables.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@ -83,7 +82,7 @@ class AArch64LinuxTaggedMemoryReadTestCase(TestBase):
out = self.res.GetOutput()
# memory find does not fail when it doesn't find the data.
# First check we actually got something.
self.assertRegexpMatches(out, "data found at location: 0x[0-9A-Fa-f]+")
self.assertRegex(out, "data found at location: 0x[0-9A-Fa-f]+")
# Then that the location found does not display the tag bits.
self.assertNotRegexpMatches(
out, "data found at location: 0x(34|56)[0-9A-Fa-f]+"

View File

@ -3,7 +3,6 @@ Test that "memory region" lookup uses the ABI plugin to remove
non address bits from addresses before lookup.
"""
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
@ -57,7 +56,7 @@ class AArch64LinuxTaggedMemoryRegionTestCase(TestBase):
if result.Succeeded():
repeats += 1
else:
self.assertRegexpMatches(result.GetError(), "Usage: memory region")
self.assertRegex(result.GetError(), "Usage: memory region")
break
# This time repeat until we get the last region. At that

View File

@ -13,7 +13,7 @@ from lldbsuite.test.lldbtest import *
class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
def assertEvaluate(self, expression, regex):
self.assertRegexpMatches(
self.assertRegex(
self.dap_server.request_evaluate(expression, context=self.context)["body"][
"result"
],
@ -78,9 +78,11 @@ class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
else:
self.assertEvaluate(
"struct1",
re.escape("{foo:15}")
if enableAutoVariableSummaries
else "my_struct @ 0x",
(
re.escape("{foo:15}")
if enableAutoVariableSummaries
else "my_struct @ 0x"
),
)
self.assertEvaluate(
"struct2", "0x.* {foo:16}" if enableAutoVariableSummaries else "0x.*"
@ -127,9 +129,11 @@ class TestDAP_evaluate(lldbdap_testcase.DAPTestCaseBase):
else:
self.assertEvaluate(
"struct1",
re.escape("{foo:15}")
if enableAutoVariableSummaries
else "my_struct @ 0x",
(
re.escape("{foo:15}")
if enableAutoVariableSummaries
else "my_struct @ 0x"
),
)
self.assertEvaluate("struct1.foo", "15")
self.assertEvaluate("struct2->foo", "16")

View File

@ -101,7 +101,7 @@ class GdbRemoteLaunchTestCase(gdbremote_testcase.GdbRemoteTestCaseBase):
)
with open(exe_path, "ab") as exe_for_writing:
context = self.expect_gdbremote_sequence()
self.assertRegexpMatches(
self.assertRegex(
seven.unhexlify(context.get("msg")),
r"(execve failed: Text file busy|The process cannot access the file because it is being used by another process.)",
)

View File

@ -41,8 +41,8 @@ class TestGdbRemoteModuleInfo(gdbremote_testcase.GdbRemoteTestCaseBase):
context = self.expect_gdbremote_sequence()
spec = context.get("spec")
self.assertRegexpMatches(spec, '"file_path":".*"')
self.assertRegexpMatches(spec, '"file_offset":\d+')
self.assertRegexpMatches(spec, '"file_size":\d+')
self.assertRegexpMatches(spec, '"triple":"\w*-\w*-.*"')
self.assertRegexpMatches(spec, '"uuid":"[A-Fa-f0-9]+"')
self.assertRegex(spec, '"file_path":".*"')
self.assertRegex(spec, '"file_offset":\d+')
self.assertRegex(spec, '"file_size":\d+')
self.assertRegex(spec, '"triple":"\w*-\w*-.*"')
self.assertRegex(spec, '"uuid":"[A-Fa-f0-9]+"')