From d02fb002dd6b57e2ecbc3a4c3df91f5ed3a6054e Mon Sep 17 00:00:00 2001 From: Jonas Devlieghere Date: Fri, 31 Jan 2020 13:27:15 -0800 Subject: [PATCH] [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 --- lldb/packages/Python/lldbsuite/test/lldbtest.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index 602749c80fa..933a99d5e14 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -2341,8 +2341,11 @@ FileCheck output: # 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) -- 2.11.0