Skip to content

Commit

Permalink
test: avoid interrupting magic mark output
Browse files Browse the repository at this point in the history
The same race condition as 85275cf exists for multiple completions
(case 0).  If the magic mark is not included in `expect()`, it may or
may not have been written by bash at the point `bash.sendintr()` is
called.   If the interrupt is delivered before magic mark has finished
printing, it can corrupt the prompt and cause `bash.expect_exact(PS1)`
to timeout.

Include `MAGIC_MARK` in the case 0 regex to avoid this issue.

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
  • Loading branch information
kevinoid authored and scop committed Mar 8, 2019
1 parent 2515f72 commit 1ea87c9
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/t/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,12 @@ def assert_complete(
bash.expect_exact(cmd)
bash.send(MAGIC_MARK)
got = bash.expect([
r"\r\n" + re.escape(PS1 + cmd), # 0: multiple lines, result in .before
r"^" + MAGIC_MARK, # 1: no completion
r"^([^\r]+)%s$" % MAGIC_MARK, # 2: on same line, result in .match
# 0: multiple lines, result in .before
r"\r\n" + re.escape(PS1 + cmd) + ".*" + MAGIC_MARK,
# 1: no completion
r"^" + MAGIC_MARK,
# 2: on same line, result in .match
r"^([^\r]+)%s$" % MAGIC_MARK,
pexpect.EOF,
pexpect.TIMEOUT,
])
Expand Down

0 comments on commit 1ea87c9

Please sign in to comment.