[Lldb-commits] [PATCH] D86792: [lldb] Improve test failure reporting for expect()

Pavel Labath via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 2 08:24:10 PDT 2020


labath added a comment.

Awesome.

In D86792#2252243 <https://reviews.llvm.org/D86792#2252243>, @DavidSpickett wrote:

> Combined two functions into one single run command
> and check message function.
>
> With some odd kwargs, but I think it helps to be able
> to put the expected lines on the end.

I think that's ok. Another option might be to take the expect argument as a dictionary instead of `**kwargs`. Something like:

      def assert_expect_fails_with(self, cmd, expect_args, failure_substrs):
          try:
              # This expect should fail
              self.expect(cmd, **expect_args)
          except AssertionError as e:
              # Then check message from previous expect
              self.expect(str(e), exe=False, substrs=failure_substrs)
  
  ...
  assert_expect_fails_with("foo", dict(endstr="foo"), "...")



================
Comment at: lldb/test/API/assert_messages_test/TestAssertMessages.py:82
+            patterns=["[0-9]+", "[a-f]+", "a|b|c"], exe=False,
+            failure_substrs=[dedent("""\
+                Checking string:
----------------
I'd consider moving the `dedent` and the listification (`[]`) operations into the `assert_expect_fails_with` function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86792



More information about the lldb-commits mailing list