Skip to content

Commit

Permalink
make sure to FF beyond cat(1) command for \a
Browse files Browse the repository at this point in the history
Otherwise, \a can be falsley matched by PROMPT_COMMAND,
where it is often found in the xterm-set-title sequence!
  • Loading branch information
jquast committed Jul 20, 2014
1 parent bc2f43f commit 52b0f82
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,12 +427,18 @@ def test_at_max_icanon(self):
# given,
child = pexpect.spawn('bash', echo=False, timeout=2)
child.sendline('stty icanon imaxbel erase ^H')
child.sendline('cat')
child.sendline('echo BEGIN; cat')
send_bytes = self.max_input

# exercise,
child.send('_' * send_bytes)
child.sendline() # rings BEL

# fast forward beyond 'cat' command, as ^G can be found as part of
# set-xterm-title sequence of $PROMPT_COMMAND or $PS1.
child.expect_exact('BEGIN')

# verify, BEL is rung
child.expect_exact('\a')

# verify, no more additional BELs expected
Expand All @@ -458,16 +464,21 @@ def test_max_no_icanon(self):
# given,
child = pexpect.spawn('bash', echo=False, timeout=5)
child.sendline('stty -icanon imaxbel')
child.sendline('cat')
child.sendline('echo BEGIN; cat')
send_bytes = self.max_input + 11

# exercise,
child.send('_' * send_bytes)
child.sendline()

# fast forward beyond 'cat' command, as ^G can be found as part of
# set-xterm-title sequence of $PROMPT_COMMAND or $PS1.
child.expect_exact('BEGIN')

# BEL is *not* found,
with self.assertRaises(pexpect.TIMEOUT):
child.expect_exact('\a', timeout=1)
print(child.buffer)

# verify cat(1) also received all input,
child.expect_exact('_' * send_bytes)
Expand Down

0 comments on commit 52b0f82

Please sign in to comment.