Skip to content

Commit 2254ce6

Browse files
committed
💲
1 parent e63b3b4 commit 2254ce6

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

ctest.sh

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,34 @@ else
4949
if [ -t 1 ]; then echo -e "${BOLDBLUE}Test ${infile:8} ${ENDCOLOR}"
5050
echo -e "${BOLDBLUE}---------- ${ENDCOLOR}"
5151
else echo -e "Test $infile\n---------- "; fi
52-
dif="$(diff "${infile%.*}.out" <(./a.out < "$infile"))"
53-
if [ -n "$dif" ]; then
54-
if [ -t 1 ]; then echo -e "${RED}Test failed.${ENDCOLOR}\nDifference : ${RED}$dif${ENDCOLOR}\n"
55-
else echo -e "FAILED.\nDifference : $dif\n"; fi
52+
outfile="${infile%.*}.out"
53+
if [ ! -f "$outfile" ]; then
54+
echo -e "Test file $outfile not found!\n"
55+
continue
5656
else
57-
if [ -t 1 ]; then echo -e "${GREEN}PASSED!${ENDCOLOR}\n"
58-
else echo -e "PASSED!\n"; fi
59-
PASSED=$((PASSED + 1))
57+
dif="$(diff "${infile%.*}.out" <(./a.out < "$infile"))"
58+
if [ -n "$dif" ]; then
59+
if [ -t 1 ]; then echo -e "${RED}Test failed.${ENDCOLOR}
60+
\nDifference : ${RED}$dif${ENDCOLOR}\n"
61+
else echo -e "FAILED.\nDifference : $dif\n"; fi
62+
else
63+
if [ -t 1 ]; then echo -e "${GREEN}PASSED!${ENDCOLOR}\n"
64+
else echo -e "PASSED!\n"; fi
65+
PASSED=$((PASSED + 1))
66+
fi
6067
fi
6168
done
6269

6370
if [ $PASSED -eq $len ]; then
6471
if [ -t 1 ]; then echo -e "${GREEN}You have passed all tests! \(ᵔᵕᵔ)/${ENDCOLOR}"
6572
else echo "All tests passed!"; fi
6673
elif [ $PASSED -eq $(($len-1)) ]; then
67-
if [ -t 1 ]; then echo -e "${MAGENTA}You have passed $PASSED out of $len tests. Almost there...! (◎_◎)${ENDCOLOR}"
74+
if [ -t 1 ]; then echo -e "${MAGENTA}You have passed $PASSED out of $len tests."
75+
echo -e "Almost there...! (◎_◎)${ENDCOLOR}"
6876
else echo -e "Passed $PASSED out of $len tests."; fi
6977
else
70-
if [ -t 1 ]; then echo -e "${MAGENTA}You have passed $PASSED out of $len tests. (._.)${ENDCOLOR}"
78+
if [ -t 1 ]; then echo -e "${MAGENTA}You have passed $PASSED out of $len tests.
79+
(._.)${ENDCOLOR}"
7180
else echo "Passed $PASSED out of $len tests."; fi
7281
fi
7382
echo

0 commit comments

Comments
 (0)