fork/fish-shell
git clone https://git.julia.blue/fork/fish-shell
8add30e3b
master
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" ]: 10sys .exit (127 ) 11 12sp = SpawnedProc () 13send ,sendline ,sleep ,expect_prompt ,expect_re = ( 14sp .send , 15sp .sendline , 16sp .sleep , 17sp .expect_prompt , 18sp .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 30PID 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 46PID 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 ): 59proc = subprocess .run ( 60 ["pgrep" ,"-l" ,"-f" ,"sleep 11" ], 61stdout = subprocess .PIPE , 62stderr = subprocess .PIPE , 63 ) 64if proc .returncode != 0 : 65break 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. 67time .sleep (1 ) 68else : 69"Commands still running" ) 70proc .stdout ) 71sys .exit (1 )