-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·74 lines (62 loc) · 1.45 KB
/
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
66
67
68
69
70
71
72
73
74
#! /bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ ! -f $DIR/test.env ]] ; then
echo "Please create $DIR/test.env and add required ENV variables"
echo "HLC_SESSION_SECRET"
echo "HLC_SESSION_KEY_USER"
echo "HLC_SESSION_KEY_SID"
exit 1
fi
source $DIR/test.env
TESTDIR=$DIR/build/test
export HLC_ROOT=$TESTDIR
OPTION=$1
echo "TEST DIR: $TESTDIR"
mkdir -p $TESTDIR
rm -rf $TESTDIR/db
cp -r $DIR/db $TESTDIR/
RED=`tput setaf 1`
GREEN=`tput setaf 2`
YELLOW=`tput setaf 3`
RESET=`tput sgr0`
White='\033[0;37m'
GREY='\033[1;30m'
TEST_RESULT=$TESTDIR/test_result
./test_setup.sh 1
suc=0
for d in */ ; do
tc=${d%/}
pushd $tc > /dev/null
go test $OPTION --ldflags -s -o $TESTDIR/$tc.test ../$tc > $TEST_RESULT 2>&1
ret=$?
popd > /dev/null
input="$TEST_RESULT"
while IFS= read -r msg
do
if [[ $msg != *"can't load package"* ]]; then
color=$GREY
if [[ $msg == *"---"* ]]; then
if [[ $msg != *"--- PASS"* ]]; then
color=$RED
suc=1
else
color="${RESET}$GREY$GREEN"
fi
fi
if [[ $msg == "?"* ]]; then
color=$YELLOW
elif [[ $msg == "ok"* ]]; then
color="${RESET}$GREEN"
elif [[ $msg == *"FAIL"* || $msg == *"should"* ]]; then
color=$RED
suc=1
fi
echo -e "${color}$msg"
else
break
fi
done < "$input"
done
./test_setup.sh 2
rm $TEST_RESULT
exit $suc