2020-06-09 04:57:46 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from pexpect_helper import SpawnedProc
|
|
|
|
|
|
|
|
sp = SpawnedProc()
|
|
|
|
send, sendline, sleep, expect_prompt, expect_re, expect_str = (
|
|
|
|
sp.send,
|
|
|
|
sp.sendline,
|
|
|
|
sp.sleep,
|
|
|
|
sp.expect_prompt,
|
|
|
|
sp.expect_re,
|
|
|
|
sp.expect_str,
|
|
|
|
)
|
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
# ensure the Apple key () is typeable
|
2024-05-07 23:54:03 +08:00
|
|
|
sendline("echo \xf8ff")
|
|
|
|
expect_prompt("\xf8ff")
|
2020-06-09 04:57:46 +08:00
|
|
|
|
|
|
|
# check that history is returned in the right order (#2028)
|
|
|
|
# first send 'echo stuff'
|
|
|
|
sendline("echo stuff")
|
|
|
|
expect_prompt("stuff")
|
|
|
|
|
|
|
|
# last history item should be 'echo stuff'
|
|
|
|
sendline("echo $history[1]")
|
|
|
|
expect_prompt("echo stuff")
|
|
|
|
|
|
|
|
# last history command should be the one that printed the history
|
|
|
|
sendline("echo $history[1]")
|
2024-05-07 23:54:30 +08:00
|
|
|
expect_prompt("echo \\$history\\[1\\]")
|
2020-06-09 04:57:46 +08:00
|
|
|
|
|
|
|
# Backslashes at end of comments (#1255)
|
|
|
|
# This backslash should NOT cause the line to continue
|
|
|
|
sendline("echo -n #comment\\")
|
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
# a pipe at the end of the line (#1285)
|
|
|
|
sendline("echo hoge |\n cat")
|
|
|
|
expect_prompt("hoge")
|
|
|
|
|
|
|
|
sendline("echo hoge | \n cat")
|
|
|
|
expect_prompt("hoge")
|
|
|
|
|
|
|
|
sendline("echo hoge 2>| \n cat")
|
|
|
|
expect_prompt("hoge")
|
|
|
|
sendline("echo hoge >| \n cat")
|
|
|
|
expect_prompt("hoge")
|
|
|
|
|
2021-01-02 04:15:09 +08:00
|
|
|
sendline("$fish --no-execute 2>&1")
|
|
|
|
expect_prompt("error: no-execute mode enabled and no script given. Exiting")
|
|
|
|
|
2020-06-09 04:57:46 +08:00
|
|
|
sendline("source; or echo failed")
|
|
|
|
expect_prompt("failed")
|
2021-01-04 00:41:38 +08:00
|
|
|
|
|
|
|
# See that `type` tells us the function was defined interactively.
|
|
|
|
sendline("function foo; end; type foo")
|
|
|
|
expect_str("foo is a function with definition\r\n")
|
|
|
|
expect_str("# Defined interactively\r\n")
|
|
|
|
expect_str("function foo")
|
|
|
|
expect_str("end")
|
|
|
|
expect_prompt()
|
2023-08-09 02:12:05 +08:00
|
|
|
|
|
|
|
# See that `functions` terminates
|
|
|
|
sendline("functions")
|
pexpects: Fix spurious failure in generic.py
This used expect_re with a regex ending in `.*`, followed by an
`expect_prompt`.
This meant that, depending on the timing, the regex could swallow the
prompt marker, which caused extremely confusing output like
>Testing file pexpects/generic.py:Failed to match pattern: prompt 14
> ...
> OUTPUT +1.33 ms (Line 70): \rprompt 13>functions\r\nN_, abbr,
> alias, bg, cd, [SNIP], up-or-search, vared, wait\r\n⏎
> \r⏎ \r\rprompt 14>
Yeah - it shows that "prompt 14" was in the output and it can't find
"prompt 14".
I could reproduce the failure locally when running the tests
repeatedly. I got one after 17 attempts and so far haven't been able
to reproduce it with this change applied.
2023-08-16 01:11:41 +08:00
|
|
|
expect_re(".*fish_prompt,")
|
2023-08-09 02:12:05 +08:00
|
|
|
expect_prompt()
|