1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-23 06:23:09 +00:00

check-needles: tweak the handling of send_key_until_needlematch

The previous way of doing this isn't really safe. It assumes we
will find at least one string literal on any line containing
send_key_until_needlematch, and strips the last one, on the basis
it must be the key to press. But if the key to press is an
unquoted variable, this will strip the tag instead. And if both
the key to press and the tag are unquoted variables, this will
strip the most recent string literal we put into the global list
from some *other* line!

So instead let's try to be a bit smarter about how we parse
send_key_until_needlematch lines - just stripping out everything
after the first comma after "send_key_until_needlematch" - and
drop the dangerous "pop the last item from the list" logic. This
way we should always only find the needle to match, if it's a
string literal, as for other directives. We should never reach
the key to press so we don't need to worry about taking it out.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
Adam Williamson 2024-05-28 09:26:15 -07:00
parent 833204e060
commit d3833d376c

View File

@ -84,13 +84,16 @@ for testpath in testpaths:
start = line.find(matchfunc) start = line.find(matchfunc)
# fortunately `find` returns -1 for 'no match' # fortunately `find` returns -1 for 'no match'
if start > -1: if start > -1:
for match in DOUBLEQUOTERE.finditer(line[start:]): matcharea = line[start:]
testtags.append(match[1])
for match in SINGLEQUOTERE.finditer(line[start:]):
testtags.append(match[1])
if matchfunc == "send_key_until_needlematch": if matchfunc == "send_key_until_needlematch":
# strip last match because it'll be the key to hit # this needs some special handling - we need
testtags.pop() # to leave out the key to press, which should
# come after the first comma
matcharea = matcharea.split(",")[0]
for match in DOUBLEQUOTERE.finditer(matcharea):
testtags.append(match[1])
for match in SINGLEQUOTERE.finditer(matcharea):
testtags.append(match[1])
# filter the list a bit for matches that aren't tags. Almost all our # filter the list a bit for matches that aren't tags. Almost all our
# tags have a - or an _ in them, except a small number of weirdos; # tags have a - or an _ in them, except a small number of weirdos;