new test platform

This commit is contained in:
whaffman 2025-03-06 15:58:17 +01:00
parent 05a6474b8c
commit 581c0404f0
8 changed files with 180 additions and 156 deletions

View File

@ -1,17 +1,36 @@
#!/bin/bash
minishell_output=$(../minishell -c "$1")
compare_shells() {
minishell_output=$(../minishell -c "$1" 2>&1)
minishell_exit_code=$?
bash_output=$(bash -c "$1")
bash_output=$(bash -c "$1" 2>&1 | sed 's/ line 1://g')
bash_exit_code=$?
paste <(echo -e "Minishell:\n$minishell_output") <(echo -e "Bash:\n$bash_output") | column -t -s $'\t'
echo -e "\e[33m$1\e[0m"
echo "==================================="
if [ "$minishell_output" != "$bash_output" ]; then
paste <(echo -e "Minishell:\n$minishell_output" | cat -e) <(echo -e "Bash:\n$bash_output" | cat -e) | column -t -s $'\t'
else
echo -e "\e[32mstdout: Ok!\e[0m"
fi
if [ $minishell_exit_code -ne $bash_exit_code ]; then
echo "Minishell exit code: $minishell_exit_code"
echo "Bash exit code: $bash_exit_code"
if [ $minishell_exit_code -eq $bash_exit_code ]; then
echo "Exit codes match."
else
echo "Exit codes do not match."
else
echo -e "\e[32mexit code: Ok!\e[0m"
fi
}
if [ -z "$1" ]; then
echo "Usage: $0 <file>"
exit 1
fi
while IFS= read -r line; do
compare_shells "$line"
done < "$1"

View File

@ -1,85 +1,6 @@
cd
cd ..
cd .
cd /Users
cd //
cd '//'
cd //////
cd ./././
cd /
cd '/etc'
cd '/var'
cd "$PWD/prompt"
cd "doesntexist"
cd "doesntexist" 2>/dev/null
cd ../../..
cd ..
cd ..
cd ?
cd +
cd _
cd bark bark
cd '/'
cd $PWD/file_tests
cd $OLDPWD/builtins
echo
echo echo
eCho
eChO
eCHO
echo $
echo $ $
ECHO
echo rhobebou
echo stop barking
echo "bonjour"
echo bonjour
echo 'bonjour'
echo -n bonjour
echo -nn bonjour
echo -n -n -n bonjour
echo "-n" bonjour
echo -n"-n" bonjour
echo "-nnnn" bonjour
echo "-nnnn" -n bonjour
echo "-n -n -n"-n bonjour
echo "-n '-n'" bonjour
echo $USER
echo "$USER"
echo "'$USER'"
echo " '$USER' "
echo text"$USER"
echo text"'$USER'" ' $USER '
echo "text" "$USER" "$USER"
echo ' $USER '
echo text "$USER" "$USER"text
echo ''''''''''$USER''''''''''
echo """"""""$USER""""""""
echo $USER'$USER'text oui oui oui oui $USER oui $USER ''
echo $USER '' $USER $USER '' $USER '' $USER -n $USER
echo ' \' ' \'
echo '\" ' " \"\""
echo \\\" \\\" \\\" \\\"\\\"\\\" \\\'\\\'\\\'
echo "$USER""$USER""$USER"
echo text"$USER"test
echo '$USER' "$USER" "text \' text"
echo '$USER'
echo $USER " "
echo "$USER""Users/$USER/file""'$USER'"'$USER'
echo "$USER$USER$USER"
echo '$USER'"$USER"'$USER'
echo '"$USER"''$USER'"""$USER"
echo " $USER "'$PWD'
echo " $USER \$ "'$PWD'
echo $USER=4
echo $USER=thallard
echo $USER
echo $?
echo $PWD/file
echo "$PWD/file"
echo "text" "text$USER" ... "$USER"
echo $PWD
env | grep "_="
env | grep "_="
env | grep "SHLVL"
@ -111,66 +32,7 @@ ls -la > tmp/file
ls -la > tmp/file
unset
export TEST=100
unset doesntexist
unset PWD
unset PWD
unset OLDPWD
unset PATH
unset PATH
unset PATH
unset TES\\\\T
unset TES;T
unset TES.T
unset TES+T
unset TES=T
unset TES}T
unset TES{T
unset TES-T
unset -TEST
unset _TEST
unset TES_T
unset TEST_
unset TE*ST
unset TES#T
unset TES@T
unset TES!T
unset TES$?T
unset ============
unset +++++++
unset ________
unset export
unset echo
unset pwd
unset cd
unset unset
unset sudo
unset TES^T
unset TES!T
unset TES\~T
echo $PWD
echo $PWD|cat -e
echo $PWD hallo | cat -e
echo '$PWD hallo | cat -e'
echo "$PWD hallo | cat -e"
wc < Makefile -l | cat -e > outfile | echo hello | rev > outfile2
< test.txt < Makefile<README.md wc -l|cat -e | rev
< Makefile cat > out | < README.md cat -e
< README.md cat -e | <Makefile cat
< in1 cat -e | < in2 cat
< in1 cat -e > out1 | < in2 cat
env | rev | head -5 | cat -e | rev
< in1 <in2 <in3 < Makefile rev | head -5 | cat -e | rev > out > out2 > out3 >> out4
echo ok"hello"ok1"mfg" == echo ok'hello'ok1'mfg'
echo okhellook1"mfg" == echo okhellook1'mfg'
echo "o""k "hellook1 == echo 'o''k 'hellook1
echo '"***hello***"'
echo "'***hello***'"
echo ok"'hello'"ok1"hello1"ok2
echo "text" "$USER" "$USER"
echo """"""""$USER""""""""
echo "-n -n -n"-n bonjour
echo "'$USER'"
echo "$PWD "a
echo " $PWD"
exit

25
tests/test_cd.txt Normal file
View File

@ -0,0 +1,25 @@
cd ; pwd
cd .. ; pwd
cd . ; pwd
cd /Users ; pwd
cd // ; pwd
cd '//' ; pwd
cd ////// ; pwd
cd ./././ ; pwd
cd / ; pwd
cd '/etc' ; pwd
cd '/var' ; pwd
cd "$PWD/prompt" ; pwd
cd "doesntexist" ; pwd
cd "doesntexist" 2>/dev/null ; pwd
cd ../../.. ; pwd
cd .. ; pwd
cd .. ; pwd
cd ? ; pwd
cd + ; pwd
cd _ ; pwd
cd bark bark ; pwd
cd '/' ; pwd
cd $PWD/file_tests ; pwd
cd $OLDPWD/builtins ; pwd
cd ~ ; pwd

81
tests/test_echo.txt Normal file
View File

@ -0,0 +1,81 @@
echo
echo echo
eCho
eChO
eCHO
echo $
echo $ $
ECHO
echo rhobebou
echo stop barking
echo "bonjour"
echo bonjour
echo 'bonjour'
echo -n bonjour
echo -nn bonjour
echo -n -n -n bonjour
echo "-n" bonjour
echo -n"-n" bonjour
echo "-nnnn" bonjour
echo "-nnnn" -n bonjour
echo "-n -n -n"-n bonjour
echo "-n '-n'" bonjour
echo $USER
echo "$USER"
echo "'$USER'"
echo " '$USER' "
echo text"$USER"
echo text"'$USER'" ' $USER '
echo "text" "$USER" "$USER"
echo ' $USER '
echo text "$USER" "$USER"text
echo ''''''''''$USER''''''''''
echo """"""""$USER""""""""
echo $USER'$USER'text oui oui oui oui $USER oui $USER ''
echo $USER '' $USER $USER '' $USER '' $USER -n $USER
echo ' \' ' \'
echo '\" ' " \"\""
echo \\\" \\\" \\\" \\\"\\\"\\\" \\\'\\\'\\\'
echo "$USER""$USER""$USER"
echo text"$USER"test
echo '$USER' "$USER" "text \' text"
echo '$USER'
echo $USER " "
echo "$USER""Users/$USER/file""'$USER'"'$USER'
echo "$USER$USER$USER"
echo '$USER'"$USER"'$USER'
echo '"$USER"''$USER'"""$USER"
echo " $USER "'$PWD'
echo " $USER \$ "'$PWD'
echo $USER=4
echo $USER=thallard
echo $USER
echo $?
echo $PWD/file
echo "$PWD/file"
echo "text" "text$USER" ... "$USER"
echo $PWD
echo $PWD|cat -e
echo $PWD hallo | cat -e
echo '$PWD hallo | cat -e'
echo "$PWD hallo | cat -e"
wc < Makefile -l | cat -e > outfile | echo hello | rev > outfile2
< test.txt < Makefile<README.md wc -l|cat -e | rev
< Makefile cat > out | < README.md cat -e
< README.md cat -e | <Makefile cat
< in1 cat -e | < in2 cat
< in1 cat -e > out1 | < in2 cat
env | rev | head -5 | cat -e | rev
< in1 <in2 <in3 < Makefile rev | head -5 | cat -e | rev > out > out2 > out3 >> out4
echo ok"hello"ok1"mfg" == echo ok'hello'ok1'mfg'
echo okhellook1"mfg" == echo okhellook1'mfg'
echo "o""k "hellook1 == echo 'o''k 'hellook1
echo '"***hello***"'
echo "'***hello***'"
echo ok"'hello'"ok1"hello1"ok2
echo "text" "$USER" "$USER"
echo """"""""$USER""""""""
echo "-n -n -n"-n bonjour
echo "'$USER'"
echo "$PWD "a
echo " $PWD"

3
tests/test_env.txt Normal file
View File

@ -0,0 +1,3 @@
env | grep "_="
env | grep "_="
env | grep "SHLVL"

View File

@ -1,2 +0,0 @@
echo "yeah"
exit

36
tests/test_unset.txt Normal file
View File

@ -0,0 +1,36 @@
unset doesntexist
unset PWD
unset PWD
unset OLDPWD
unset PATH
unset PATH
unset PATH
unset TES\\\\T
unset TES;T
unset TES.T
unset TES+T
unset TES=T
unset TES}T
unset TES{T
unset TES-T
unset -TEST
unset _TEST
unset TES_T
unset TEST_
unset TE*ST
unset TES#T
unset TES@T
unset TES!T
unset TES$?T
unset ============
unset +++++++
unset ________
unset export
unset echo
unset pwd
unset cd
unset unset
unset sudo
unset TES^T
unset TES!T
unset TES\~T