Make tests usable with path with spaces
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?
2024-12-27 19:54:43 +00:00
|
|
|
# RUN: env fish_test_helper=%fish_test_helper fish=%fish %fish %s
|
2024-12-26 12:30:09 +00:00
|
|
|
#REQUIRES: command -v %fish_test_helper
|
2019-12-23 12:49:40 +00:00
|
|
|
|
2020-01-13 19:34:22 +00:00
|
|
|
$fish -c 'function main; exit 4; true; end; main'
|
|
|
|
echo $status
|
2019-12-23 12:49:40 +00:00
|
|
|
#CHECK: 4
|
|
|
|
|
2020-01-13 19:34:22 +00:00
|
|
|
$fish -c 'begin; exit 5; true; end'
|
|
|
|
echo $status
|
2019-12-23 12:49:40 +00:00
|
|
|
#CHECK: 5
|
|
|
|
|
2020-05-16 09:20:18 +00:00
|
|
|
$fish -c 'kill -SIGHUP $fish_pid'
|
2020-01-13 19:34:22 +00:00
|
|
|
echo $status
|
2019-12-23 12:49:40 +00:00
|
|
|
#CHECK: 129
|
|
|
|
|
2020-05-16 09:20:18 +00:00
|
|
|
$fish -c 'function main; kill -SIGTERM $fish_pid; true; end; main'
|
2020-01-13 19:34:22 +00:00
|
|
|
echo $status
|
2019-12-23 12:49:40 +00:00
|
|
|
#CHECK: 143
|
2019-06-26 18:07:46 +00:00
|
|
|
|
2019-02-21 01:07:29 +00:00
|
|
|
function alarm --on-signal ALRM
|
2020-01-13 19:34:22 +00:00
|
|
|
echo ALRM received
|
2019-02-21 01:07:29 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
kill -s ALRM $fish_pid
|
2019-06-26 18:07:46 +00:00
|
|
|
# CHECK: ALRM received
|
2019-02-21 01:07:29 +00:00
|
|
|
|
2019-02-23 20:41:01 +00:00
|
|
|
function anychild --on-process-exit 0
|
2021-05-19 18:29:03 +00:00
|
|
|
# Type and exit status
|
|
|
|
echo $argv[1] $argv[3]
|
|
|
|
end
|
|
|
|
|
|
|
|
function anyjob --on-job-exit 0
|
2020-01-13 19:34:22 +00:00
|
|
|
# Type and exit status
|
|
|
|
echo $argv[1] $argv[3]
|
2019-02-23 20:41:01 +00:00
|
|
|
end
|
|
|
|
|
2019-02-21 05:41:35 +00:00
|
|
|
echo "command false:"
|
2019-02-23 20:41:01 +00:00
|
|
|
command false
|
2019-06-26 18:07:46 +00:00
|
|
|
# CHECK: command false:
|
2021-06-24 16:14:45 +00:00
|
|
|
# (Solaris' false exits with 255, not 1)
|
|
|
|
# CHECK: PROCESS_EXIT {{1|255}}
|
2019-06-26 18:07:46 +00:00
|
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
|
2019-02-21 05:41:35 +00:00
|
|
|
echo "command true:"
|
2019-02-23 20:41:01 +00:00
|
|
|
command true
|
2019-06-26 18:07:46 +00:00
|
|
|
# CHECK: command true:
|
|
|
|
# CHECK: PROCESS_EXIT 0
|
|
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
|
2019-02-21 05:41:35 +00:00
|
|
|
echo "command false | true:"
|
2019-02-23 20:41:01 +00:00
|
|
|
command false | command true
|
2019-06-26 18:07:46 +00:00
|
|
|
# CHECK: command false | true:
|
2021-06-24 16:14:45 +00:00
|
|
|
# CHECK: PROCESS_EXIT {{1|255}}
|
2019-06-26 18:07:46 +00:00
|
|
|
# CHECK: PROCESS_EXIT 0
|
|
|
|
# CHECK: JOB_EXIT 0
|
2019-02-21 05:41:35 +00:00
|
|
|
|
2021-05-17 21:34:52 +00:00
|
|
|
# Signals are reported correctly.
|
|
|
|
# SIGKILL $status is 128 + 9 = 137
|
|
|
|
$fish_test_helper sigkill_self
|
|
|
|
# CHECK: PROCESS_EXIT 137
|
|
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
|
2019-02-21 05:41:35 +00:00
|
|
|
function test_blocks
|
2020-01-13 19:34:22 +00:00
|
|
|
block -l
|
2021-05-17 21:34:52 +00:00
|
|
|
command echo "This is the process whose exit event should be blocked"
|
2020-01-13 19:34:22 +00:00
|
|
|
echo "This should come before the event handler"
|
2019-02-21 05:41:35 +00:00
|
|
|
end
|
|
|
|
test_blocks
|
2021-05-17 21:34:52 +00:00
|
|
|
# CHECK: This is the process whose exit event should be blocked
|
2019-06-26 18:07:46 +00:00
|
|
|
# CHECK: This should come before the event handler
|
|
|
|
|
2019-02-21 05:41:35 +00:00
|
|
|
echo "Now event handler should have run"
|
2019-06-26 18:07:46 +00:00
|
|
|
# CHECK: PROCESS_EXIT 0
|
|
|
|
# CHECK: JOB_EXIT 0
|
|
|
|
# CHECK: Now event handler should have run
|
|
|
|
# CHECK: PROCESS_EXIT 0
|