fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Fabian Boehmpexpects: Disable exit on CI Darwin/FreeBSD8add30e3b

master
1.7 KiB71 linesraw
1#!/usr/bin/env python3
2from pexpect_helper import SpawnedProc
3import os
4import subprocess
5import sys
6import time
7import platform
8
9if "CI" in os.environ and platform.system() in ["Darwin", "FreeBSD"]:
10    sys.exit(127)
11
12sp = SpawnedProc()
13send, sendline, sleep, expect_prompt, expect_re = (
14    sp.send,
15    sp.sendline,
16    sp.sleep,
17    sp.expect_prompt,
18    sp.expect_re,
19)
20expect_prompt()
21
22# Verify that if we attempt to exit with a job in the background we get warned
23# about that job and are told to type `exit` a second time.
24send("sleep 111 &\r")
25expect_prompt()
26send("exit\r")
27expect_re(
28    """There are still jobs active:\r
29\r
30   PID  Command\r
31 *\\d+  sleep 111 &\r
32\r
33A second attempt to exit will terminate them.\r
34Use 'disown PID' to remove jobs from the list without terminating them.\r"""
35)
36expect_prompt()
37
38# Running anything other than `exit` should result in the same warning with
39# the shell still running.
40send("sleep 113 &\r")
41expect_prompt()
42send("exit\r")
43expect_re(
44    """There are still jobs active:\r
45\r
46   PID  Command\r
47 *\\d+  sleep 113 &\r
48 *\\d+  sleep 111 &\r
49\r
50A second attempt to exit will terminate them.\r
51Use 'disown PID' to remove jobs from the list without terminating them.\r"""
52)
53expect_prompt()
54
55# Verify that asking to exit a second time does so.
56send("exit\r")
57
58for t in range(0, 3):
59    proc = subprocess.run(
60        ["pgrep", "-l", "-f", "sleep 11"],
61        stdout=subprocess.PIPE,
62        stderr=subprocess.PIPE,
63    )
64    if proc.returncode != 0:
65        break
66    # This is cheesy, but on Travis with thread-sanitizer this can be slow enough that the process is still running, so we sleep for a bit.
67    time.sleep(1)
68else:
69    print("Commands still running")
70    print(proc.stdout)
71    sys.exit(1)