mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-23 21:53:09 +08:00
60 lines
1.0 KiB
Python
60 lines
1.0 KiB
Python
|
#!/usr/bin/env python3
|
||
|
from pexpect_helper import SpawnedProc
|
||
|
import subprocess
|
||
|
import sys
|
||
|
import time
|
||
|
|
||
|
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()
|
||
|
|
||
|
sendline("test -t 0; echo $status")
|
||
|
expect_prompt("0")
|
||
|
|
||
|
sendline("""function t
|
||
|
test -t 0 && echo stdin
|
||
|
test -t 1 && echo stdout
|
||
|
test -t 2 && echo stderr
|
||
|
end""")
|
||
|
expect_prompt()
|
||
|
|
||
|
sendline("t")
|
||
|
expect_str("stdin")
|
||
|
expect_str("stdout")
|
||
|
expect_str("stderr")
|
||
|
expect_prompt()
|
||
|
|
||
|
sendline("cat </dev/null | t")
|
||
|
expect_str("stdout")
|
||
|
expect_str("stderr")
|
||
|
expect_prompt()
|
||
|
|
||
|
sendline("t | cat")
|
||
|
expect_str("stdin")
|
||
|
expect_str("stderr")
|
||
|
expect_prompt()
|
||
|
|
||
|
sendline("t 2>| cat")
|
||
|
expect_str("stdin")
|
||
|
expect_str("stdout")
|
||
|
expect_prompt()
|
||
|
|
||
|
sendline("cat </dev/null | t | cat")
|
||
|
expect_str("stderr")
|
||
|
expect_prompt()
|
||
|
sendline("cat </dev/null | t 2>| cat")
|
||
|
expect_str("stdout")
|
||
|
expect_prompt()
|
||
|
|
||
|
sendline("t </dev/null")
|
||
|
expect_str("stdout")
|
||
|
expect_str("stderr")
|
||
|
expect_prompt()
|