osmo_interact*: allow comments without prompt
Change-Id: I5fb8efba9e13a5b9e22b44ffc3d708f8a76241ec
This commit is contained in:
parent
be7fcf5f28
commit
33233d15bb
|
@ -44,6 +44,7 @@ class Interact:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.result = []
|
self.result = []
|
||||||
|
self.leading_blanks = []
|
||||||
|
|
||||||
def verify_interact_state(self, interact_instance):
|
def verify_interact_state(self, interact_instance):
|
||||||
# for example to verify that the last VTY prompt received shows the
|
# for example to verify that the last VTY prompt received shows the
|
||||||
|
@ -131,24 +132,26 @@ class Interact:
|
||||||
steps = []
|
steps = []
|
||||||
step = None
|
step = None
|
||||||
blank_lines = 0
|
blank_lines = 0
|
||||||
|
leading_blanks = []
|
||||||
for line in transcript.splitlines():
|
for line in transcript.splitlines():
|
||||||
if not line:
|
if not line or line.strip().startswith('#'):
|
||||||
blank_lines += 1
|
leading_blanks.append(line);
|
||||||
continue
|
continue
|
||||||
|
|
||||||
next_step_started = self.Step.is_next_step(line, self)
|
next_step_started = self.Step.is_next_step(line, self)
|
||||||
if next_step_started:
|
if next_step_started:
|
||||||
if step:
|
if step:
|
||||||
steps.append(step)
|
steps.append(step)
|
||||||
step = next_step_started
|
step = next_step_started
|
||||||
step.leading_blanks = blank_lines
|
step.leading_blanks = leading_blanks
|
||||||
blank_lines = 0
|
leading_blanks = []
|
||||||
elif step:
|
elif step:
|
||||||
# we only count blank lines directly preceding the start of a
|
# we only count blank lines directly preceding the start of a
|
||||||
# next step. Insert blank lines in the middle of a response
|
# next step. Insert blank lines in the middle of a response
|
||||||
# back into the response:
|
# back into the response:
|
||||||
if blank_lines:
|
if leading_blanks:
|
||||||
step.result.extend([''] * blank_lines)
|
step.result.extend(leading_blanks)
|
||||||
blank_lines = 0
|
leading_blanks = []
|
||||||
step.result.append(line)
|
step.result.append(line)
|
||||||
if step:
|
if step:
|
||||||
steps.append(step)
|
steps.append(step)
|
||||||
|
@ -163,7 +166,7 @@ class Interact:
|
||||||
try:
|
try:
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
if step.leading_blanks:
|
if step.leading_blanks:
|
||||||
print('\n' * step.leading_blanks, end='')
|
print('\n'.join(step.leading_blanks), end='')
|
||||||
print(step.command_str())
|
print(step.command_str())
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
@ -182,7 +185,7 @@ class Interact:
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
if step.leading_blanks:
|
if step.leading_blanks:
|
||||||
actual_result.extend([''] * step.leading_blanks)
|
actual_result.extend(step.leading_blanks)
|
||||||
actual_result.append(step.command_str(self))
|
actual_result.append(step.command_str(self))
|
||||||
|
|
||||||
match_result = self.match_lines(step.result, res)
|
match_result = self.match_lines(step.result, res)
|
||||||
|
|
Loading…
Reference in New Issue