removed unnecessary code

This commit is contained in:
Filip Bucek 2019-11-06 14:34:55 +01:00
parent 08127bad50
commit b15596b25f
2 changed files with 93 additions and 148 deletions

View File

@ -10,122 +10,96 @@ COVERAGE_DIR=$SOURCE_DIR"/build/testcc-info"
HTML_RESULTS_DIR=$SOURCE_DIR"/build/testcc-html"
COVERAGE_FILTER="*Qt*.framework* *Xcode.app* *.moc *moc_*.cpp */test/* *qrc_* ui_* *qt.headers */build/* *main*.* *c++*"
main() {
info "Getting .pro file"
PRO_FILE=$(ls *.pro)
info "Getting .pro file"
PRO_FILE=$(ls *.pro)
# Ensuring server-sdk wont be filtered out for server-sdk
NAME=$( basename $PWD )
if [ "$NAME" != "server-sdk" ]; then
COVERAGE_FILTER+=" *server-sdk*"
fi
# Ensuring server-sdk wont be filtered out for server-sdk
NAME=$( basename $PWD )
if [ "$NAME" != "server-sdk" ]; then
COVERAGE_FILTER+=" *server-sdk*"
fi
# Ensuring 'src' dir exists
if [ ! -d src ]; then
fail "'src' dir does not exists. ${BLUE}Expecting 'src' dir with c++ source code${NC}"
else
pass "src dir exits"
fi
# Ensuring 'src' dir exists
if [ ! -d src ]; then
fail "'src' dir does not exists. ${BLUE}Expecting 'src' dir with c++ source code${NC}"
else
pass "src dir exits"
fi
# Ensuring PRO_FILE exists
if [ ! -f $PRO_FILE ]; then
fail ".pro file does not exists: " $PRO_FILE
else
pass ".pro file: " $PRO_FILE
fi
# Ensuring PRO_FILE exists
if [ ! -f $PRO_FILE ]; then
fail ".pro file does not exists: " $PRO_FILE
else
pass ".pro file: " $PRO_FILE
fi
info "Creating: $BUILDPATH"
mkdir -p $BUILDPATH
cd $BUILDPATH
info "Generate makefile with coverage option"
qmake $SOURCE_DIR/$PRO_FILE "QMAKE_CXXFLAGS += --coverage" "QMAKE_LFLAGS += --coverage"
info "Creating: $BUILDPATH"
mkdir -p $BUILDPATH
cd $BUILDPATH
info "Remove previous *.gcda files"
find $BUILDPATH -name *.gcda -exec rm "{}" \;
info "Generate makefile with coverage option"
qmake $SOURCE_DIR/$PRO_FILE "QMAKE_CXXFLAGS += --coverage" "QMAKE_LFLAGS += --coverage"
info "Build"
make -j4 # build
info "Remove previous *.gcda files"
find $BUILDPATH -name *.gcda -exec rm "{}" \;
info "Run unittests"
make check test
info "Build"
make -j4 # build
info "Run unittests"
make check test
echo "--------------------"
echo "Source : $SRCDIR"
echo "Build : $BUILDPATH"
echo "Makeflags : $MAKEFLAGS"
echo "COVERAGE_DIR : $COVERAGE_DIR"
echo "SOURCE_DIR : $SOURCE_DIR"
echo "HTML_RESULTS_DIR : $HTML_RESULTS_DIR"
echo "COVERAGE_FILTER : $COVERAGE_FILTER"
echo "--------------------"
echo "--------------------"
echo "Source : $SRCDIR"
echo "Build : $BUILDPATH"
echo "Makeflags : $MAKEFLAGS"
echo "COVERAGE_DIR : $COVERAGE_DIR"
echo "SOURCE_DIR : $SOURCE_DIR"
echo "HTML_RESULTS_DIR : $HTML_RESULTS_DIR"
echo "COVERAGE_FILTER : $COVERAGE_FILTER"
echo "--------------------"
#exit 0
#exit 0
info "Create dummy files to ensure not tested class are acounted"
find $BUILDPATH -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
mkdir -p $COVERAGE_DIR
info "Create dummy files to ensure not tested class are acounted"
find $BUILDPATH -name "*.gcno" -exec sh -c 'touch -a "${1%.gcno}.gcda"' _ {} \;
mkdir -p $COVERAGE_DIR
info "Make dir 'codecoverage' clean"
rm -f $COVERAGE_DIR/*.*
rm -rf $HTML_RESULTS_DIR
info "Make dir 'codecoverage' clean"
rm -f $COVERAGE_DIR/*.*
rm -rf $HTML_RESULTS_DIR
info "Copy .gc?? file from $BUILDPATH into 'codecoverage' dir"
find $BUILDPATH -name *.gc?? -exec cp "{}" $COVERAGE_DIR \;
info "Copy .gc?? file from $BUILDPATH into 'codecoverage' dir"
find $BUILDPATH -name *.gc?? -exec cp "{}" $COVERAGE_DIR \;
##########################
# RUN LCOV
##########################
##########################
# RUN LCOV
##########################
# ${1} is the directory containing the .gcno files (%{PROJBUILD} in Qt Creator)
LCOV=lcov
GENHTML=genhtml
BROWSER="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
info "Generating initial code coverage info report"
cd $BUILDPATH
${LCOV} -d ${BUILDPATH} -c -o ${COVERAGE_DIR}/coverage.info
# ${1} is the directory containing the .gcno files (%{PROJBUILD} in Qt Creator)
LCOV=lcov
GENHTML=genhtml
BROWSER="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
info "Generating initial code coverage info report"
cd $BUILDPATH
${LCOV} -d ${BUILDPATH} -c -o ${COVERAGE_DIR}/coverage.info
info "Filtering code coverage info report"
${LCOV} -r ${COVERAGE_DIR}/coverage.info $COVERAGE_FILTER -o ${COVERAGE_DIR}/coverage-filtered.info
info "Filtering code coverage info report"
${LCOV} -r ${COVERAGE_DIR}/coverage.info $COVERAGE_FILTER -o ${COVERAGE_DIR}/coverage-filtered.info
info "Creating html output"
mkdir -p ${HTML_RESULTS_DIR}
cd $BUILDPATH
"${GENHTML}" -o "${HTML_RESULTS_DIR}" "${COVERAGE_DIR}/coverage-filtered.info"
info "Creating html output"
mkdir -p ${HTML_RESULTS_DIR}
cd $BUILDPATH
"${GENHTML}" -o "${HTML_RESULTS_DIR}" "${COVERAGE_DIR}/coverage-filtered.info"
info "Reseting coverage counts"
"${LCOV}" -d "${COVERAGE_DIR}" -z
info "Reseting coverage counts"
"${LCOV}" -d "${COVERAGE_DIR}" -z
if [ "$1" == "open" ]; then
open "${HTML_RESULTS_DIR}/index.html" &
fi
}
# ################
# Output funcitons
# ################
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
function info () {
echo -e "[${BLUE} $@ ${NC}]"
}
function pass() {
echo -e "[${GREEN}PASS${NC}] $@"
}
function fail() {
FAIL="true"; echo -e "[${RED}FAIL${NC}] $@"
exit
}
# Run main function
main "$@"
if [ "$1" == "open" ]; then
open "${HTML_RESULTS_DIR}/index.html" &
fi

View File

@ -7,58 +7,29 @@ SOURCE_DIR=$PWD
BUILD_DIR=$SOURCE_DIR"/build"
DOC_DIR=$BUILD_DIR"/doc"
main() {
if [ ! -d src ]; then
fail "src dir does not exists"
else
pass "src dir exits"
fi
doc "$@"
}
function doc() {
info "Generation documentation"
mkdir -p $BUILD_DIR
cd $BUILD_DIR
if [ ! -d "m.css" ] ; then
info "Cloning m.css"; git clone git://github.com/mosra/m.css;
fi
cd m.css/documentation
info "Installing jinja2 and Pygments"
pip3 install jinja2 Pygments
info "Generating doxygen"
if [ "$1" == "clean" ]; then rm -fr $DOC_DIR; fi
./doxygen.py --debug $SOURCE_DIR/doc/Doxyfile-mcss
if [ "$1" == "open" ]; then
open $DOC_DIR/html/index.html
fi
}
# ################
# Output funcitons
# ################
RED='\033[0;31m'
GREEN='\033[0;32m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
function info () {
echo -e "[${BLUE} $@ ${NC}]"
}
function pass() {
echo -e "[${GREEN}PASS${NC}] $@"
}
function fail() {
FAIL="true"; echo -e "[${RED}FAIL${NC}] $@"
exit
}
if [ ! -d src ]; then
fail "src dir does not exists"
else
pass "src dir exits"
fi
# Run main function
main "$@"
info "Generation documentation"
mkdir -p $BUILD_DIR
cd $BUILD_DIR
if [ ! -d "m.css" ] ; then
info "Cloning m.css"; git clone git://github.com/mosra/m.css;
fi
cd m.css/documentation
info "Installing jinja2 and Pygments"
pip3 install jinja2 Pygments
info "Generating doxygen"
if [ "$1" == "clean" ]; then rm -fr $DOC_DIR; fi
./doxygen.py --debug $SOURCE_DIR/doc/Doxyfile-mcss
if [ "$1" == "open" ]; then
open $DOC_DIR/html/index.html
fi