[Lldb-commits] [lldb] d02fb00 - [lldb/Test] Make substrs argument to self.expect ordered.
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Jan 31 13:36:43 PST 2020
Author: Jonas Devlieghere
Date: 2020-01-31T13:35:37-08:00
New Revision: d02fb002dd6b57e2ecbc3a4c3df91f5ed3a6054e
URL: https://github.com/llvm/llvm-project/commit/d02fb002dd6b57e2ecbc3a4c3df91f5ed3a6054e
DIFF: https://github.com/llvm/llvm-project/commit/d02fb002dd6b57e2ecbc3a4c3df91f5ed3a6054e.diff
LOG: [lldb/Test] Make substrs argument to self.expect ordered.
This patch changes the behavior of the substrs argument to self.expect.
Currently, the elements of substrs are unordered and as long as the
string appears in the output, the assertion passes.
We can be more precise by requiring that the substrings be ordered in
the way they appear. My hope is that this will make it harder to
accidentally pass a check because a string appears out of order.
Differential revision: https://reviews.llvm.org/D73766
Added:
Modified:
lldb/packages/Python/lldbsuite/test/lldbtest.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 602749c80fa8..933a99d5e142 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -2341,8 +2341,11 @@ def expect(
# Look for sub strings, if specified.
keepgoing = matched if matching else not matched
if substrs and keepgoing:
+ start = 0
for substr in substrs:
- matched = output.find(substr) != -1
+ index = output[start:].find(substr)
+ start = start + index if matching else 0
+ matched = index != -1
with recording(self, trace) as sbuf:
print("%s sub string: %s" % (heading, substr), file=sbuf)
print("Matched" if matched else "Not matched", file=sbuf)
More information about the lldb-commits
mailing list