mirror of
https://github.com/fish-shell/fish-shell
synced 2024-11-10 23:24:39 +00:00
Add a test for trap
Preparation to implement trapping in non-interactive mode.
This commit is contained in:
parent
f5b1063a8b
commit
5917ae8baf
1 changed files with 51 additions and 0 deletions
51
tests/checks/trap.fish
Normal file
51
tests/checks/trap.fish
Normal file
|
@ -0,0 +1,51 @@
|
|||
# RUN: %fish %s
|
||||
|
||||
set -g SIGUSR1_COUNT 0
|
||||
|
||||
function gotsigusr1
|
||||
set -g SIGUSR1_COUNT (math $SIGUSR1_COUNT + 1)
|
||||
echo "Got USR1: $SIGUSR1_COUNT"
|
||||
|
||||
end
|
||||
|
||||
function handle1 --on-signal SIGUSR1
|
||||
gotsigusr1
|
||||
end
|
||||
|
||||
function handle_us42 --on-signal SIGUSR2
|
||||
end
|
||||
|
||||
kill -USR1 $fish_pid
|
||||
sleep .1
|
||||
#CHECK: Got USR1: 1
|
||||
|
||||
kill -USR1 $fish_pid
|
||||
sleep .1
|
||||
#CHECK: Got USR1: 2
|
||||
|
||||
kill -USR2 $fish_pid
|
||||
sleep .1
|
||||
kill -USR2 $fish_pid
|
||||
sleep .1
|
||||
|
||||
# Previous signals do not re-trigger handlers.
|
||||
functions --erase handle1
|
||||
kill -USR1 $fish_pid
|
||||
sleep .1
|
||||
kill -USR1 $fish_pid
|
||||
sleep .1
|
||||
|
||||
kill -USR2 $fish_pid
|
||||
sleep .1
|
||||
|
||||
# Send the signal and immediately define the function; it should not excute.
|
||||
kill -USR1 $fish_pid
|
||||
function handle1 --on-signal SIGUSR1
|
||||
gotsigusr1
|
||||
end
|
||||
echo "Hope it did not run"
|
||||
#CHECK: Hope it did not run
|
||||
|
||||
kill -USR1 $fish_pid
|
||||
sleep .1
|
||||
#CHECK: Got USR1: 3
|
Loading…
Reference in a new issue