Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,13 @@ def continue_to_exception_breakpoint(self, filter_label):
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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Test the 'memory region' command.
"""


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
Expand Down Expand Up @@ -62,7 +61,7 @@ def test_command(self):
# 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',
)
Expand All @@ -81,7 +80,7 @@ def test_command(self):
# 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.
Expand All @@ -94,7 +93,7 @@ def test_command(self):
# 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\)",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Test how lldb reacts to wrong commands
"""


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
Expand All @@ -18,11 +17,9 @@ def test_ambiguous_command(self):

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
always enables.
"""


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
Expand Down Expand Up @@ -83,7 +82,7 @@ def test_tagged_memory_find(self):
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]+"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
non address bits from addresses before lookup.
"""


import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
Expand Down Expand Up @@ -57,7 +56,7 @@ def test_mte_regions(self):
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
Expand Down
18 changes: 11 additions & 7 deletions lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

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"
],
Expand Down Expand Up @@ -78,9 +78,11 @@ def run_test_evaluate_expressions(
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.*"
Expand Down Expand Up @@ -127,9 +129,11 @@ def run_test_evaluate_expressions(
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")
Expand Down
2 changes: 1 addition & 1 deletion lldb/test/API/tools/lldb-server/TestGdbRemoteLaunch.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_launch_failure_via_vRun(self):
)
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.)",
)
Expand Down
10 changes: 5 additions & 5 deletions lldb/test/API/tools/lldb-server/TestGdbRemoteModuleInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def test_module_info(self):

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]+"')