File: stdin_nonblocking.py

package info (click to toggle)
fish 4.2.1-3.2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 35,976 kB
  • sloc: python: 6,972; javascript: 1,407; sh: 1,009; xml: 411; ansic: 230; objc: 78; makefile: 20
file content (42 lines) | stat: -rw-r--r-- 944 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# Verify that stdin is properly set to blocking even if a job tweaks it.
from pexpect_helper import SpawnedProc
import os

sp = SpawnedProc()
send, sendline, expect_prompt, expect_str, sleep = (
    sp.send,
    sp.sendline,
    sp.expect_prompt,
    sp.expect_str,
    sp.sleep,
)

if not os.environ.get("fish_test_helper", ""):
    import sys

    sys.exit(127)

# Launch fish_test_helper.
expect_prompt()
exe_path = os.environ.get("fish_test_helper")
sendline(exe_path + " stdin_make_nonblocking")

expect_str("stdin was blocking")
sleep(0.1)

send("\x1a")  # ctrl-Z
expect_prompt("has stopped")

# We don't "restore" non-blocking state when continuing a stopped job.
sleep(0.1)
sendline("fg")
expect_str("stdin was blocking")

# Kill the job and do it again.
send("\x03")  # ctrl-c
expect_prompt()
sendline(exe_path + " stdin_make_nonblocking")
expect_str("stdin was blocking")
send("\x03")  # ctrl-c
expect_prompt()