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()
|
|
|
|
|
2021-07-12 16:45:46 +00:00
|
|
|
timeout = 0.15
|
2021-07-12 16:54:40 +00:00
|
|
|
|
2021-07-12 16:45:46 +00:00
|
|
|
if "CI" in os.environ:
|
2021-12-29 05:35:30 +00:00
|
|
|
# This doesn't work under TSan, because TSan prevents select() being
|
|
|
|
# interrupted by a signal.
|
2021-07-12 16:54:40 +00:00
|
|
|
import sys
|
2022-06-16 16:43:28 +00:00
|
|
|
|
2021-07-12 16:54:40 +00:00
|
|
|
print("SKIPPING cancel_event.py")
|
|
|
|
sys.exit(0)
|
2021-07-12 16:45:46 +00:00
|
|
|
|
2020-10-07 00:49:07 +00:00
|
|
|
# Verify that cancel-commandline does what we expect - see #7384.
|
|
|
|
send("not executed")
|
2021-07-12 16:45:46 +00:00
|
|
|
sleep(timeout)
|
2020-10-07 00:49:07 +00:00
|
|
|
os.kill(sp.spawn.pid, signal.SIGINT)
|
2023-12-28 13:41:30 +00:00
|
|
|
sendline("echo marker")
|
|
|
|
sp.expect_str("marker")
|
|
|
|
expect_prompt()
|
2020-10-07 00:49:07 +00:00
|
|
|
|
|
|
|
sendline("function cancelhandler --on-event fish_cancel ; echo yay cancelled ; end")
|
|
|
|
expect_prompt()
|
|
|
|
send("still not executed")
|
2021-07-12 16:45:46 +00:00
|
|
|
sleep(timeout)
|
2020-10-07 00:49:07 +00:00
|
|
|
os.kill(sp.spawn.pid, signal.SIGINT)
|
2023-12-28 13:41:30 +00:00
|
|
|
expect_str("yay cancelled")
|
|
|
|
sendline("echo marker")
|
|
|
|
sp.expect_str("marker")
|
|
|
|
expect_prompt()
|