mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-20 01:42:56 +08:00
tests/noshebang: Do redirections in a new shell process
This is an attempt to solve the test failures on Launchpad's CI. I'm assuming when we do a redirection like foo > file and then try to execute `file` immediately afterwards, we either haven't written it soon enough or closed the file, so we get a "text file busy" error. So, when we do that in a new fish the file should be closed once it quits. See #8021.
This commit is contained in:
parent
eed2173860
commit
8a86d3452f
|
@ -1,11 +1,11 @@
|
|||
# RUN: %fish %s
|
||||
# RUN: %fish -C'set -g fish (builtin realpath %fish)' %s
|
||||
|
||||
# Test for shebangless scripts - see 7802.
|
||||
|
||||
set testdir (mktemp -d)
|
||||
cd $testdir
|
||||
|
||||
touch file
|
||||
$fish -c 'true > file'
|
||||
chmod a+x file
|
||||
|
||||
function runfile
|
||||
|
@ -23,21 +23,21 @@ function runfile
|
|||
end
|
||||
|
||||
# Empty executable files are 'true'.
|
||||
true >file
|
||||
sleep 0.1
|
||||
runfile
|
||||
#CHECK: 0
|
||||
#CHECK: 0
|
||||
|
||||
# Files without NUL are 'true' as well.
|
||||
echo -e -n '#COMMENT\n#COMMENT' >file
|
||||
# NOTE: We redirect in a new process because the file must be *closed*
|
||||
# before it can be run. On some systems that doesn't happen quickly enough.
|
||||
$fish -c "echo -e -n '#COMMENT\n#COMMENT' >file"
|
||||
sleep 0.1
|
||||
runfile
|
||||
#CHECK: 0
|
||||
#CHECK: 0
|
||||
|
||||
# Never implicitly pass files ending with .fish to /bin/sh.
|
||||
true >file.fish
|
||||
sleep 0.1
|
||||
touch file.fish
|
||||
chmod a+x file.fish
|
||||
set -g fish_use_posix_spawn 0
|
||||
./file.fish
|
||||
|
@ -59,14 +59,14 @@ rm file.fish
|
|||
|
||||
# On to NUL bytes.
|
||||
# The heuristic is that there must be a line containing a lowercase letter before the first NUL byte.
|
||||
echo -n -e 'true\n\x00' >file
|
||||
$fish -c "echo -n -e 'true\n\x00' >file"
|
||||
sleep 0.1
|
||||
runfile
|
||||
#CHECK: 0
|
||||
#CHECK: 0
|
||||
|
||||
# Doesn't meet our heuristic as there is no newline.
|
||||
echo -n -e 'true\x00' >file
|
||||
$fish -c "echo -n -e 'true\x00' >file"
|
||||
sleep 0.1
|
||||
runfile
|
||||
#CHECK: 126
|
||||
|
@ -80,7 +80,7 @@ runfile
|
|||
#CHECKERR: {{.*}}
|
||||
|
||||
# Doesn't meet our heuristic as there is no lowercase before newline.
|
||||
echo -n -e 'NOPE\n\x00' >file
|
||||
$fish -c "echo -n -e 'NOPE\n\x00' >file"
|
||||
sleep 0.1
|
||||
runfile
|
||||
#CHECK: 126
|
||||
|
|
Loading…
Reference in New Issue
Block a user