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-05 17:41:56 +00:00
|
|
|
time sleep 0
|
2019-12-20 15:53:09 +00:00
|
|
|
|
|
|
|
# These are a tad awkward because it picks the correct unit and adapts whitespace.
|
|
|
|
# The idea is that it's a table.
|
2022-02-21 21:43:36 +00:00
|
|
|
#CHECKERR: ________________________________________________________
|
|
|
|
#CHECKERR: Executed in {{[\d,.\s]*}} {{millis|micros|secs}} {{\s*}}fish {{\s*}}external
|
|
|
|
#CHECKERR: usr time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}}
|
|
|
|
#CHECKERR: sys time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}}
|
2019-12-20 15:53:09 +00:00
|
|
|
time for i in (seq 1 2)
|
|
|
|
echo banana
|
|
|
|
end
|
|
|
|
|
|
|
|
#CHECK: banana
|
|
|
|
#CHECK: banana
|
2022-02-21 21:43:36 +00:00
|
|
|
#CHECKERR: ________________________________________________________
|
|
|
|
#CHECKERR: Executed in {{[\d,.\s]*}} {{millis|micros|secs}} {{\s*}}fish {{\s*}}external
|
|
|
|
#CHECKERR: usr time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}}
|
|
|
|
#CHECKERR: sys time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}}
|
2019-12-20 15:53:09 +00:00
|
|
|
|
|
|
|
# Make sure we're not double-parsing
|
|
|
|
time echo 'foo -s bar'
|
|
|
|
#CHECK: foo -s bar
|
2022-02-21 21:43:36 +00:00
|
|
|
#CHECKERR: ________________________________________________________
|
|
|
|
#CHECKERR: Executed in {{[\d,.\s]*}} {{millis|micros|secs}} {{\s*}}fish {{\s*}}external
|
|
|
|
#CHECKERR: usr time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}}
|
|
|
|
#CHECKERR: sys time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}}
|
2019-12-21 10:45:07 +00:00
|
|
|
|
|
|
|
true && time a=b not builtin true | true
|
2022-02-21 21:43:36 +00:00
|
|
|
#CHECKERR: ___{{.*}}
|
2019-12-21 10:45:07 +00:00
|
|
|
#CHECKERR: {{.*}}
|
|
|
|
#CHECKERR: {{.*}}
|
|
|
|
#CHECKERR: {{.*}}
|
|
|
|
|
|
|
|
not time true
|
2022-02-21 21:43:36 +00:00
|
|
|
#CHECKERR: ___{{.*}}
|
2019-12-21 10:45:07 +00:00
|
|
|
#CHECKERR: {{.*}}
|
|
|
|
#CHECKERR: {{.*}}
|
|
|
|
#CHECKERR: {{.*}}
|
2019-12-23 10:45:55 +00:00
|
|
|
|
2024-11-21 10:02:34 +00:00
|
|
|
not time a=b true
|
|
|
|
#CHECKERR: ___{{.*}}
|
|
|
|
#CHECKERR: {{.*}}
|
|
|
|
#CHECKERR: {{.*}}
|
|
|
|
#CHECKERR: {{.*}}
|
|
|
|
|
|
|
|
# Currently illegal syntax. Same in zsh. POSIX shells call the external command "time" here.
|
|
|
|
a=b time true
|
|
|
|
#CHECKERR: fish: time: missing man page
|
|
|
|
#CHECKERR: Documentation may not be installed.
|
|
|
|
#CHECKERR: `help time` will show an online version
|
|
|
|
not a=b time true
|
|
|
|
#CHECKERR: fish: time: missing man page
|
|
|
|
#CHECKERR: Documentation may not be installed.
|
|
|
|
#CHECKERR: `help time` will show an online version
|
|
|
|
|
2019-12-23 10:45:55 +00:00
|
|
|
$fish -c 'time true&'
|
|
|
|
#CHECKERR: fish: {{.*}}
|
|
|
|
#CHECKERR: time true&
|
2022-08-11 15:22:03 +00:00
|
|
|
#CHECKERR: ^~~~~~~~~^
|
2019-12-23 10:45:55 +00:00
|
|
|
|
|
|
|
$fish -c 'not time true&'
|
|
|
|
#CHECKERR: fish: {{.*}}
|
|
|
|
#CHECKERR: not time true&
|
2022-08-11 16:20:40 +00:00
|
|
|
#FIXME: This error marks the entire statement. Would be cool to mark just `time true&`.
|
|
|
|
#CHECKERR: ^~~~~~~~~~~~~^
|
2023-08-25 17:34:24 +00:00
|
|
|
|
|
|
|
$fish -c 'echo Is it time yet | time cat'
|
|
|
|
#CHECKERR: fish: The 'time' command may only be at the beginning of a pipeline
|
|
|
|
#CHECKERR: echo Is it time yet | time cat
|
|
|
|
#CHECKERR: ^~~~~~~^
|
|
|
|
|
|
|
|
begin
|
|
|
|
printf '%s\n' "#!/bin/sh" 'echo No this is Patrick' > time
|
|
|
|
chmod +x time
|
|
|
|
set -l PATH .
|
|
|
|
echo Hello is this time | command time
|
|
|
|
# CHECK: No this is Patrick
|
|
|
|
end
|
|
|
|
rm time
|