-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfull_test.sh
More file actions
executable file
·95 lines (84 loc) · 2.37 KB
/
full_test.sh
File metadata and controls
executable file
·95 lines (84 loc) · 2.37 KB
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
#!/bin/bash
TESTDIR='./test'
# colors
BW='\x1b[37;1m' # bold white
BR='\x1b[31;1m' # bold red
BG='\x1b[32;1m' # bold red
NC='\x1b[37;0m' # no color
FILTER="*" # default test filter
STYLECHECK=true
while [[ $# > 0 ]]; do
key="$1"
case $key in
-f|--filter)
FILTER="$2"
shift
;;
-n|--nostylecheck)
STYLECHECK=false
;;
*)
# unknown option
;;
esac
shift
done
cwd=${PWD##*/}
if [ "$cwd" != "codebook" ]; then
echo -e "${BR}Run from root directory of this project!${NC}"
exit 1
fi
echo -e "${BW}Looking for tests ... ${NC}"
for filename in $(find -regex '\./implementacija/\([^/]+/\)+[^.][^/]+\.\(h\)')
do
if [[ "$filename" == *_util.h ]]; then continue; fi
testname="$(dirname $filename)/$(basename $filename .h)_test.cpp"
if [ ! -f $testname ]; then
echo -e "${BR}Filename: ${NC}$filename${BR} does not have a test!"
echo -e "Make sure file ${NC}$testname${BR} exists!${NC}"
exit 2
fi
done
cd $TESTDIR # CWD CHANGES
if [ $? -ne 0 ]; then
echo -e "${BR}Error: couldnt access ${TESTDIR}!${NC}"
exit 3
fi
echo -e "${BW}Compiling tests ...${NC}"
make all -j8 > /dev/null # your number of processors in j8
if [ $? -ne 0 ]; then
echo -e "${BR}Error: compilation failed!.${NC}"
exit 4
fi
echo -e "${BW}Running tests ...${NC}"
./run_tests --gtest_filter="$FILTER"
if [ $? -ne 0 ]; then
echo -e "${BR}Error: there are failed tests!${NC}"
exit 5
fi
STYLEFILTERS="-legal,-build/include,-runtime/reference,-runtime/threadsafe_fn, \
-runtime/explicit,-readability/streams,-whitespace/empty_loop_body"
if [ "$STYLECHECK" = "true" ]; then
echo -e "${BW}Checking code style ...${NC}"
cd ..
ERRORCODE=0
for filename in $(find -regex '\./implementacija/\([^/]+/\)+[^.][^/]+\.\(cpp\|cc\|c\|h\)')
do
dir=`mktemp -d`
python2 "test/cpplint.py" "--filter=$STYLEFILTERS" \
"--linelength=100" \
"$filename" 2> "$dir/out"
exit_code=$?
if [ $exit_code -ne 0 ]; then
cat "$dir/out"
fi
rm -r $dir
ERRORCODE=$(($ERRORCODE+$exit_code))
done
if [ $ERRORCODE -ne 0 ]; then
echo -e "${BR}Error: there were sytle mistakes!${NC}"
echo "(If you feel errors are unjust, edit this file and add exceptions (ln. 78).)"
exit 6
fi
fi
echo -e "${BG}Done! All looks great!${NC}"