-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathcollect-coverage.sh
executable file
·59 lines (48 loc) · 1.54 KB
/
collect-coverage.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
#!/bin/bash
set -u
ferr(){
echo "$@"
exit 1
}
#prepare
project_dir="$(readlink -f .)"
build_dir="$project_dir/build"
echo "project directory $project_dir"
echo "build directory $build_dir"
cd ${project_dir} || ferr "can not enter build dir"
CXX=${CXX:='gcc'}
version=${CXX#*-}
if [[ -n $version ]]; then
version="-$version"
fi
GCOV=gcov${version}
echo "gcov: $GCOV"
LCOV=(
'lcov'
'--directory' "$project_dir"
'--gcov-tool' "$(type -p ${GCOV})"
)
# clear counters
"${LCOV[@]}" --capture --initial --output-file base_coverage.info || ferr "failed lcov"
"${LCOV[@]}" --zerocounters || ferr "failed lcov"
# run tests
(cd "${build_dir}/tests" && ctest -V) || ferr "failed to run tests"
# collect coverage info
"${LCOV[@]}" --capture --output-file test_coverage.info || ferr "failed lcov"
"${LCOV[@]}" --add-tracefile base_coverage.info --add-tracefile test_coverage.info --output-file coverage.info || ferr "failed lcov"
"${LCOV[@]}" --remove coverage.info \
'/usr/*' \
'*CMakeFiles/*' \
"$project_dir"'/examples/*' \
"$project_dir"'/tools/*' \
"$project_dir"'/tests/*' \
"$project_dir"'/include/velocypack/velocypack-wyhash*' \
"$project_dir"'/src/xxhash*' \
"$project_dir"'/src/fasthash*' \
"$project_dir"'/src/powers.h' \
--output-file coverage.info || ferr "failed lcov"
"${LCOV[@]}" --list coverage.info || ferr "failed lcov"
sed -i "s#${project_dir}/##" coverage.info
echo $PWD
ls -lah
echo "Done with lcov"