-
Notifications
You must be signed in to change notification settings - Fork 9
/
test.sh
executable file
·65 lines (57 loc) · 1022 Bytes
/
test.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
#!/usr/bin/env bash
NODE_BIN="/usr/bin/env node"
FAIL=0
SUCCESS=0
TOTAL=0
cd tests
for TEST in $(ls ./*.js)
do
if [ -f $TEST ]
then
TOTAL=$(($TOTAL + 1))
fi
done
CURRENT=1
for TEST in $(ls ./*.js)
do
if [ -f $TEST ]
then
TEST_FILE=$(basename $TEST .js)
PERCENT=$(echo "$CURRENT / $TOTAL * 100" | bc -l | awk '{printf("%d\n",$1 + 0.5)}')
OUTPUT="\r[$PERCENT% | $CURRENT/$TOTAL | + $SUCCESS | - $FAIL] $TEST_FILE"
echo -ne $OUTPUT
$NODE_BIN $TEST > /dev/null
EXIT_CODE=$?
SPACER=""
for IDX in $(seq 0 ${#OUTPUT})
do
SPACER=" $SPACER"
done
echo -ne "\r$SPACER"
if [ $EXIT_CODE -ne 0 ]
then
echo -e "\n\e[0;31mFailed: $TEST_FILE\e[0m\n"
FAIL=$(($FAIL + 1))
else
SUCCESS=$(($SUCCESS+1))
fi
CURRENT=$(($CURRENT + 1))
fi
done
echo ""
if [ $FAIL -eq 0 ]
then
# green
echo -e "\e[0;32mFailed tests: $FAIL\e[0m"
else
#red
echo -e "\e[0;31mFailed tests: $FAIL\e[0m"
fi
echo -e "\033[1mTotal tests: $TOTAL\033[0m"
echo ""
if [ $FAIL -eq 0 ]
then
exit 0
else
exit 1
fi