diff --git a/ut_bonus.sh b/tests/bonus.sh similarity index 100% rename from ut_bonus.sh rename to tests/bonus.sh diff --git a/ut_builtins.sh b/tests/defaults/builtins.sh similarity index 100% rename from ut_builtins.sh rename to tests/defaults/builtins.sh diff --git a/ut_builtins_env.sh b/tests/defaults/builtins_env.sh similarity index 100% rename from ut_builtins_env.sh rename to tests/defaults/builtins_env.sh diff --git a/ut_exit_status.sh b/tests/defaults/exit_status.sh similarity index 100% rename from ut_exit_status.sh rename to tests/defaults/exit_status.sh diff --git a/ut_expensions.sh b/tests/defaults/expensions.sh similarity index 100% rename from ut_expensions.sh rename to tests/defaults/expensions.sh diff --git a/ut_heredocs.sh b/tests/defaults/heredocs.sh similarity index 100% rename from ut_heredocs.sh rename to tests/defaults/heredocs.sh diff --git a/ut_pipes.sh b/tests/defaults/pipes.sh similarity index 100% rename from ut_pipes.sh rename to tests/defaults/pipes.sh diff --git a/ut_redirections.sh b/tests/defaults/redirections.sh similarity index 100% rename from ut_redirections.sh rename to tests/defaults/redirections.sh diff --git a/ut_to_do_manually.sh b/tests/to_do_manually.sh similarity index 100% rename from ut_to_do_manually.sh rename to tests/to_do_manually.sh diff --git a/tests/vrac.sh b/tests/vrac.sh new file mode 100644 index 0000000..4555ece --- /dev/null +++ b/tests/vrac.sh @@ -0,0 +1,662 @@ +$ + +file_name_in_current_dir + +/bin/echo bonjour + +not_cmd + +echo bonjour > $test w/ t +ls + +"exit retour a la ligne" + +minishell +# binary not in path without "./" before + +l^Ds + +touch testt +chmod 000 testt +ls +./testt + +mkdir testt +./testt +pwd +cd ../ + +cat < ../ + +# https://github.com/potatokuka/mini_tester/blob/main/test_cmds.txt +/bin/ls +exit a aa a +echo ";;;;;" +/bin/pwd +ls -la +pwd +/bin/chmod +/bin/ls -la +echo 00\\\'pp ; echo 00\\\\\'pp +echo 00\\\\'pp' ; echo “./hello”. ; echo ./hello ; echo ello +Echo ; echo \n ' \n this is the; "first line"' ; echo "and right here;;; 'We have the second'" ; echo and" a fe"'w 'here'; with some slash and quotes .' '\' ; echo '\\' ; echo "\\" ; echo "\"" ; echo \\ ; echo \' ; echo \" "\\" "\"" \\ \' \" +echo /$"123$USER" +echo | cd .. | pwd +echo DOET HET NIET > test1 | cat test1 +echo hallo >x1 >x2 >x3 | echo hoi +echo $POEP hallo +echo "hallo$" +echo "\poep" +echo $/ +echo $ +echo "123\"456" +exit 123 123 123 +exit 1234 +echo $? +/bin/ls +echo $? +/bin/ls doesnotexist +echo $? +echo hi ; echo ; echo ; echo ; export ; env ; echo ; echo ; echo ; echo working ; echo $PWD +ctrl-C +ctrl-D +ctrl-\ +asdf ctrl-C +asdf ctrl-D +cat ctrl-C +asdf ctrl-\ +cat ctrl-D +echo \"test\" +echo" +hoi +" +echo +hallo$ +env +export ; export a="\\" ; export b='\\' ; export c="\b" ; export +env +export a=hijdoehet ; export +export test=working ; export +export test1 +export +export test1= +export +export 1test +export _TEST=DOethetwelmetunderscore +env +env ; echo ; export a=hijdoehet ; echo ; env ; echo ; export test=working;echo ;env ; echo ; export test1; export; echo ; env ; echo ; export test1= ; echo ; env +export +export ZZZ +export ZZZ= +export ; export a="\\" ; export b='\\' ; export c="\b" ; export +export LS="ls -la" ; ls +export TEST="evenchecken" +echo $TEST +unset a ; env ; unset test ; unset test1 ; env +unset PATH +ls +wc +awk +echo $PWD ; echo $HOME ; echo "$PWD" ; echo '$PWD' ; echo "$HOME" +cd .. +pwd +/bin/ls +cd .. +pwd +/bin/ls +cd notworking +cd . +cd .. ;pwd;/bin/ls;cd .. ; pwd ;/bin/ls; cd notworking; cd . +cd ~ +cd $IETSONBESTAANDS +cd $GEK .. +cd $NOTHING $MORENOTHING .. +pwd +pwd . +pwd .. +cd ../Desktop +ls -la +echo > ilovewords.txt count me ; wc ilovewords.txt +awk '{ print }' /etc/passwd +export PATH="test:working:multiplepath:directory1:directory2" +export +echo 'how are you' +echo '$PWD' +echo > "hardesttest.txt" +echo adding stuff >> working.txt +echo more stuff >> working.txt +echo > working.txt +echo dit > test1 gaat > test2 goed > test3 +echo dit > test1 gaat > test2 goed > test3 > test4 +cat < test4 +< test4 cat +> newfile ; > working.txt +< working.txt +< notworking.txt +echo > doethet ; echo hoi >> doethet "of niet" ; echo clear > "doethet" ; echo test > working.txt ; echo > newfile.txt hardertest +export | grep -e "HOME=" +echo hallo daar | echo hoi maran +cat working.txt | grep stuff | echo tim +cat | cat -e | cat +ls filedoesnotexist | grep notme | echo "TEST" +export | grep -e "PWD=" +echo +echo hallo daar +"echo" hallo daar +echo "hallo daar" +echo hallo daar | echo hoi maran +echo hallo daar ; echo hoi maran +echo hallo >file1 >file2 +echo hallo >file1 >file2 maran +echo hallo >file1 >file2 >>file3 maran siemons +echo hallo file2 +echo $USER"" +echo $USER" +echo $USER_ +cd +export +export ZZZ +export ZZZ= +export ZZZ=new_value +export ZZZ======new +export ZZZ=new YYY=new2 XXX===new3 +export $USER +export TEST=$USER4857987345 +export 123$USER--- +export MARANSIEMONS +export MARANSIEMONS=lief +echo $ +echo 123$USER---- +echo 123$USER----$ +echo abc$USERdef +echo abc$USER123 +echo abc$POEPdef +echo $USER "$USER" '$USER' +export TEST_$USER=hallo$LOGNAME +echo $POEP +echo $POEP $MEERPOEP +echo hallo $POEP +hallo +echo $POEP hallo +hallo +export TEST=/Users/maran/Desktop/minishell +cd $IETSONBESTAANDS +cd $IETSONBESTAANDS +cd $POEP $MEERPOEP .. +echojhdfjhjdkh +echo | poep + echo | cd .. | pwd + echo +echo +echo hoi +cd poep +ls +"ls" +test +exit +exit 99 +exit 3 a +exit 55 99 +/bin/ls +/binn/ls +echo hallo 'ma\"ran' siemons +hallo ma\"ran siemons +echo hallo 'ma\'ran' siemons +Multiple line error +echo hallo 'ma\'ran'' siemons +hallo ma\ran siemons Hij ziet de \ niet als escape, print gewoon \ +echo 'ma\' Hij ziet de \ niet als escape, print gewoon \ +ma\ +echo 'hallo$USER' +hallo$USER +echo 'hallo\$USER' +hallo\$USER +echo '\$?' +\$? +echo '$USER' +$USER +echo '\$USER' +\$USER +echo '"\$USER"' +"\$USER" +echo "hallo"maran" +echo "\poep" +\poep +echo \poep +poep +echo "poep\"" +poep" +echo "poep\'" +poep\' +echo "poep\" +echo "hallo\"\poep" +hallo"\poep +echo hallo"" +hallo +echo "hoi$USERmaran" +echo "$USER" +maran +echo "'\$USER'" +'$USER' +echo "\$USER" +$USER +echo "123\"456" +123"456 +echo "\poep" +\poep +echo "123\'456" +123\'456 +echo "hallo$" +hallo$ +echo \" +" +echo \$? +echo '$USER'$USER +$USERmaran +echo '$USER'$USER\$USER/"$USER" +$USERmaran$USER/maran +echo hallo"1234"maran"$USER"'/$USER'"/$USER"'poep''poep2'"maran"'ellende'END +hallo1234maranmaran/$USER/maranpoeppoep2maranellendeEND +echo "$USER"'/$USER' +maran/$USER +echo 'poep''poep2'"maran"'ellende'END +poeppoep2maranellendeEND +echo 'poep2'"maran"'ellende' +poep2maranellende +echo 123"hallo$"456 +export kip=ei=koe===melk +echo $_1234 +echo hallo +echo hallo | echo hoi +echo hallo ; echo hoi +echo hallo >x1 >x2 >x3 | echo hoi +echo hallo >x1 >x2 >x3 ; echo hoi +echo hallo | echo poep >x1 >x2 +echo hallo ; echo poep >x1 >x2 +echo hallo | echo hoi | cat +echo hallo | echo hoi > y1 >y2 | cat -e +echo hoi > y1 >y2 ; cat -e +echo hallo | echo hoi > y1 >y2 ; cat -e +echt bash +echo "hello | this is some stuff > touch this file" | grep more +env | leaks +cat x1 | grep Makefile +ls > x1 ; cat x1 | grep main +echo $USERhallo +echo $hallo"poep" +echo /$"123$USER" +echo $a5aap +echo $_poep +echo hallo$\abc +hallo$abc +echo hallo$\\abc +hallo$\abc +echo hallo$"USER" +halloUSER +echo hallo$"POEP" +halloPOEP +echo hallo$'USER' +halloUSER +echo $halllo### +echo $USER9582309582529 +echo $ +echo $USER +echo $USER' +echo 123$USER---- +echo 123$USER----$ +echo abc$USERdef +echo abc$USER123 +echo abc$POEPdef +echo $%%%%jlkjtwejt +echo %%$ +echo $"USERhallo" +echo "$222" +echo "hallo$USER***$USER$2$" +echo "$_poep" +echo "$a5aap" +echo "$halllo###" +echo "$USER9582309582529" +"hallo$USER" +echo "$" +echo hallo"$"abc +hallo$abc +echo hallo"$POEP"abc +echo hallo"$USER"abc +echo "$USER" +echo "$USER'" +echo "$USER_" +echo "abc$USERdef" +echo "abc$USER123" +echo "abc$POEPdef" +echo "$%%%%jlkjtwejt" +echo "%%$" +echo $"hallo" +echo $hallo +echo $hallo"poep" +echo "hallo\"\poep" +echo $"etet" +“$rewtwet” +echo "$53535" +$" +$' +echo “$\hallo” +echo $"\hallo" +\hallo +echo "\\hallo" +\hallo +echo "hallo\\hoi" +hallo\hoi +echo "\\$USER" +\maran +echo "123\"456" +123"456 +echo "123\$456" +echo "123\\456" +123\456 +echo "123\!456" +123\!456 +echo "1234" +echo "12\34" +echo "1234\" +echo \"1234" +echo "1\a234" +echo \1 +echo "\1234" +echo "1234\\" +echo '1234\\' +echo '1234' +echo '12\34' +echo '1234\' +echo \'1234' +echo '1\a234' +echo '\1234' +echo '1234\\' +echo '1234\\' +echo \a +echo \b +echo \c +echo \d +echo \e +echo \! +echo \" +echo \# +echo \$ +echo \% +echo \& +echo \' +echo \( +echo \) +echo \* +echo \+ +echo \, +echo \- +echo \. +echo \/ +echo \0 +echo \1 +echo \2 +echo \3 +echo \4 +echo \5 +echo \6 +echo \7 +echo \8 +echo \9 +echo \: +echo \= +echo \? +echo \@ +echo \A +echo \B +echo \C +echo \D +echo \E +echo \F +echo \G +echo \H +echo \I +echo \J +echo \K +echo \L +echo \M +echo \N +echo \O +echo \P +echo \Q +echo \R +echo \S +echo \T +echo \U +echo \V +echo \W +echo \X +echo \Y +echo \Z +echo \[ +echo \\ +echo \] +echo \^ +echo \_ +echo \a +echo \b +echo \c +echo \d +echo \e +echo \f +echo \g +echo \h +echo \i +echo \j +echo \k +echo \l +echo \m +echo \n +echo \o +echo \p +echo \q +echo \r +echo \s +echo \t +echo \u +echo \v +echo \w +echo \x +echo \y +echo \z +echo \{ +echo \} +echo \~ +echo "\!" +echo "\"" +echo "\#" +echo "\$" +echo "\%" +echo "\&" +echo "\'" +echo "\(" +echo "\)" +echo "\*" +echo "\+" +echo "\," +echo "\-" +echo "\." +echo "\/" +echo "\0" +echo "\1" +echo "\2" +echo "\3" +echo "\4" +echo "\5" +echo "\6" +echo "\7" +echo "\8" +echo "\9" +echo "\:" +echo "\<" +echo "\=" +echo "\>" +echo "\?" +echo "\@" +echo "\A" +echo "\B" +echo "\C" +echo "\D" +echo "\E" +echo "\F" +echo "\G" +echo "\H" +echo "\I" +echo "\J" +echo "\K" +echo "\L" +echo "\M" +echo "\N" +echo "\O" +echo "\P" +echo "\Q" +echo "\R" +echo "\S" +echo "\T" +echo "\U" +echo "\V" +echo "\W" +echo "\X" +echo "\Y" +echo "\Z" +echo "\[" +echo "\\" +echo "\]" +echo "\^" +echo "\_" +echo "\a" +echo "\b" +echo "\c" +echo "\d" +echo "\e" +echo "\f" +echo "\g" +echo "\h" +echo "\i" +echo "\j" +echo "\k" +echo "\l" +echo "\m" +echo "\n" +echo "\o" +echo "\p" +echo "\q" +echo "\r" +echo "\s" +echo "\t" +echo "\u" +echo "\v" +echo "\w" +echo "\x" +echo "\y" +echo "\z" +echo "\{" +echo "\|" +echo "\}" +echo "\~" +echo '\!' +echo '\"' +echo '\#' +echo '\$' +echo '\%' +echo '\&' +echo '\'' +echo '\(' +echo '\)' +echo '\*' +echo '\+' +echo '\,' +echo '\-' +echo '\.' +echo '\/' +echo '\0' +echo '\1' +echo '\2' +echo '\3' +echo '\4' +echo '\5' +echo '\6' +echo '\7' +echo '\8' +echo '\9' +echo '\:' +echo '\<' +echo '\=' +echo '\>' +echo '\?' +echo '\@' +echo '\A' +echo '\B' +echo '\C' +echo '\D' +echo '\E' +echo '\F' +echo '\G' +echo '\H' +echo '\I' +echo '\J' +echo '\K' +echo '\L' +echo '\M' +echo '\N' +echo '\O' +echo '\P' +echo '\Q' +echo '\R' +echo '\S' +echo '\T' +echo '\U' +echo '\V' +echo '\W' +echo '\X' +echo '\Y' +echo '\Z' +echo '\[' +echo '\\' +echo '\]' +echo '\^' +echo '\_' +echo '\a' +echo '\b' +echo '\c' +echo '\d' +echo '\e' +echo '\f' +echo '\g' +echo '\h' +echo '\i' +echo '\j' +echo '\k' +echo '\l' +echo '\m' +echo '\n' +echo '\o' +echo '\p' +echo '\q' +echo '\r' +echo '\s' +echo '\t' +echo '\u' +echo '\v' +echo '\w' +echo '\x' +echo '\y' +echo '\z' +echo '\{' +echo '\|' +echo '\}' +echo '\~' +echo '\;' +echo "\;" +echo '\>' +echo "\>" +echo '\<' +echo "\<" +echo '\|' +echo "\|" + + diff --git a/unitests.sh b/unitests.sh index a1b40f9..5b5da33 100644 --- a/unitests.sh +++ b/unitests.sh @@ -2,6 +2,8 @@ cd $(dirname $0) MINISHELL="../minishell" +TEST_DIR="./tests/" +DEFAULT_DIR="./tests/defaults/" # COLORS RED="\e[0;31m" @@ -41,14 +43,7 @@ MINISHELL="../minishell" MINISHELL_LOG="./logs/minishell_log.txt" # default list of files to be use - default_files="\ - ut_builtins.sh - ut_exit_status.sh - ut_expensions.sh - ut_heredocs.sh - ut_pipes.sh - ut_redirections.sh - ut_vrac.sh" + default_files="$( find $DEFAULT_DIR | tail -n+2 )" # print usage function print_usage @@ -97,7 +92,7 @@ MINISHELL="../minishell" DIFF_FILES="$(comm -3 <(echo "$FILES_BEFORE") <(echo "$FILES_AFTER"))" while read line_diff do - rm -r "$line_diff" + rm -rf "$line_diff" done < <(echo "$DIFF_FILES") } @@ -139,16 +134,22 @@ MINISHELL="../minishell" list_files="" for (( i = $START ; i <= "$#" ; i++ )) do - if [ -e "${!i}" ] + # the ! is for indirect parameter expansion + # $i expand in integers 1,2,3... + # $1,$2,$3... expand in arguments of process call + FILE="${!i/#/$TEST_DIR}" + FILE="${FILE%.sh}" + FILE="${FILE/%/.sh}" + if [ -e "$FILE" ] then if [ -n "$list_files" ] then list_files+=$'\n' fi - list_files+="${!i}" + list_files+="$FILE" else print_usage - echo " \"${!i}\" is not a valid file or option, see usage above" + echo " <$FILE> is not a valid file or option, see usage above" fi done fi @@ -283,6 +284,7 @@ MINISHELL="../minishell" echo "" print_results "all" $TOTAL_SUCCESS $TOTAL_TEST fi + delete_files # ask to show the diff # -rsn1 will stop read after first key pressed diff --git a/ut_vrac.sh b/ut_vrac.sh deleted file mode 100644 index b6e3588..0000000 --- a/ut_vrac.sh +++ /dev/null @@ -1,32 +0,0 @@ -$ - -file_name_in_current_dir - -/bin/echo bonjour - -not_cmd - -echo bonjour > $test w/ t -ls -rm '$test' - -"exit retour a la ligne" - -minishell -# binary not in path without "./" before - -l^Ds - -touch testt -chmod 000 testt -ls -./testt -rm -rf testt - -mkdir testt -./testt -pwd -cd ../ -rm -rf testt - -cat < ../