diff --git a/tests/checks/fds.fish b/tests/checks/fds.fish index c3b606a2c..c2a60bb1f 100644 --- a/tests/checks/fds.fish +++ b/tests/checks/fds.fish @@ -23,6 +23,9 @@ $helper print_fds &2 +# CHECK: 0 1 2 5 + # This attempts to trip a case where the file opened in fish # has the same fd as the redirection. In this case, the dup2 # does not clear the CLO_EXEC bit. diff --git a/tests/checks/redirect.fish b/tests/checks/redirect.fish index bd0956299..8c62783fe 100644 --- a/tests/checks/redirect.fish +++ b/tests/checks/redirect.fish @@ -48,17 +48,20 @@ echo -n 2>$tmpdir/file.txt test -f $tmpdir/file.txt && echo "File exists" || echo "File does not exist" #CHECK: File exists -function foo +rm $tmpdir/file.txt + +function redir_to_argv1 if set -q argv[1] - foo >$argv[1] + redir_to_argv1 >$argv[1] end echo foo end -foo $tmpdir/bar +redir_to_argv1 $tmpdir/bar # CHECK: foo cat $tmpdir/bar # CHECK: foo +rm $tmpdir/bar # Verify that we can turn stderr into stdout and then pipe it # Note that the order here has historically been unspecified - 'errput' could conceivably appear before 'output'. @@ -68,7 +71,8 @@ begin end 2>&1 | sort | tee $tmpdir/tee_test.txt cat $tmpdir/tee_test.txt -rm -Rf $tmpdir +rm $tmpdir/tee_test.txt +rmdir $tmpdir #CHECK: errput #CHECK: output @@ -101,7 +105,14 @@ echo $status read abc <&- #CHECKERR: read: stdin is closed +# This one should output nothing. +echo derp >&- +# Redirection to 0, 1, 2 should always work. We don't test 0 since writing to stdin is weird and unpredictable. +echo hooray1 >&1 +echo hooray2 >&2 +#CHECK: hooray1 +#CHECKERR: hooray2 # "Verify that pipes don't conflict with fd redirections" # This code is very similar to eval. We go over a bunch of fads