-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2.2.7: - report covergae on sonarcloud (#203) - fixed some code smells (#128) - fixed bugs: #129, #130, #31, #134, #135
- Loading branch information
Showing
17 changed files
with
227 additions
and
67 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env bash | ||
|
||
# does actual build. | ||
# | ||
cmake_build(){ | ||
|
||
echo "cd cmake-build && cmake $cmake_args .. && make $make_args " | ||
[ -d cmake-build ] && ( cd cmake-build && cmake $cmake_args .. && make $make_args ) | ||
|
||
} | ||
|
||
# build command usage message | ||
# | ||
usage(){ | ||
echo "usage: `basename $0` [-G] [-S] [-T <build_type>]" | ||
echo | ||
echo "Build this module." | ||
echo | ||
echo "-S setup things to run SONAR" | ||
echo "-G setup things to compile with coverage options and libs" | ||
echo "-T build type (Release, Debug, ...)" | ||
echo | ||
|
||
exit 99 | ||
} | ||
|
||
set_current_branch(){ | ||
if [ -z "$TRAVIS_BRANCH" ] | ||
then | ||
current_branch=`git rev-parse --abbrev-ref HEAD -- | head -1` | ||
else | ||
if [ -z "$TRAVIS_TAG" ] | ||
then | ||
[ -z "$TRAVIS_PULL_REQUEST_BRANCH" ] && current_branch=$TRAVIS_BRANCH || current_branch=$TRAVIS_PULL_REQUEST_BRANCH | ||
else | ||
current_branch="master" | ||
fi | ||
fi | ||
} | ||
|
||
set_current_branch | ||
|
||
if [ "$current_branch" == "master" ] | ||
then | ||
cmake_build_type="-DCMAKE_BUILD_TYPE=Release" | ||
else | ||
cmake_build_type="-DCMAKE_BUILD_TYPE=Debug" | ||
fi | ||
|
||
make_args="all test" | ||
|
||
while getopts "SGT:" option | ||
do | ||
case $option in | ||
S) cmake_sonar_option="-DSONAR=yes" ; cmake_gcov_option="-DCOVERAGE=yes" ; make_args="code-quality";; | ||
G) cmake_gcov_option="-DCOVERAGE=yes" ; make_args="$make_args coverage";; | ||
T) cmake_build_type="-DCMAKE_BUILD_TYPE=$OPTARG" ;; | ||
*) usage ;; # display usage and exit | ||
esac | ||
done | ||
|
||
cmake_args="$cmake_build_type $cmake_gcov_option $cmake_sonar_option" | ||
|
||
echo "##############################################################################" | ||
echo "#" | ||
[ ! -z "$TRAVIS_BRANCH" ] && echo -e "# Running on Travis (TRAVIS_BRANCH: $TRAVIS_BRANCH, TRAVIS_TAG: $TRAVIS_TAG, TRAVIS_PULL_REQUEST_BRANCH: $TRAVIS_PULL_REQUEST_BRANCH)\n#" | ||
echo "# Project: cpp-pthread" | ||
echo "# Build date: `date`" | ||
echo "# Build directory: cmake-build" | ||
echo "# Build options: $cmake_args" | ||
echo "# GIT current branch: [$current_branch]" | ||
echo "#" | ||
echo "##############################################################################" | ||
|
||
[ -d cmake-build ] && (rm -Rf cmake-build/* && cmake_build ) || ( mkdir cmake-build && cmake_build ) | ||
|
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
option(COVERAGE "Activate coverage") | ||
|
||
if (COVERAGE) | ||
|
||
# Handle coverage with GNU compilers | ||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") | ||
message(STATUS "Detecting LCOV") | ||
find_program(LCOV lcov) | ||
if ( LCOV ) | ||
|
||
message(STATUS "Detecting LCOV [${LCOV}] - done") | ||
add_custom_target( coverage | ||
COMMAND ${CMAKE_CURRENT_LIST_DIR}/LCOV | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} | ||
COMMENT "Coverage report (${CMAKE_CURRENT_LIST_DIR}/LCOV)" | ||
VERBATIM | ||
) | ||
message(STATUS "Added custom build target [coverage]...") | ||
|
||
endif() | ||
|
||
message(STATUS "Setting GCOV --coverage compiler option") | ||
add_compile_options(--coverage) | ||
if (CMAKE_VERSION VERSION_GREATER "3.13.5") | ||
message(STATUS "Setting GCOV --coverage linker option") | ||
add_link_options(--coverage) | ||
else () | ||
message(STATUS "Setting GCOV --coverage option in linker related variables CMAKE_EXE_LINKER_FLAGS and CMAKE_SHARED_LINKER_FLAGS") | ||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") | ||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") | ||
endif () | ||
endif () | ||
endif () |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env sh | ||
|
||
# author: herbert koelman | ||
# | ||
# This shell script makes sure to handle only files that have produced coverage data. It comes with the | ||
# SonarConfig.cmake module | ||
# | ||
|
||
for source_gcda_file in $(find ./ -type f -name "*.gcda") | ||
do | ||
source_file=`basename $source_gcda_file .gcda` | ||
source_dir=`dirname $source_gcda_file` | ||
source_gcno_file=$source_dir/$source_file.gcno | ||
|
||
echo "Handling file [$source_gcno_file]------------------------" | ||
[ -f $source_gcno_file ] && gcov -m $source_gcno_file | ||
echo "Done -----------------------------------------------------" | ||
echo | ||
done |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#8/usr/bin/env bash | ||
|
||
initialize_coverage_file="" | ||
|
||
for directory in $(find ./ -type f -name "*.gcda" -exec dirname {} \; | sort -u) | ||
do | ||
echo "Handling directory [$directory]" | ||
|
||
if [ "${initialize_coverage_file}" == "" ] | ||
then | ||
echo "Initializing [coverage.info] file" | ||
lcov --quiet --directory $directory --capture --output-file coverage.info | ||
initialize_coverage_file="`date`" | ||
else | ||
coverage_info=$(mktemp --suffix=.coverage) | ||
lcov --quiet --directory $directory --capture --output-file $coverage_info | ||
echo "Adding tracefile [$coverage_info] to [coverage.info]" | ||
lcov --quiet --add-tracefile $coverage_info --add-tracefile coverage.info --output-file coverage.info | ||
fi | ||
done | ||
lcov --quiet --remove coverage.info '/usr/*' --output-file coverage.info | ||
lcov --quiet --remove coverage.info '*/googletest/*' --output-file coverage.info | ||
lcov --list coverage.info |
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
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
Oops, something went wrong.