-
Notifications
You must be signed in to change notification settings - Fork 35
/
test.sh
executable file
·56 lines (50 loc) · 876 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
#!/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)
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=$?
if [ $EXIT_CODE -ne 0 ]
then
echo -e "\nFailed: $TEST_FILE"
FAIL=$(($FAIL + 1))
else
SUCCESS=$(($SUCCESS+1))
fi
SPACER=""
for IDX in $(seq 0 ${#OUTPUT})
do
SPACER=" $SPACER"
done
echo -ne "\r$SPACER"
CURRENT=$(($CURRENT + 1))
fi
done
echo ""
echo "Failed tests: $FAIL"
echo "Total tests: $TOTAL"
echo ""
if [ $FAIL -eq 0 ]
then
exit 0
else
exit 1
fi