[Lldb-commits] [PATCH] D76080: Adjust error_msg handling for expect_expr in lldbtest.py

Jim Ingham via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Mar 12 11:23:41 PDT 2020


jingham added a comment.

The result from EvaluateExpression is pretty much always going to be valid, since the result holds the error.  The correct way to do the first check is:

self.assertTrue(eval_result.GetError().Fail(), "Unexpected success...")

though you probably also want to make sure "eval_result.IsValid()" too, just to be on the safe side.  It's good to check that first, especially if you are going to do a find rather than a strict compare.  I don't think there's any guarantee that you have to leave the string in an Error empty if you return `False` from SBError().Fail().

I'm on the fence about using a "find" not a strict string compare.  The only reason you'd be passing in an error_msg is that you want to test that you got the error string you were expecting.  I worry that using substrings will lead to weakening this test by having too general a match.  OTOH, it would be super annoying to match all of some of the compiler's error messages...


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

https://reviews.llvm.org/D76080





More information about the lldb-commits mailing list