tests: ensure some more specific tests work

This commit is contained in:
Khaïs COLIN 2025-04-30 15:30:20 +02:00
parent 826abdf623
commit 58a27d712b

77
test.sh
View file

@ -1610,4 +1610,81 @@ expecting <<EOF
minishell: *.txt: ambiguous redirect minishell: *.txt: ambiguous redirect
EOF EOF
when_run <<EOF "writing to /dev/full"
echo hi > /dev/full
echo \$?
pwd > /dev/full
echo \$?
env > /dev/full
echo \$?
EOF
expecting <<EOF
minishell: echo: write error: No space left on device
1
minishell: pwd: write error: No space left on device
1
minishell: env: write error: No space left on device
125
EOF
when_run <<EOF "writing to /root"
echo hi > /root/minishell.tmp
echo \$?
pwd > /root/minishell.tmp
echo \$?
env > /root/minishell.tmp
echo \$?
EOF
expecting <<EOF
minishell: /root/minishell.tmp: Permission denied
1
minishell: /root/minishell.tmp: Permission denied
1
minishell: /root/minishell.tmp: Permission denied
1
EOF
when_run <<EOF "redirection: same file for input and output"
cat < hello.txt > hello.txt
echo \$?
EOF
expecting <<EOF
minishell: hello.txt: No such file or directory
1
EOF
when_run <<EOF "redirection: same file for output and input"
cat > hello.txt < hello.txt
echo \$?
ls
cat hello.txt
EOF
expecting <<EOF
0
hello.txt
EOF
when_run <<"EOF" "null expansions"
echo hi $NOOOOOOOOOOOOOOOOOOOOOOO hello
echo hi "" hello
echo hi "$NOOOOOOOOOOOOOOOOOOOOOOO" hello
echo hi a$NOOOOOOOOOOOOOOOOOOOOOOO hello
echo hi ""$NOOOOOOOOOOOOOOOOOOOOOOO hello
echo hi $NOOOOOOOOOOOOOOOOOOOOOOO"" hello
echo hi '' hello
echo hi ''$NOOOOOOOOOOOOOOOOOOOOOOO hello
echo hi $NOOOOOOOOOOOOOOOOOOOOOOO'' hello
EOF
expecting <<EOF
hi hello
hi hello
hi hello
hi a hello
hi hello
hi hello
hi hello
hi hello
hi hello
EOF
finalize finalize