From a288ad473e372570c3ccc985c88a0e98c85f5ec1 Mon Sep 17 00:00:00 2001 From: hugogogo Date: Fri, 3 Dec 2021 22:32:07 +0100 Subject: [PATCH] test unitaires a peu pres ok :) --- tests/unit_tests/builtins.sh | 1 - tests/unit_tests/exit_status.sh | 1 - tests/unit_tests/expensions.sh | 1 - tests/unit_tests/file.log | 3 - tests/unit_tests/logs/bash_log.txt | 59 ++++++ tests/unit_tests/logs/log_err.txt | 1 + tests/unit_tests/logs/minishell_log.txt | 60 ++++++ tests/unit_tests/pipes.sh | 8 - tests/unit_tests/redirections.sh | 1 - tests/unit_tests/t0mm4rx_tests.md | 105 --------- tests/unit_tests/test | 1 - tests/unit_tests/test1.sh | 111 ---------- tests/unit_tests/test2.sh | 5 - tests/unit_tests/test3.sh | 10 - .../unit_tests/{test_unit.sh => unitests.sh} | 159 ++++++++------ tests/unit_tests/ut_bonus.sh | 11 + tests/unit_tests/ut_builtins.sh | 108 ++++++++++ tests/unit_tests/ut_exit_status.sh | 17 ++ tests/unit_tests/ut_expensions.sh | 35 +++ .../{heredocs.sh => ut_heredocs.sh} | 2 +- tests/unit_tests/ut_pipes.sh | 36 ++++ tests/unit_tests/ut_redirections.sh | 54 +++++ tests/unit_tests/ut_to_do_manually.sh | 11 + tests/unit_tests/ut_vrac.sh | 19 ++ tests/unit_tests/vrac.sh | 200 ------------------ tests/unit_tests/{ => wip}/main.c | 0 26 files changed, 506 insertions(+), 513 deletions(-) delete mode 100644 tests/unit_tests/builtins.sh delete mode 100644 tests/unit_tests/exit_status.sh delete mode 100644 tests/unit_tests/expensions.sh delete mode 100644 tests/unit_tests/file.log create mode 100644 tests/unit_tests/logs/log_err.txt delete mode 100644 tests/unit_tests/pipes.sh delete mode 100644 tests/unit_tests/redirections.sh delete mode 100644 tests/unit_tests/t0mm4rx_tests.md delete mode 100644 tests/unit_tests/test delete mode 100644 tests/unit_tests/test1.sh delete mode 100644 tests/unit_tests/test2.sh delete mode 100644 tests/unit_tests/test3.sh rename tests/unit_tests/{test_unit.sh => unitests.sh} (61%) create mode 100644 tests/unit_tests/ut_bonus.sh create mode 100644 tests/unit_tests/ut_builtins.sh create mode 100644 tests/unit_tests/ut_exit_status.sh create mode 100644 tests/unit_tests/ut_expensions.sh rename tests/unit_tests/{heredocs.sh => ut_heredocs.sh} (76%) create mode 100644 tests/unit_tests/ut_pipes.sh create mode 100644 tests/unit_tests/ut_redirections.sh create mode 100644 tests/unit_tests/ut_to_do_manually.sh create mode 100644 tests/unit_tests/ut_vrac.sh delete mode 100644 tests/unit_tests/vrac.sh rename tests/unit_tests/{ => wip}/main.c (100%) diff --git a/tests/unit_tests/builtins.sh b/tests/unit_tests/builtins.sh deleted file mode 100644 index df7d12a..0000000 --- a/tests/unit_tests/builtins.sh +++ /dev/null @@ -1 +0,0 @@ -echo "builtins" diff --git a/tests/unit_tests/exit_status.sh b/tests/unit_tests/exit_status.sh deleted file mode 100644 index db1c752..0000000 --- a/tests/unit_tests/exit_status.sh +++ /dev/null @@ -1 +0,0 @@ -echo "exit status" diff --git a/tests/unit_tests/expensions.sh b/tests/unit_tests/expensions.sh deleted file mode 100644 index d9caf1c..0000000 --- a/tests/unit_tests/expensions.sh +++ /dev/null @@ -1 +0,0 @@ -echo "expensions" diff --git a/tests/unit_tests/file.log b/tests/unit_tests/file.log deleted file mode 100644 index 3093fdb..0000000 --- a/tests/unit_tests/file.log +++ /dev/null @@ -1,3 +0,0 @@ -mybash a very long prompt to test the output in case of a redirection in a file> echo hello -hello -mybash a very long prompt to test the output in case of a redirection in a file> exit diff --git a/tests/unit_tests/logs/bash_log.txt b/tests/unit_tests/logs/bash_log.txt index 8b13789..a6b1212 100644 --- a/tests/unit_tests/logs/bash_log.txt +++ b/tests/unit_tests/logs/bash_log.txt @@ -1 +1,60 @@ + + + +file: ut_vrac.sh +  + +$ +----------- + + + +file_name_in_current_dir +----------- + + + +/bin/echo bonjour +----------- +bonjour + + +not_cmd +----------- + + + +echo bonjour > $test w/ t +ls +rm '$test' +----------- +logs +minishell +tests_discord.md +unitests.sh +ut_bonus.sh +ut_builtins.sh +ut_exit_status.sh +ut_expensions.sh +ut_heredocs.sh +ut_pipes.sh +ut_redirections.sh +ut_to_do_manually.sh +ut_vrac.sh +wip + + +"exit retour a la ligne" +----------- + + + +minishell +----------- + + + +l^Ds +----------- + diff --git a/tests/unit_tests/logs/log_err.txt b/tests/unit_tests/logs/log_err.txt new file mode 100644 index 0000000..ab50433 --- /dev/null +++ b/tests/unit_tests/logs/log_err.txt @@ -0,0 +1 @@ +hulamy@NoName:/home/simplonco/Nextcloud/informatique/42/minishell/minishell/tests s/unit_tests> exit +10 diff --git a/tests/unit_tests/logs/minishell_log.txt b/tests/unit_tests/logs/minishell_log.txt index 8b13789..edfa877 100644 --- a/tests/unit_tests/logs/minishell_log.txt +++ b/tests/unit_tests/logs/minishell_log.txt @@ -1 +1,61 @@ + + + +file: ut_vrac.sh +  + +$ +----------- + + + +file_name_in_current_dir +----------- + + + +/bin/echo bonjour +----------- +bonjour + + +not_cmd +----------- + + + +echo bonjour > $test w/ t +ls +rm '$test' +----------- +logs +minishell +$test +tests_discord.md +unitests.sh +ut_bonus.sh +ut_builtins.sh +ut_exit_status.sh +ut_expensions.sh +ut_heredocs.sh +ut_pipes.sh +ut_redirections.sh +ut_to_do_manually.sh +ut_vrac.sh +wip + + +"exit retour a la ligne" +----------- + + + +minishell +----------- + + + +l^Ds +----------- + diff --git a/tests/unit_tests/pipes.sh b/tests/unit_tests/pipes.sh deleted file mode 100644 index 821824a..0000000 --- a/tests/unit_tests/pipes.sh +++ /dev/null @@ -1,8 +0,0 @@ -echo bonjour ; | - -echo bonjour | | - -| - -echo bonjour |; - diff --git a/tests/unit_tests/redirections.sh b/tests/unit_tests/redirections.sh deleted file mode 100644 index d933bd8..0000000 --- a/tests/unit_tests/redirections.sh +++ /dev/null @@ -1 +0,0 @@ -echo "redirections" diff --git a/tests/unit_tests/t0mm4rx_tests.md b/tests/unit_tests/t0mm4rx_tests.md deleted file mode 100644 index 06eb103..0000000 --- a/tests/unit_tests/t0mm4rx_tests.md +++ /dev/null @@ -1,105 +0,0 @@ -# Minishell tests - -Here are some tests for the minishell project of school 42 cursus. It's not exaustive, so don't limit yourself with this tests. -These tests are not all mines. Credits to vgoldman, mashar, and jecaudal. - -tmarx -# Tests - -- [ ] echo bonjour ; | -- [ ] echo bonjour | | -- [ ] | -- [ ] echo bonjour |; -- [ ] echo bonjour \; ls -- [ ] echo bonjour > test\ 1 -- [ ] cd $HOME/Documents -- [ ] echo "\s" & echo "\\s" -- [ ] echo \> -- [ ] echo -n -n -nnnn -nnnnm -- [ ] cat /dev/random | head -n 1 | cat -e -- [ ] unset var1 # with undefined var1 -- [ ] export "" et unset "" -- [ ] echo test > file test1 -- [ ] $ -- [ ] not_cmd bonjour > salut -- [ ] env puis export puis env # vars aren't sorted -- [ ] cat Makefile | grep pr | head -n 5 | cd test (mybin) # check status code -- [ ] cat Makefile | grep pr | head -n 5 | cat test (bin) # check status code -- [ ] cat Makefile | grep pr | head -n 5 | hello (NA) # check status code -- [ ] echo bonjour >>> test -- [ ] echo bonjour > > out -- [ ] echo 2 >> out1 > out2 -- [ ] echo 2 > out1 >> out2 -- [ ] cat < test # with non-existent test -- [ ] export var; export var=test -- [ ] echo bonjour > $test # with test not defined -- [ ] file_name_in_current_dir -- [ ] cd ../../../../../.. ; pwd -- [ ] ctrl-C . 130 sur bin(ex : sleep 10)&line vide -- [ ] ctrl-\ .131 sur bin -- [ ] echo "bip | bip ; coyotte > < \" " -- [ ] cat | cat | cat | ls # check outputs order -- [ ] $bla # with bla not defined -- [ ] export var ="cat Makefile | grep >" -- [ ] export "test=ici"=coucou -- [ ] c$var Makefile # with var=at -- [ ] $LESS$VAR -- [ ] /bin/echo bonjour -- [ ] not_cmd -- [ ] sleep 5 | exit -- [ ] echo bonjour > $test w/ t -- [ ] "exit retour a la ligne" -- [ ] minishell # binary not in path without "./" before -- [ ] cat diufosgid # check exit code -- [ ] exit # should return the last exit code value -- [ ] exit -10 -- [ ] exit +10 -- [ ] ; -- [ ] echo coucou | ; -- [ ] echo "$HOME" -- [ ] echo '$HOME' -- [ ] export ; env # display is different for both commands -- [ ] echo \$HOME -- [ ] > log echo coucou -- [ ] echo hudifg d | | hugdfihd -- [ ] echo -- [ ] echo simple -- [ ] echo -n simple -- [ ] echo '\' -- [ ] echo "\" -- [ ] echo "\\" -- [ ] echo "\n \n \n" -- [ ] echo "\n \\n \\\n" -- [ ] echo ;; -- [ ] echo hi";" hihi -- [ ] echo hi " ; " hihi -- [ ] cd -- [ ] cd . -- [ ] cd ~ -- [ ] cd / -- [ ] cd no_file -- [ ] cd a b c d -- [ ] pwd a -- [ ] pwd a b c d -- [ ] export LOL=lala ROR=rara -- [ ] unset LOL ROR -- [ ] export "HI= hi" -- [ ] export "HI =hi" -- [ ] /bin/ls -- [ ] # write something the press ctrl+c -- [ ] # write something then press ctrl+d -- [ ] # write something then press ctrl+\ -- [ ] echo $? -- [ ] l^Ds -- [ ] echo | -- [ ] | echo -- [ ] sort | ls # check output order -- [ ] cat < > -- [ ] cat < < -- [ ] cat > > -- [ ] > a ls > b < Makefile -- [ ] echo > a Hello World! -- [ ] > a echo Hello World! -- [ ] cat < Makefile | grep gcc > output -- [ ] exit 0 | exit 1 -- [ ] exit 1 | exit 0 \ No newline at end of file diff --git a/tests/unit_tests/test b/tests/unit_tests/test deleted file mode 100644 index e11e39e..0000000 --- a/tests/unit_tests/test +++ /dev/null @@ -1 +0,0 @@ -bonjour 1 diff --git a/tests/unit_tests/test1.sh b/tests/unit_tests/test1.sh deleted file mode 100644 index b6defe6..0000000 --- a/tests/unit_tests/test1.sh +++ /dev/null @@ -1,111 +0,0 @@ -echo hello -echo test - -# comment - - - - - -echo you -echo you - - - - - - - - - - - - - - - - - - - - - - - -echo you -echo you - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -echo you -echo you diff --git a/tests/unit_tests/test2.sh b/tests/unit_tests/test2.sh deleted file mode 100644 index 54f7176..0000000 --- a/tests/unit_tests/test2.sh +++ /dev/null @@ -1,5 +0,0 @@ -echo "ho !" - -echo "it's you again" - -echo "welcome back" diff --git a/tests/unit_tests/test3.sh b/tests/unit_tests/test3.sh deleted file mode 100644 index 8f12d98..0000000 --- a/tests/unit_tests/test3.sh +++ /dev/null @@ -1,10 +0,0 @@ -echo "let's" -echo "see what" -echo "you've" -echo "got" - -echo "show" -echo "me" -echo "what" -echo "you" -echo "goooot" diff --git a/tests/unit_tests/test_unit.sh b/tests/unit_tests/unitests.sh similarity index 61% rename from tests/unit_tests/test_unit.sh rename to tests/unit_tests/unitests.sh index 2430af0..6ae2e79 100644 --- a/tests/unit_tests/test_unit.sh +++ b/tests/unit_tests/unitests.sh @@ -1,24 +1,5 @@ #!/bin/bash -## explanation : -## 1. check for arguments (files for tests) -## if found, check for validity, and launch test on them -## if not found, launch test on default file list -## 2. execute the main for-loop -## it will iterate through the commands of each files -## if a line start with a # it's skipped -## if commands are not separated by empty line, it concat them -## then it calls the compare function "test_minishell" with commands -## and it calls the print function with the results -## 3. the compare function "test_minishell" -## it takes the commands in argument -## it launch bash and minishell with the commands -## if multiple commands, they are executed in a row before exit the shell -## if error, it prints right away the two outputs -## 4. the print function, print results -## it's use after each files -## and at the end - # COLORS RED="\001\e[0;31m\002" GREEN="\001\e[0;32m\002" @@ -48,7 +29,7 @@ TOTAL_TEST=0 TOTAL_SUCCESS=0 LINE_NUMBER=0 - LOG=0 + OPTION=0 PRINT=0 mkdir -p ./logs echo "" > ./logs/bash_log.txt @@ -58,13 +39,13 @@ # default list of files to be use default_files="\ - vrac.sh - pipes.sh - expensions.sh - redirections.sh - exit_status.sh - builtins.sh" - #heredocs.sh + ut_builtins.sh + ut_exit_status.sh + ut_expensions.sh + ut_heredocs.sh + ut_pipes.sh + ut_redirections.sh + ut_vrac.sh" # print usage function print_usage @@ -88,8 +69,10 @@ echo " options :" echo -en "$ENDCO" echo -en "$CYAN" - echo " help - print usage" - echo " log - log output into logs/" + echo " help - print usage" + echo " -p1 - prints errors" + echo " -p2 - prints errors and commands" + echo " -p3 - prints errors and commands and errors output" echo -en "$ENDCO" echo "" echo -en "$GREEN" @@ -104,26 +87,40 @@ echo "" } -# list of tests files, by default ot in parameters - if [ $# == 0 ] +# check for argments, like options or files list +# if no file list, default file list is used + list_files="$default_files" + if [ $# -gt 0 ] then - list_files="$default_files" - else + START=1 if [ "$1" == "help" ] then print_usage - else - START=1 - if [ "$1" == "log" ] + START=0 + elif [ "$1" == "-p1" ] + then + PRINT=1 + OPTION=1 + elif [ "$1" == "-p2" ] + then + PRINT=2 + OPTION=1 + elif [ "$1" == "-p3" ] + then + PRINT=3 + OPTION=1 + fi + if [ $OPTION -eq 1 ] + then + if [ $# -eq 1 ] then - LOG=1 - START=2 - fi - if [ "$1" == "print" ] - then - PRINT=1 + START=0 + else START=2 fi + fi + if [ $START -gt 0 ] + then list_files="" for (( i = $START ; i <= "$#" ; i++ )) do @@ -135,47 +132,67 @@ fi list_files+="${!i}" else - echo "${!i} is not a valid file" + print_usage + echo " \"${!i}\" is not a valid file or option, see usage above" fi done fi fi +# if print option, print next command + function print_next_command + { + TEXT=$1 + CMD=$2 + COLOR=$3 + INDENT="$(for (( i=1; i<=${#TEXT}; i++ )); do echo -n ' '; done)" + echo -en $COLOR"$TEXT"$YELLOW + echo -n "${CMD//$'\n'/$'\n'$INDENT}" + echo -e $ENDCO + } + # function that will launch the command in bash and minishell and compare them function test_minishell { - # if print option, print wich command is about to be executed - if [ "$PRINT" == 1 ] + # if -p2|3, print which command is about to be executed + if [ $PRINT -gt 1 ] then - NEXT_CMD="command line $LINE_NUMBER : " - INDENT="$(for (( i=1; i<=${#NEXT_CMD}; i++ )); do echo -n ' '; done)" - echo -en $CYAN"$NEXT_CMD"$YELLOW - echo -n "${@//$'\n'/$'\n'$INDENT}" - echo -e $ENDCO + NEXT_CMD="command line $(( $LINE_NUMBER - 1 )) : " + print_next_command "$NEXT_CMD" "$@" "$CYAN" fi - # execute commands in bash and minishell + # execute commands in bash, and logs results bash_execution=$( echo "$@" | bash 2>/dev/null ) + echo -e $B_WHITE"\n\n$@\n-----------"$ENDCO >>$BASH_LOG + echo "$bash_execution" >> $BASH_LOG + minishell_execution=$( echo "$@" | ./minishell 2>/dev/null ) - # if log option, log results - if [ "$LOG" == 1 ] - then - echo "$@" | bash -i &>>$BASH_LOG - echo "$@" | ./minishell &>>$MINISHELL_LOG - fi + echo -e $B_WHITE"\n\n$@\n-----------"$ENDCO >>$MINISHELL_LOG + echo "$minishell_execution" >> $MINISHELL_LOG + #compare output if [ "$bash_execution" = "$minishell_execution" ] then (( SUCCESS_TEST++ )) (( TOTAL_SUCCESS++ )) else - echo -e $B_RED"ERROR : line number $LINE_NUMBER"$ENDCO - echo "" - echo -e $B_MAGENTA"[bash execution] :"$ENDCO - echo "$@" | bash -i - echo "" - echo -e $B_MAGENTA"[minishell execution] :"$ENDCO - echo "$@" | ./minishell - echo "" + # if -p1..3 print error for command + if [ $PRINT -eq 1 ] + then + ERROR_CMD="ERROR line $(( $LINE_NUMBER - 1 )), command : " + print_next_command "$ERROR_CMD" "$@" "$B_RED" + elif [ $PRINT -eq 2 ] + then + echo -e $B_RED" "'\'" ERROR"$ENDCO + elif [ $PRINT -eq 3 ] + then + echo -e $B_RED" "'\'" ERROR"$ENDCO + echo -e $B_MAGENTA"[bash execution] :"$ENDCO + echo "$@" | bash -i + echo "" + echo -e $B_MAGENTA"[minishell execution] :"$ENDCO + echo "$@" | ./minishell + echo "" + fi fi } @@ -204,9 +221,14 @@ filename=$i echo -e "\n"$B_YELLOW"test file : $i"$ENDCO command_test="" + LINE_NUMBER=0 LAST_LINE_NUMBER=$(wc -l < $filename) UNIT_TEST=0 SUCCESS_TEST=0 + # write name of file in log files + echo -en $B_YELLOW "\n\n\nfile: $filename\n" $ENDCO >>$BASH_LOG + echo -en $B_YELLOW "\n\n\nfile: $filename\n" $ENDCO >>$MINISHELL_LOG + # do the loop while read line do (( LINE_NUMBER++ )) @@ -246,3 +268,10 @@ echo "" print_results "all" $TOTAL_SUCCESS $TOTAL_TEST fi + +# ask to show the diff + read -p 'you want to see the diff ? (y?)' DIFF + if [[ "${DIFF,,}" =~ y|yes ]] + then + diff -y --width=100 --color=always "$BASH_LOG" "$MINISHELL_LOG" + fi diff --git a/tests/unit_tests/ut_bonus.sh b/tests/unit_tests/ut_bonus.sh new file mode 100644 index 0000000..f71d00b --- /dev/null +++ b/tests/unit_tests/ut_bonus.sh @@ -0,0 +1,11 @@ +echo bonjour ; | + +echo bonjour |; + +; + +echo coucou | ; + +echo ;; + +echo bonjour \; ls diff --git a/tests/unit_tests/ut_builtins.sh b/tests/unit_tests/ut_builtins.sh new file mode 100644 index 0000000..e9827e6 --- /dev/null +++ b/tests/unit_tests/ut_builtins.sh @@ -0,0 +1,108 @@ +# +# ENV +# + +env + +# +# EXPORT +# + +export var + +export var=test + +export var ="cat Makefile | grep >" + +export "test=ici"=coucou + +export LOL=lala ROR=rara + +export "HI= hi" + +export "HI =hi" + +export +env +# display is different for both commands + +env +export +env + +# +# UNSET +# + +export BLOU= +env +unset BLOU +env + +unset LOL ROR +env + +unset blablabla +env + +export "" +env +unset "" +env + +# +# ECHO +# + +echo + +echo simple + +echo -n simple + +echo -n -n -nnnn -nnnnm + +# +# PWD +# + +pwd a + +pwd a b c d + +# +# CD +# + +cd +pwd + +cd . +pwd + +cd ~ +pwd + +cd / +pwd + +cd no_file +pwd + +cd a b c d +pwd + +cd $HOME/Documents +pwd + +cd ../../../../../.. +pwd + +# +# EXIT +# + +exit -10 + +exit +10 + diff --git a/tests/unit_tests/ut_exit_status.sh b/tests/unit_tests/ut_exit_status.sh new file mode 100644 index 0000000..9a2968f --- /dev/null +++ b/tests/unit_tests/ut_exit_status.sh @@ -0,0 +1,17 @@ +echo $? + +cat Makefile | grep pr | head -n 5 | cd test (mybin) +$? + +cat Makefile | grep pr | head -n 5 | cat test (bin) +$? + +cat Makefile | grep pr | head -n 5 | hello (NA) +$? + +cat diufosgid +$? + +exit +$? + diff --git a/tests/unit_tests/ut_expensions.sh b/tests/unit_tests/ut_expensions.sh new file mode 100644 index 0000000..d349a49 --- /dev/null +++ b/tests/unit_tests/ut_expensions.sh @@ -0,0 +1,35 @@ +echo "bip | bip ; coyotte > < \" " + +export vat=at +c$var Makefile + +$blablabla + +$LESS$VAR + +echo '\' + +echo "\" + +echo "\\" + +echo "\n \n \n" + +echo "\n \\n \\\n" + +echo hi";" hihi + +echo hi " ; " hihi + +echo "\s" + +echo "\\s" + +echo \> + +echo "$HOME" + +echo '$HOME' + +echo \$HOME + diff --git a/tests/unit_tests/heredocs.sh b/tests/unit_tests/ut_heredocs.sh similarity index 76% rename from tests/unit_tests/heredocs.sh rename to tests/unit_tests/ut_heredocs.sh index 2a3cd63..08de63d 100644 --- a/tests/unit_tests/heredocs.sh +++ b/tests/unit_tests/ut_heredocs.sh @@ -6,7 +6,7 @@ COMMANDE=' echo "hugo"' # EOF' #echo "$COMMANDE" | bash -i &>file.log -echo "$COMMANDE" | ./minishell &>file.log +#echo "$COMMANDE" | ./minishell &>file.log #cat << EOF #hello diff --git a/tests/unit_tests/ut_pipes.sh b/tests/unit_tests/ut_pipes.sh new file mode 100644 index 0000000..19d3784 --- /dev/null +++ b/tests/unit_tests/ut_pipes.sh @@ -0,0 +1,36 @@ +echo bonjour ; | + +echo bonjour | | + +| + +echo bonjour |; + +cat Makefile | grep pr | head -n 5 | cd test (mybin) + +cat Makefile | grep pr | head -n 5 | cat test (bin) + +cat Makefile | grep pr | head -n 5 | hello (NA) + +cat | cat | cat | ls + +echo hudifg d | | hugdfihd + +echo | + +| echo + +sort | ls + +exit 0 | exit 1 + +exit 1 | exit 0 + +cat < Makefile | grep gcc > output +ls +rm output + +rm output + +sleep 5 | exit + diff --git a/tests/unit_tests/ut_redirections.sh b/tests/unit_tests/ut_redirections.sh new file mode 100644 index 0000000..96e00ee --- /dev/null +++ b/tests/unit_tests/ut_redirections.sh @@ -0,0 +1,54 @@ +echo bonjour > $test +ls +rm '$test' + +> log echo coucou +ls +rm log + +cat < > + +cat < < + +cat > > + +> a ls > b < Makefile +ls +rm a b + +echo > a Hello World! +ls +rm a + +> a echo Hello World! +ls +rm a + +echo bonjour > test\ 1 +ls +rm test + +echo bonjour >>> test + +echo bonjour > > out +ls +rm out + +echo 2 >> out1 > out2 +ls +rm out1 out2 + +echo 2 > out1 >> out2 +ls +rm out1 out2 + +cat < blablabla + +echo test > file test1 +ls +rm file + +not_cmd bonjour > salut +ls +rm salut + diff --git a/tests/unit_tests/ut_to_do_manually.sh b/tests/unit_tests/ut_to_do_manually.sh new file mode 100644 index 0000000..cdfab63 --- /dev/null +++ b/tests/unit_tests/ut_to_do_manually.sh @@ -0,0 +1,11 @@ + +cat /dev/random | head -n 1 | cat -e + +ctrl-C . 130 sur bin(ex : sleep 10)&line vide + +ctrl-\ .131 sur bin + +/bin/ls +write something the press ctrl+c +write something then press ctrl+d +write something then press ctrl+\ diff --git a/tests/unit_tests/ut_vrac.sh b/tests/unit_tests/ut_vrac.sh new file mode 100644 index 0000000..b7adfe5 --- /dev/null +++ b/tests/unit_tests/ut_vrac.sh @@ -0,0 +1,19 @@ +$ + +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 + diff --git a/tests/unit_tests/vrac.sh b/tests/unit_tests/vrac.sh deleted file mode 100644 index 7aaa759..0000000 --- a/tests/unit_tests/vrac.sh +++ /dev/null @@ -1,200 +0,0 @@ -echo bonjour ; | - -echo bonjour | | - -| - -echo bonjour |; - -echo bonjour \; ls - -echo bonjour > test\ 1 - -cd $HOME/Documents - -echo "\s" & echo "\\s" - -echo \> - -echo -n -n -nnnn -nnnnm - -cat /dev/random | head -n 1 | cat -e - -unset blablabla - -export "" et unset "" - -echo test > file test1 - -$ - -not_cmd bonjour > salut - -env -export -env - -cat Makefile | grep pr | head -n 5 | cd test (mybin) -$? - -cat Makefile | grep pr | head -n 5 | cat test (bin) -$? - -cat Makefile | grep pr | head -n 5 | hello (NA) -$? - -echo bonjour >>> test - -echo bonjour > > out - -echo 2 >> out1 > out2 - -echo 2 > out1 >> out2 - -cat < blablabla - -export var; export var=test - -echo bonjour > $test - -file_name_in_current_dir - -cd ../../../../../.. ; pwd - -ctrl-C . 130 sur bin(ex : sleep 10)&line vide - -ctrl-\ .131 sur bin - -echo "bip | bip ; coyotte > < \" " - -cat | cat | cat | ls - -$blablabla - -export var ="cat Makefile | grep >" - -export "test=ici"=coucou - -export vat=at -c$var Makefile - -$LESS$VAR - -/bin/echo bonjour - -not_cmd - -sleep 5 | exit - -echo bonjour > $test w/ t - -"exit retour a la ligne" - -minishell -# binary not in path without "./" before - -cat diufosgid -$? - -exit -$? - -exit -10 - -exit +10 - -; - -echo coucou | ; - -echo "$HOME" - -echo '$HOME' - -export ; env -# display is different for both commands - -echo \$HOME - -> log echo coucou - -echo hudifg d | | hugdfihd - -echo - -echo simple - -echo -n simple - -echo '\' - -echo "\" - -echo "\\" - -echo "\n \n \n" - -echo "\n \\n \\\n" - -echo ;; - -echo hi";" hihi - -echo hi " ; " hihi - -cd - -cd . - -cd ~ - -cd / - -cd no_file - -cd a b c d - -pwd a - -pwd a b c d - -export LOL=lala ROR=rara - -unset LOL ROR - -export "HI= hi" - -export "HI =hi" - -# /bin/ls -# write something the press ctrl+c -# write something then press ctrl+d -# write something then press ctrl+\ - -echo $? - -l^Ds - -echo | - -| echo - -sort | ls - -cat < > - -cat < < - -cat > > - -> a ls > b < Makefile - -echo > a Hello World! - -> a echo Hello World! - -cat < Makefile | grep gcc > output - -exit 0 | exit 1 - -exit 1 | exit 0 diff --git a/tests/unit_tests/main.c b/tests/unit_tests/wip/main.c similarity index 100% rename from tests/unit_tests/main.c rename to tests/unit_tests/wip/main.c