Commit 03f2c464b821edc7790cc49f17d80f0e93ba29b1
1 parent
07392999
Attempted enabling coverage, but code commented out for now.
Showing
3 changed files
with
19 additions
and
3 deletions
.travis.yml
| @@ -11,9 +11,12 @@ addons: | @@ -11,9 +11,12 @@ addons: | ||
| 11 | - g++-5 | 11 | - g++-5 |
| 12 | - gcc-5 | 12 | - gcc-5 |
| 13 | 13 | ||
| 14 | +before_install: | ||
| 15 | + - pip install --user cpp-coveralls | ||
| 16 | + | ||
| 14 | install: | 17 | install: |
| 15 | - if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi | 18 | - if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi |
| 16 | - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi | 19 | - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi |
| 17 | 20 | ||
| 18 | script: | 21 | script: |
| 19 | - - ./tools/build.sh | ||
| 20 | \ No newline at end of file | 22 | \ No newline at end of file |
| 23 | + - ./tools/build.sh -i | ||
| 21 | \ No newline at end of file | 24 | \ No newline at end of file |
test/unit/CMakeLists.txt
| @@ -21,6 +21,12 @@ file(GLOB_RECURSE CppLinuxSerialUnitTests_SRC | @@ -21,6 +21,12 @@ file(GLOB_RECURSE CppLinuxSerialUnitTests_SRC | ||
| 21 | 21 | ||
| 22 | add_executable(CppLinuxSerialUnitTests ${CppLinuxSerialUnitTests_SRC}) | 22 | add_executable(CppLinuxSerialUnitTests ${CppLinuxSerialUnitTests_SRC}) |
| 23 | 23 | ||
| 24 | +if(COVERAGE) | ||
| 25 | + message("Coverage enabled.") | ||
| 26 | + target_compile_options(CppLinuxSerialUnitTests PRIVATE --coverage) | ||
| 27 | + target_link_libraries(CppLinuxSerialUnitTests PRIVATE --coverage) | ||
| 28 | +endif() | ||
| 29 | + | ||
| 24 | target_link_libraries(CppLinuxSerialUnitTests LINK_PUBLIC CppLinuxSerial gtest_main ${CMAKE_THREAD_LIBS_INIT}) | 30 | target_link_libraries(CppLinuxSerialUnitTests LINK_PUBLIC CppLinuxSerial gtest_main ${CMAKE_THREAD_LIBS_INIT}) |
| 25 | 31 | ||
| 26 | # The custom target and custom command below allow the unit tests | 32 | # The custom target and custom command below allow the unit tests |
tools/build.sh
| @@ -27,6 +27,7 @@ set +e | @@ -27,6 +27,7 @@ set +e | ||
| 27 | 27 | ||
| 28 | # Define the command-line arguments | 28 | # Define the command-line arguments |
| 29 | DEFINE_boolean 'install' 'false' 'Do you want to [i]nstall the CppLinuxSerial header files onto your local system after build?' 'i' | 29 | DEFINE_boolean 'install' 'false' 'Do you want to [i]nstall the CppLinuxSerial header files onto your local system after build?' 'i' |
| 30 | +DEFINE_boolean 'coverage' 'false' 'Do you want to record test [c]overage metrics?' 'c' | ||
| 30 | 31 | ||
| 31 | # parse the command-line | 32 | # parse the command-line |
| 32 | FLAGS "$@" || exit 1 | 33 | FLAGS "$@" || exit 1 |
| @@ -37,6 +38,7 @@ eval set -- "${FLAGS_ARGV}" | @@ -37,6 +38,7 @@ eval set -- "${FLAGS_ARGV}" | ||
| 37 | set -e | 38 | set -e |
| 38 | 39 | ||
| 39 | printInfo "install = ${FLAGS_install}" | 40 | printInfo "install = ${FLAGS_install}" |
| 41 | +printInfo "coverage = ${FLAGS_coverage}" | ||
| 40 | 42 | ||
| 41 | BUILD_DIRECTORY_NAME="build" | 43 | BUILD_DIRECTORY_NAME="build" |
| 42 | 44 | ||
| @@ -47,8 +49,13 @@ printInfo "Making and/or changing into build directory (${script_dir}/../${BUILD | @@ -47,8 +49,13 @@ printInfo "Making and/or changing into build directory (${script_dir}/../${BUILD | ||
| 47 | mkdir -p ${script_dir}/../${BUILD_DIRECTORY_NAME}/ | 49 | mkdir -p ${script_dir}/../${BUILD_DIRECTORY_NAME}/ |
| 48 | cd ${script_dir}/../${BUILD_DIRECTORY_NAME}/ | 50 | cd ${script_dir}/../${BUILD_DIRECTORY_NAME}/ |
| 49 | 51 | ||
| 50 | -printInfo 'Invoking cmake...' | ||
| 51 | -cmake .. | 52 | +if [[ "$FLAGS_coverage" == $FLAGS_TRUE ]]; then |
| 53 | + printInfo 'Invoking cmake with -DCOVERAGE=1...' | ||
| 54 | + cmake -DCOVERAGE=1 .. | ||
| 55 | +else | ||
| 56 | + printInfo 'Invoking cmake without -DCOVERAGE=1...' | ||
| 57 | + cmake .. | ||
| 58 | +fi | ||
| 52 | 59 | ||
| 53 | printInfo 'Invoking make...' | 60 | printInfo 'Invoking make...' |
| 54 | make -j8 | 61 | make -j8 |