Tester is much better, ready for tests to be added
This commit is contained in:
104
main_test.sh
104
main_test.sh
@@ -3,49 +3,113 @@
|
||||
|
||||
# import and run all tests
|
||||
|
||||
#test_files=("test_template.sh" "test_header.sh" "test_body.sh")
|
||||
test_files=("test_template.sh" "test_header.sh" "test_path.sh")
|
||||
#test_files=("test_path.sh")
|
||||
|
||||
##########
|
||||
# Colors
|
||||
##########
|
||||
|
||||
|
||||
_GREY='\033[30m'
|
||||
_RED='\033[0;31m'
|
||||
_GREEN='\033[32m'
|
||||
_YELLOW='\033[33m'
|
||||
_BLUE='\033[34m'
|
||||
_PURPLE='\033[35m'
|
||||
_CYAN='\033[36m'
|
||||
_WHITE='\033[37m'
|
||||
_END='\033[0m'
|
||||
|
||||
|
||||
#test_file_names=("test_template.sh" "test_header.sh" "test_path.sh")
|
||||
test_file_names=("test_method.sh" "test_header.sh" "test_path.sh")
|
||||
#test_file_names=("test_path.sh")
|
||||
|
||||
test_files=()
|
||||
expected_result_files=()
|
||||
|
||||
fill_test_files()
|
||||
{
|
||||
for i in "${test_file_names[@]}"
|
||||
do
|
||||
test_files+=("./Tester/$i")
|
||||
done
|
||||
}
|
||||
|
||||
# needs to be invoked for each test_file!
|
||||
# acutally kinda useless...
|
||||
fill_expected_files()
|
||||
{
|
||||
for i in "${local_expected_test_files[@]}"
|
||||
do
|
||||
expected_result_files+=("./Tester/expected_results/$i")
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
|
||||
test_all()
|
||||
{
|
||||
rm -rf telnet.out
|
||||
|
||||
arg=${1}
|
||||
c=0
|
||||
|
||||
make
|
||||
|
||||
rm -rf telnet.log
|
||||
rm -rf webserv.log
|
||||
rm -rf compare.txt
|
||||
rm -rf expected.txt
|
||||
|
||||
fill_test_files
|
||||
|
||||
for i in "${test_files[@]}"
|
||||
do
|
||||
source $i
|
||||
source telnet_test.sh
|
||||
# echo $host $i
|
||||
source ./Tester/telnet_test.sh
|
||||
|
||||
./webserv $config_file &>> webserv.log &
|
||||
echo -e "${_GREEN}Running Telnet Test on '$test_name'${_END}"
|
||||
sleep 1
|
||||
# echo "$connect_to_telnet"
|
||||
# run | telnet >> telnet.out
|
||||
run | telnet > compare.txt
|
||||
run | telnet | tee compare.txt >> telnet.log
|
||||
# run | telnet > compare.txt >> telnet.log
|
||||
# run | telnet >> telnet.log
|
||||
pkill webserv
|
||||
echo -e "\n\n------\n" &>> webserv.log
|
||||
|
||||
fill_expected_files
|
||||
expected_result_file="./Tester/expected_results/$file"
|
||||
|
||||
# cat compare.txt
|
||||
# cat $expected_result_file
|
||||
DIFF=$(diff -q compare.txt $expected_result_file)
|
||||
if [ "$DIFF" == "" ];
|
||||
if [ "$arg" = "diff" ];
|
||||
then
|
||||
echo "Good diff"
|
||||
else
|
||||
diff compare.txt $expected_result_file
|
||||
DIFF=$(diff -q compare.txt $expected_result_file)
|
||||
if [ "$DIFF" == "" ];
|
||||
then
|
||||
echo "Good diff"
|
||||
else
|
||||
diff compare.txt $expected_result_file
|
||||
fi
|
||||
elif [ "$arg" = "create" ];
|
||||
then
|
||||
if ! test -f $expected_result_file;
|
||||
then
|
||||
cat compare.txt > $expected_result_file
|
||||
fi
|
||||
elif [ "$arg" = "replace" ];
|
||||
then
|
||||
cat compare.txt > $expected_result_file
|
||||
fi
|
||||
|
||||
cat compare.txt >> telnet.out
|
||||
|
||||
|
||||
c+=1
|
||||
|
||||
done
|
||||
|
||||
# if [ "$arg" != "diff" ];
|
||||
# then
|
||||
# cat telnet.log
|
||||
# fi
|
||||
|
||||
|
||||
}
|
||||
|
||||
test_all
|
||||
test_all $1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user