2020-10-07 00:49:07 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
import os
|
|
|
|
from pexpect_helper import SpawnedProc
|
|
|
|
import signal
|
|
|
|
|
|
|
|
sp = SpawnedProc()
|
2020-11-22 13:39:48 +00:00
|
|
|
send, sendline, sleep, expect_str, expect_prompt = (
|
|
|
|
sp.send,
|
|
|
|
sp.sendline,
|
|
|
|
sp.sleep,
|
|
|
|
sp.expect_str,
|
|
|
|
sp.expect_prompt,
|
|
|
|
)
|
2020-10-07 00:49:07 +00:00
|
|
|
expect_prompt()
|
|
|
|
|
|
|
|
# Verify that cancel-commandline does what we expect - see #7384.
|
|
|
|
send("not executed")
|
2021-07-12 16:12:35 +00:00
|
|
|
sleep(0.15)
|
2020-10-07 00:49:07 +00:00
|
|
|
os.kill(sp.spawn.pid, signal.SIGINT)
|
|
|
|
sp.expect_str("not executed^C")
|
|
|
|
expect_prompt(increment=False)
|
|
|
|
|
|
|
|
sendline("function cancelhandler --on-event fish_cancel ; echo yay cancelled ; end")
|
|
|
|
expect_prompt()
|
|
|
|
send("still not executed")
|
2021-07-12 16:12:35 +00:00
|
|
|
sleep(0.15)
|
2020-10-07 00:49:07 +00:00
|
|
|
os.kill(sp.spawn.pid, signal.SIGINT)
|
|
|
|
expect_str("still not executed^C")
|
|
|
|
expect_prompt("yay cancelled", increment=False)
|