mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-12 04:58:57 +00:00
e66f6878b5
This is somewhat subtle: The #RUN line in a littlecheck file will be run by a posix shell, which means the substitutions will also be mangled by it. Now, we *have* shell-quoted them, but unfortunately what we need is to quote them for inside a pre-existing layer of quotes, e.g. # RUN: fish -C 'set -g fish %fish' here, %fish can't be replaced with `'path with spaces/fish'`, because that ends up as # RUN: fish -C 'set -g fish 'path with spaces/fish'' which is just broken. So instead, we pass it as a variable to that fish: # RUN: fish=%fish fish... In addition, we need to not mangle the arguments in our test_driver. For that, because we insist on posix shell, which has only one array, and we source a file, we *need* to stop having that file use arguments. Which is okay - test_env.sh could previously be used to start a test, and now it no longer can because that is test_*driver*.sh's job. For the interactive tests, it's slightly different: pexpect.spawn(foo) is sensitive to shell metacharacters like space. So we shell-quote it. But if you pass any args to pexpect.spawn, it no longer uses a shell, and so we cannot shell-quote it. There could be a better way to fix this?
76 lines
1.7 KiB
Fish
76 lines
1.7 KiB
Fish
# RUN: env fish_test_helper=%fish_test_helper fish=%fish %fish %s
|
|
#REQUIRES: command -v %fish_test_helper
|
|
|
|
$fish -c 'function main; exit 4; true; end; main'
|
|
echo $status
|
|
#CHECK: 4
|
|
|
|
$fish -c 'begin; exit 5; true; end'
|
|
echo $status
|
|
#CHECK: 5
|
|
|
|
$fish -c 'kill -SIGHUP $fish_pid'
|
|
echo $status
|
|
#CHECK: 129
|
|
|
|
$fish -c 'function main; kill -SIGTERM $fish_pid; true; end; main'
|
|
echo $status
|
|
#CHECK: 143
|
|
|
|
function alarm --on-signal ALRM
|
|
echo ALRM received
|
|
end
|
|
|
|
kill -s ALRM $fish_pid
|
|
# CHECK: ALRM received
|
|
|
|
function anychild --on-process-exit 0
|
|
# Type and exit status
|
|
echo $argv[1] $argv[3]
|
|
end
|
|
|
|
function anyjob --on-job-exit 0
|
|
# Type and exit status
|
|
echo $argv[1] $argv[3]
|
|
end
|
|
|
|
echo "command false:"
|
|
command false
|
|
# CHECK: command false:
|
|
# (Solaris' false exits with 255, not 1)
|
|
# CHECK: PROCESS_EXIT {{1|255}}
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
echo "command true:"
|
|
command true
|
|
# CHECK: command true:
|
|
# CHECK: PROCESS_EXIT 0
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
echo "command false | true:"
|
|
command false | command true
|
|
# CHECK: command false | true:
|
|
# CHECK: PROCESS_EXIT {{1|255}}
|
|
# CHECK: PROCESS_EXIT 0
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
# Signals are reported correctly.
|
|
# SIGKILL $status is 128 + 9 = 137
|
|
$fish_test_helper sigkill_self
|
|
# CHECK: PROCESS_EXIT 137
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
function test_blocks
|
|
block -l
|
|
command echo "This is the process whose exit event should be blocked"
|
|
echo "This should come before the event handler"
|
|
end
|
|
test_blocks
|
|
# CHECK: This is the process whose exit event should be blocked
|
|
# CHECK: This should come before the event handler
|
|
|
|
echo "Now event handler should have run"
|
|
# CHECK: PROCESS_EXIT 0
|
|
# CHECK: JOB_EXIT 0
|
|
# CHECK: Now event handler should have run
|
|
# CHECK: PROCESS_EXIT 0
|