Last active
July 19, 2017 03:39
-
-
Save brandonsoto/a450c644e6b1e5a64180158858595df4 to your computer and use it in GitHub Desktop.
file that will generate test coverage for a given test
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 | |
# variables | |
PROJECT_BUILD_DIR=/vagrant/project/cmake-debug-build | |
DEVTOOLSET_DIR=/opt/rh/devtoolset-3 | |
OUTPUT_DIR=/$HOME/html-out | |
TARGET=$1 | |
TRACEFILE=$TARGET.info.cleaned | |
echo -e "Creating coverage for target \e[1m\"$1\"\e[0m..." | |
# ensure arg count is 1 | |
if [ $# -ne 1 ] | |
then | |
echo -e "\e[31mCould not create coverage because of invalid arg count - $#\e[0m" | |
echo -e "\e[31mPlease pass the target to generate coverage on.\e[0m" | |
exit 1 | |
fi | |
# check if project directory exists | |
if [ ! -d $PROJECT_BUILD_DIR ] | |
then | |
echo -e "\e[31mProject directory does not exist. Please create it and try again\e[0m" | |
echo -e "\e[31mExpected project directory = $PROJECT_BUILD_DIR\e[0m" | |
exit 1 | |
fi | |
# check if devtoolset exists | |
if [ ! -x $DEVTOOLSET_DIR/enable ] | |
then | |
echo -e "\e[31mDevtoolset does not exist or is not in expected location.\e[0m" | |
echo -e "\e[31mExpected devtoolset location = $DEVTOOLSET_DIR\e[0m" | |
exit 1 | |
fi | |
source $DEVTOOLSET_DIR/enable | |
# show c++ compiler | |
echo "c++ compiler: $(which g++)" | |
# build target and generate coverage | |
# TODO: should we generate makefile if it doesn't exist? | |
cd $PROJECT_BUILD_DIR | |
if make --jobs=8 $TARGET && genhtml --output-directory $OUTPUT_DIR $TRACEFILE | |
then | |
echo -e "\e[32mSuccessfully created coverage for \e[1m\"$TARGET\"\e[0m" | |
else | |
echo -e "\e[31mFailed to created coverage for \e[1m\"$TARGET\"\e[0m" | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
💡 Should allow
$1
(the target) to be defaulted toall