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: fish=%fish %fish %s
|
2020-01-24 01:34:46 +00:00
|
|
|
|
|
|
|
# Empty commands should be 123
|
|
|
|
set empty_var
|
|
|
|
$empty_var
|
|
|
|
echo $status
|
|
|
|
# CHECK: 123
|
|
|
|
# CHECKERR: {{.*}} The expanded command was empty.
|
|
|
|
# CHECKERR: $empty_var
|
2022-08-11 16:20:40 +00:00
|
|
|
# CHECKERR: ^~~~~~~~~^
|
2020-01-24 01:34:46 +00:00
|
|
|
|
|
|
|
# Failed expansions
|
|
|
|
echo "$abc["
|
|
|
|
echo $status
|
|
|
|
# CHECK: 121
|
|
|
|
# CHECKERR: {{.*}} Invalid index value
|
|
|
|
# CHECKERR: echo "$abc["
|
2022-08-11 17:24:41 +00:00
|
|
|
# CHECKERR: ^
|
2020-01-24 01:34:46 +00:00
|
|
|
|
|
|
|
# Failed wildcards
|
|
|
|
echo *gibberishgibberishgibberish*
|
|
|
|
echo $status
|
|
|
|
# CHECK: 124
|
|
|
|
# CHECKERR: {{.*}} No matches for wildcard '*gibberishgibberishgibberish*'. {{.*}}
|
|
|
|
# CHECKERR: echo *gibberishgibberishgibberish*
|
2022-08-11 15:22:03 +00:00
|
|
|
# CHECKERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~^
|
2023-03-14 09:50:22 +00:00
|
|
|
|
|
|
|
$fish -c 'exit -5'
|
2024-01-05 15:52:18 +00:00
|
|
|
# CHECKERR: warning: builtin exit returned invalid exit code -5
|
2023-03-14 09:50:22 +00:00
|
|
|
echo $status
|
|
|
|
# CHECK: 251
|
|
|
|
|
|
|
|
$fish -c 'exit -1'
|
2024-01-05 15:52:18 +00:00
|
|
|
# CHECKERR: warning: builtin exit returned invalid exit code -1
|
2023-03-14 09:50:22 +00:00
|
|
|
echo $status
|
|
|
|
# CHECK: 255
|
|
|
|
|
|
|
|
# (we avoid 0, so this is turned into 255 again)
|
|
|
|
$fish -c 'exit -256'
|
2024-01-05 15:52:18 +00:00
|
|
|
# CHECKERR: warning: builtin exit returned invalid exit code -256
|
2023-03-14 09:50:22 +00:00
|
|
|
echo $status
|
|
|
|
# CHECK: 255
|
|
|
|
|
|
|
|
$fish -c 'exit -512'
|
2024-01-05 15:52:18 +00:00
|
|
|
# CHECKERR: warning: builtin exit returned invalid exit code -512
|
2023-03-14 09:50:22 +00:00
|
|
|
echo $status
|
|
|
|
# CHECK: 255
|