diff options
| author | Raphael Isemann <teemperor@gmail.com> | 2020-02-13 13:40:22 +0100 |
|---|---|---|
| committer | Raphael Isemann <teemperor@gmail.com> | 2020-02-13 15:00:55 +0100 |
| commit | b3a0c4d7dcfa252be17ef5f5b63ffaaa83e01a2b (patch) | |
| tree | f532c1b428f232a9b45c7e210269c072dd70474e /lldb/test/API/python_api/value | |
| parent | 70e6ed1db709584c6f0ca5f2c7904c74c962dec7 (diff) | |
| download | llvm-b3a0c4d7dcfa252be17ef5f5b63ffaaa83e01a2b.zip llvm-b3a0c4d7dcfa252be17ef5f5b63ffaaa83e01a2b.tar.gz llvm-b3a0c4d7dcfa252be17ef5f5b63ffaaa83e01a2b.tar.bz2 | |
[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
Diffstat (limited to 'lldb/test/API/python_api/value')
| -rw-r--r-- | lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py | 16 | ||||
| -rw-r--r-- | lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py index 6f0dee2..b7977f1 100644 --- a/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py +++ b/lldb/test/API/python_api/value/change_values/TestChangeValueAPI.py @@ -60,7 +60,7 @@ class ChangeValueAPITestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Get Frame #0. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEquals(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -76,7 +76,7 @@ class ChangeValueAPITestCase(TestBase): self.assertTrue(val_value.IsValid(), "Got the SBValue for val") actual_value = val_value.GetValueAsSigned(error, 0) self.assertTrue(error.Success(), "Got a value from val") - self.assertTrue(actual_value == 100, "Got the right value from val") + self.assertEquals(actual_value, 100, "Got the right value from val") result = val_value.SetValueFromCString("12345") self.assertTrue(result, "Setting val returned True.") @@ -99,7 +99,7 @@ class ChangeValueAPITestCase(TestBase): self.assertTrue( error.Success(), "Got an unsigned value for second_val") - self.assertTrue(actual_value == 5555) + self.assertEquals(actual_value, 5555) result = mine_second_value.SetValueFromCString("98765") self.assertTrue(result, "Success setting mine.second_value.") @@ -107,7 +107,7 @@ class ChangeValueAPITestCase(TestBase): self.assertTrue( error.Success(), "Got a changed value from mine.second_val") - self.assertTrue(actual_value == 98765, + self.assertEquals(actual_value, 98765, "Got the right changed value from mine.second_val") # Next do the same thing with the pointer version. @@ -120,7 +120,7 @@ class ChangeValueAPITestCase(TestBase): self.assertTrue( error.Success(), "Got an unsigned value for ptr->second_val") - self.assertTrue(actual_value == 6666) + self.assertEquals(actual_value, 6666) result = ptr_second_value.SetValueFromCString("98765") self.assertTrue(result, "Success setting ptr->second_value.") @@ -128,7 +128,7 @@ class ChangeValueAPITestCase(TestBase): self.assertTrue( error.Success(), "Got a changed value from ptr->second_val") - self.assertTrue(actual_value == 98765, + self.assertEquals(actual_value, 98765, "Got the right changed value from ptr->second_val") # gcc may set multiple locations for breakpoint @@ -138,7 +138,7 @@ class ChangeValueAPITestCase(TestBase): # values as well... process.Continue() - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEquals(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( @@ -171,7 +171,7 @@ class ChangeValueAPITestCase(TestBase): process.Continue() - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEquals(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( diff --git a/lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py b/lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py index c7197e5..c778577 100644 --- a/lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py +++ b/lldb/test/API/python_api/value/empty_class/TestValueAPIEmptyClass.py @@ -28,7 +28,7 @@ class ValueAPIEmptyClassTestCase(TestBase): self.assertTrue(process, PROCESS_IS_VALID) # Get Frame #0. - self.assertTrue(process.GetState() == lldb.eStateStopped) + self.assertEquals(process.GetState(), lldb.eStateStopped) thread = lldbutil.get_stopped_thread( process, lldb.eStopReasonBreakpoint) self.assertTrue( |
