[lldb] Replace assertTrue(a == b, "msg") with assertEquals(a, b, "msg") in the test suite
Summary:
The error message from the construct `assertTrue(a == b, "msg") ` are nearly always completely useless for actually debugging the issue.
This patch is just replacing this construct (and similar ones like `assertTrue(a != b, ...)` with the proper call to assertEqual or assertNotEquals.
This patch was mostly written by a shell script with some manual verification afterwards:
```
lang=python
import sys
def sanitize_line(line):
if line.strip().startswith("self.assertTrue(") and " == " in line:
line = line.replace("self.assertTrue(", "self.assertEquals(")
line = line.replace(" == ", ", ", 1)
if line.strip().startswith("self.assertTrue(") and " != " in line:
line = line.replace("self.assertTrue(", "self.assertNotEqual(")
line = line.replace(" != ", ", ", 1)
return line
for a in sys.argv[1:]:
with open(a, "r") as f:
lines = f.readlines()
with open(a, "w") as f:
for line in lines:
f.write(sanitize_line(line))
```
Reviewers: labath, JDevlieghere
Reviewed By: labath
Subscribers: abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D74475
This commit is contained in:
@@ -63,7 +63,7 @@ class SBValuePersistTestCase(TestBase):
|
||||
self.assertTrue(
|
||||
barPersist.GetPointeeData().sint32[0] == 4,
|
||||
"barPersist != 4")
|
||||
self.assertTrue(bazPersist.GetSummary() == '"85"', "bazPersist != 85")
|
||||
self.assertEquals(bazPersist.GetSummary(), '"85"', "bazPersist != 85")
|
||||
|
||||
self.runCmd("continue")
|
||||
|
||||
@@ -77,6 +77,6 @@ class SBValuePersistTestCase(TestBase):
|
||||
self.assertTrue(
|
||||
barPersist.GetPointeeData().sint32[0] == 4,
|
||||
"barPersist != 4")
|
||||
self.assertTrue(bazPersist.GetSummary() == '"85"', "bazPersist != 85")
|
||||
self.assertEquals(bazPersist.GetSummary(), '"85"', "bazPersist != 85")
|
||||
|
||||
self.expect("expr *(%s)" % (barPersist.GetName()), substrs=['= 4'])
|
||||
|
||||
Reference in New Issue
Block a user