fish-shell/tests/pexpects/generic.py
Fabian Homborg e6cdd315d1 tests/generic: Check for a literal match
I *think* this might sometimes (on CI) be eating the prompt, so that the actual `prompt`
part of `expect_prompt` doesn't find anything.

On Github Actions we see things like:

```
Testing file pexpects/generic.py ... Failed to match pattern: prompt 5
generic.py:35: timeout from expect_prompt("echo .history.*")

[...]

OUTPUT      +1.08 ms (Line 31): \rprompt 4>
 INPUT      +0.35 ms (Line 34): echo $history[1]\n
OUTPUT      +1.58 ms (Line 35): echo $history[1]\r\necho $history[1]\r\n⏎                                                                              \r⏎ \r\rprompt 5>
```

so the prompt *is* printed, it's just not correctly matched.
2020-11-13 15:20:37 +01:00

56 lines
1.2 KiB
Python

#!/usr/bin/env python3
from pexpect_helper import SpawnedProc
import subprocess
import sys
from time import sleep
import os
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
sendline("echo ")
expect_prompt("")
# 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]")
expect_prompt("echo \$history\[1\]")
# 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")
sendline("source; or echo failed")
expect_prompt("failed")