-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathruntest.sh
executable file
·100 lines (98 loc) · 4.24 KB
/
runtest.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
rm diff.txt &> /dev/null
rm -rf results
mkdir results
gcc -Wall -Werror -Wextra -w srcs/main_tester.c -D PRINT="printf" -o printf.out # &> /dev/null
./printf.out >> results/expected_result.txt
make -C srcs/
./srcs/tester.out >> results/test_result.txt
cp srcs/main_tester.c srcs/main_test_list.c
sed -i -e "s/PRINT(\" --- Return : %d\\\n\", /B/g" srcs/main_test_list.c
sed -i -e "s/));/);/g" srcs/main_test_list.c
gcc -Wall -Werror -Wextra -w srcs/main_test_list.c -D PRINT="printf" -o printf.out # &> /dev/null
./printf.out >> results/test_list.txt
echo ""
echo "============================================================================================================================================================="
echo "========================================================================= FT_PRINTF ========================================================================="
echo "============================================================================================================================================================="
echo ""
i=1
k=0
sed -n ${i}p results/expected_result.txt >> printf.txt
if [ -s results/test_result.txt ] ; then
while [ -s printf.txt ]
do
rm -f printf.txt ft.txt printf_r.txt ft_r.txt
sed -n ${i}p results/expected_result.txt >> printf.txt
sed -n ${i}p results/test_result.txt >> ft.txt
if [ $i -lt 10 ] ; then
echo -n "Test $i :"
elif [ $i -lt 100 ] ; then
echo -n "Test $i :"
else
echo -n "Test $i :"
fi
DIFF=$(diff ft.txt printf.txt)
if [ "$DIFF" == "" ] ; then
echo -ne "\033[0;32m \xE2\x9C\x94 \033[0m"
let "k += 1"
else
echo -ne "\033[0;31m x \033[0m"
echo "----------Test $i : ----------" >> diff.txt
sed -n ${i}p results/test_list.txt >> diff.txt
echo >> diff.txt
echo "$DIFF" >> diff.txt
echo >> diff.txt
fi
let "j = $i % 10"
if [ $j -eq 0 ] ; then
echo
fi
let "i += 1"
done
echo
echo
let "i -= 1"
if [ $i -eq $k ] ; then
echo -ne "
_ _
/ \_______ /|_\\
/ /_/ \__
/ \_/ /
_|_ |/|_
_|_ O _ O _|_
_|_ (_) _|_ \033[0;32m $k / $i : Well done ! \033[0m
\ /
_\_____________/_
/ \/ (___) \/ \\
\__( o o )__/ "
else
echo -ne "░░░░░▄▄▄▄▀▀▀▀▀▀▀▀▄▄▄▄▄▄░░░░░░░
░░░░░█░░░░▒▒▒▒▒▒▒▒▒▒▒▒░░▀▀▄░░░░
░░░░█░░░▒▒▒▒▒▒░░░░░░░░▒▒▒░░█░░░
░░░█░░░░░░▄██▀▄▄░░░░░▄▄▄░░░░█░░
░▄▀▒▄▄▄▒░█▀▀▀▀▄▄█░░░██▄▄█░░░░█░
█░▒█▒▄░▀▄▄▄▀░░░░░░░░█░░░▒▒▒▒▒░█
█░▒█░█▀▄▄░░░░░█▀░░░░▀▄░░▄▀▀▀▄▒█
░█░▀▄░█▄░█▀▄▄░▀░▀▀░▄▄▀░░░░█░░█░
░░█░░░▀▄▀█▄▄░█▀▀▀▄▄▄▄▀▀█▀██░█░░
░░░█░░░░██░░▀█▄▄▄█▄▄█▄████░█░░░
░░░░█░░░░▀▀▄░█░░░█░█▀██████░█░░ \033[0;31m $k / $i : Try Again ! \033[0m
░░░░░▀▄░░░░░▀▀▄▄▄█▄█▄█▄█▄▀░░█░░
░░░░░░░▀▄▄░▒▒▒▒░░░░░░░░░░▒░░░█░
░░░░░░░░░░▀▀▄▄░▒▒▒▒▒▒▒▒▒▒░░░░█░
░░░░░░░░░░░░░░▀▄▄▄▄▄░░░░░░░░█░░"
fi
echo
echo
echo
else
echo -e "\033[0;31m \xEA\x93\xA5 \xEA\x93\xA5 \033[0m"
echo -ne "\033[4;31m/!\\"
echo -ne "\033[0m\033[0;31m Does Not Compile \033[0m"
echo -e "\033[4;31m/!\\"
echo
echo
fi
rm -rf results printf.txt ft.txt test.txt printf.out srcs/main_test_list.c srcs/main_test_list.c-e &> /dev/null
make -C srcs/ fclean &> /dev/null