diff --git a/tests/exit.expect b/tests/exit.expect deleted file mode 100644 index 165798793..000000000 --- a/tests/exit.expect +++ /dev/null @@ -1,48 +0,0 @@ -# vim: set filetype=expect: -# -# Test handling of the `exit` command. -set pid [spawn $fish] -expect_prompt - -# Verify that if we attempt to exit with a job in the background we get warned -# about that job and are told to type `exit` a second time. -send "sleep 111 &\r" -expect_prompt -send "exit\r" -expect -re "There are still jobs active:\r -\r - PID Command\r - *\\d+ sleep 111 &\r -\r -A second attempt to exit will terminate them.\r -Use 'disown PID' to remove jobs from the list without terminating them.\r" -expect_prompt - -# Running anything other than `exit` should result in the same warning with -# the shell still running. -send "sleep 113 &\r" -expect_prompt -send "exit\r" -expect -re "There are still jobs active:\r -\r - PID Command\r - *\\d+ sleep 113 &\r - *\\d+ sleep 111 &\r -\r -A second attempt to exit will terminate them.\r -Use 'disown PID' to remove jobs from the list without terminating them.\r" -expect_prompt - -# Verify that asking to exit a second time does so. -send "exit\r" -catch {expect default exp_continue} output -wait - -# Verify all child processes have been killed. We don't use `-p $fish_pid` because -# if the shell has a bug the child processes might have been reparented to pid -# 1 rather than killed. -set status [catch {exec pgrep -l -f "sleep 11"} output] -if {$status == 0} { - puts stderr "Commands spawned by the shell still running after `exit`" - puts stderr $output -} diff --git a/tests/exit.expect.err b/tests/exit.expect.err deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/exit.expect.out b/tests/exit.expect.out deleted file mode 100644 index e69de29bb..000000000 diff --git a/tests/pexpects/exit.py b/tests/pexpects/exit.py new file mode 100644 index 000000000..9d4f996fe --- /dev/null +++ b/tests/pexpects/exit.py @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +from pexpect_helper import SpawnedProc +import subprocess +import sys + +sp = SpawnedProc() +send, sendline, sleep, expect_prompt, expect_re = sp.send, sp.sendline, sp.sleep, sp.expect_prompt, sp.expect_re +expect_prompt() + +# Verify that if we attempt to exit with a job in the background we get warned +# about that job and are told to type `exit` a second time. +send("sleep 111 &\r") +expect_prompt() +send("exit\r") +expect_re("""There are still jobs active:\r +\r + PID Command\r + *\\d+ sleep 111 &\r +\r +A second attempt to exit will terminate them.\r +Use 'disown PID' to remove jobs from the list without terminating them.\r""") +expect_prompt() + +# Running anything other than `exit` should result in the same warning with +# the shell still running. +send("sleep 113 &\r") +expect_prompt() +send("exit\r") +expect_re("""There are still jobs active:\r +\r + PID Command\r + *\\d+ sleep 113 &\r + *\\d+ sleep 111 &\r +\r +A second attempt to exit will terminate them.\r +Use 'disown PID' to remove jobs from the list without terminating them.\r""") +expect_prompt() + +# Verify that asking to exit a second time does so. +send("exit\r") + +proc = subprocess.run(["pgrep", "-l", "-f", "sleep 11"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) +if proc.returncode == 0: + print("Commands still running") + print(proc.stdout) + sys.exit(1)