mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 21:03:12 +00:00
9907a8df4d
The psub tests create a fifo and launch a background job to write to it. However fifos have this obnoxious behavior where opening the file blocks until both sides are ready. In one of the tests we don't actually read from the fifo we create, so the background job hangs, and the tests never complete. Fix this by just reading from the fifo.
53 lines
1.4 KiB
Fish
53 lines
1.4 KiB
Fish
# Test psub behavior
|
|
set -l filename (echo foo | psub --testing)
|
|
test -f $filename
|
|
or echo 'psub is not a regular file' >&2
|
|
rm $filename
|
|
|
|
set -l filename (echo foo | psub --testing --file)
|
|
test -f $filename
|
|
or echo 'psub is not a regular file' >&2
|
|
rm $filename
|
|
|
|
set -l filename (echo foo | psub --testing --fifo)
|
|
test -p $filename
|
|
or echo 'psub is not a fifo' >&2
|
|
# hack: the background write that psub peforms may block
|
|
# until someone opens the fifo for reading. So make sure we
|
|
# actually read it.
|
|
cat $filename > /dev/null
|
|
rm $filename
|
|
|
|
cat (echo foo | psub)
|
|
cat (echo bar | psub --fifo)
|
|
cat (echo baz | psub)
|
|
|
|
set -l filename (echo foo | psub)
|
|
if test -e $filename
|
|
echo 'psub file was not deleted'
|
|
else
|
|
echo 'psub file was deleted'
|
|
end
|
|
|
|
# The --file flag is the default behavior.
|
|
if count (echo foo | psub -s .cc | grep -o '\.cc$') >/dev/null
|
|
echo 'psub filename ends with .cc'
|
|
else
|
|
echo 'psub filename does not end with .cc'
|
|
end
|
|
|
|
# Make sure we get the same result if we explicitly ask for a temp file.
|
|
if count (echo foo | psub -f -s .cc | grep -o '\.cc$') >/dev/null
|
|
echo 'psub filename ends with .cc'
|
|
else
|
|
echo 'psub filename does not end with .cc'
|
|
end
|
|
|
|
set -l filename (echo foo | psub -s .fish)
|
|
if test -e (dirname $filename)
|
|
echo 'psub directory was not deleted'
|
|
else
|
|
echo 'psub directory was deleted'
|
|
end
|
|
|
|
diff -q (__fish_print_help psub | psub) (psub -hs banana | psub)
|