Created
December 27, 2014 23:29
-
-
Save dkorolev/a3b3a414ca70d3d51d80 to your computer and use it in GitHub Desktop.
coverage-report.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Generates code coverage report using gcov/geninfo/genhtml for each .cc file in current directory. | |
set -u -e | |
CPPFLAGS="-std=c++11 -g -Wall -W -fprofile-arcs -ftest-coverage" | |
LDFLAGS="-pthread" | |
TMPDIR=tmp | |
mkdir -p $TMPDIR | |
for i in *.cc ; do | |
echo -e "\033[0m\033[1m$i\033[0m: \033[33mGenerating coverage report.\033[0m" | |
BINARY=${i%".cc"} | |
rm -rf $TMPDIR/coverage/$BINARY | |
mkdir -p $TMPDIR/coverage/$BINARY | |
g++ $CPPFLAGS $i -o $TMPDIR/coverage/$BINARY/binary $LDFLAGS | |
./$TMPDIR/coverage/$BINARY/binary || exit 1 | |
gcov $i >/dev/null | |
geninfo . --output-file coverage.info >/dev/null | |
genhtml coverage.info --output-directory $TMPDIR/coverage/$BINARY >/dev/null | |
rm -rf coverage.info *.gcov *.gcda *.gcno | |
echo -e -n "\033[0m\033[1m$i\033[0m: \033[36m" | |
echo $PWD/$TMPDIR/coverage/$BINARY/$PWD/index.html | |
echo -e -n "\033[0m" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment