[Lldb-commits] [PATCH] D74475: [lldb] Replace assertTrue(a == b, "msg") with assertEquals(a, b, "msg") in the test suite

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 12 03:46:56 PST 2020


labath accepted this revision.
labath added a comment.
This revision is now accepted and ready to land.

I think this is a good idea. I have glanced over the patch, and I have found a couple of places where your script gets things wrong. They all involve doing boolean expressions in the assertion, which takes on a different meaning when you replace the comparison operator  with a comma.



================
Comment at: lldb/test/API/functionalities/process_group/TestChangeProcessGroup.py:70
         value = thread.GetSelectedFrame().EvaluateExpression("release_child_flag = 1")
-        self.assertTrue(value.IsValid() and value.GetValueAsUnsigned(0) == 1)
+        self.assertEquals(value.IsValid() and value.GetValueAsUnsigned(0), 1)
         process.Continue()
----------------
This is not right. It should probably be two asserts.


================
Comment at: lldb/test/API/macosx/thread-names/TestInterruptThreadNames.py:39
 
-        self.assertTrue(inferior_set_up.IsValid() and inferior_set_up.GetValueAsSigned() == 1, "Check that the program was able to create its threads within the allotted time")
+        self.assertEquals(inferior_set_up.IsValid() and inferior_set_up.GetValueAsSigned(), 1, "Check that the program was able to create its threads within the allotted time")
 
----------------
same here


================
Comment at: lldb/test/API/tools/lldb-vscode/launch/TestVSCode_launch.py:147
         output = self.get_stdout()
-        self.assertTrue(output is None or len(output) == 0,
+        self.assertEquals(output is None or len(output), 0,
                         "expect no program output")
----------------
An equivalent expression would be `if output: assertEquals(len(output), 0)`, though I'm not sure why we'd need both checks tbh -- we should have a consistent way of reporting "no output"...


Repository:
  rLLDB LLDB

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74475/new/

https://reviews.llvm.org/D74475





More information about the lldb-commits mailing list