From 03f2c464b821edc7790cc49f17d80f0e93ba29b1 Mon Sep 17 00:00:00 2001 From: Geoffrey Hunter Date: Mon, 27 Nov 2017 12:04:39 -0800 Subject: [PATCH] Attempted enabling coverage, but code commented out for now. --- .travis.yml | 5 ++++- test/unit/CMakeLists.txt | 6 ++++++ tools/build.sh | 11 +++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1af22c8..3b2334a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,9 +11,12 @@ addons: - g++-5 - gcc-5 +before_install: + - pip install --user cpp-coveralls + install: - if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi script: - - ./tools/build.sh \ No newline at end of file + - ./tools/build.sh -i \ No newline at end of file diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index fb0aad0..33c2543 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -21,6 +21,12 @@ file(GLOB_RECURSE CppLinuxSerialUnitTests_SRC add_executable(CppLinuxSerialUnitTests ${CppLinuxSerialUnitTests_SRC}) +if(COVERAGE) + message("Coverage enabled.") + target_compile_options(CppLinuxSerialUnitTests PRIVATE --coverage) + target_link_libraries(CppLinuxSerialUnitTests PRIVATE --coverage) +endif() + target_link_libraries(CppLinuxSerialUnitTests LINK_PUBLIC CppLinuxSerial gtest_main ${CMAKE_THREAD_LIBS_INIT}) # The custom target and custom command below allow the unit tests diff --git a/tools/build.sh b/tools/build.sh index 1be0705..33a94e2 100755 --- a/tools/build.sh +++ b/tools/build.sh @@ -27,6 +27,7 @@ set +e # Define the command-line arguments DEFINE_boolean 'install' 'false' 'Do you want to [i]nstall the CppLinuxSerial header files onto your local system after build?' 'i' +DEFINE_boolean 'coverage' 'false' 'Do you want to record test [c]overage metrics?' 'c' # parse the command-line FLAGS "$@" || exit 1 @@ -37,6 +38,7 @@ eval set -- "${FLAGS_ARGV}" set -e printInfo "install = ${FLAGS_install}" +printInfo "coverage = ${FLAGS_coverage}" BUILD_DIRECTORY_NAME="build" @@ -47,8 +49,13 @@ printInfo "Making and/or changing into build directory (${script_dir}/../${BUILD mkdir -p ${script_dir}/../${BUILD_DIRECTORY_NAME}/ cd ${script_dir}/../${BUILD_DIRECTORY_NAME}/ -printInfo 'Invoking cmake...' -cmake .. +if [[ "$FLAGS_coverage" == $FLAGS_TRUE ]]; then + printInfo 'Invoking cmake with -DCOVERAGE=1...' + cmake -DCOVERAGE=1 .. +else + printInfo 'Invoking cmake without -DCOVERAGE=1...' + cmake .. +fi printInfo 'Invoking make...' make -j8 -- libgit2 0.21.4