[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
This commit is contained in:
Jonas Devlieghere 2020-01-31 13:27:15 -08:00
parent 1463341f4b
commit d02fb002dd
1 changed files with 4 additions and 1 deletions

View File

@ -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)