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 | 11 | - g++-5 |
| 12 | 12 | - gcc-5 |
| 13 | 13 | |
| 14 | +before_install: | |
| 15 | + - pip install --user cpp-coveralls | |
| 16 | + | |
| 14 | 17 | install: |
| 15 | 18 | - if [ "$CXX" = "g++" ]; then export CXX="g++-5" CC="gcc-5"; fi |
| 16 | 19 | - if [ "$CXX" = "clang++" ]; then export CXX="clang++-3.7" CC="clang-3.7"; fi |
| 17 | 20 | |
| 18 | 21 | script: |
| 19 | - - ./tools/build.sh | |
| 20 | 22 | \ No newline at end of file |
| 23 | + - ./tools/build.sh -i | |
| 21 | 24 | \ No newline at end of file | ... | ... |
test/unit/CMakeLists.txt
| ... | ... | @@ -21,6 +21,12 @@ file(GLOB_RECURSE CppLinuxSerialUnitTests_SRC |
| 21 | 21 | |
| 22 | 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 | 30 | target_link_libraries(CppLinuxSerialUnitTests LINK_PUBLIC CppLinuxSerial gtest_main ${CMAKE_THREAD_LIBS_INIT}) |
| 25 | 31 | |
| 26 | 32 | # The custom target and custom command below allow the unit tests | ... | ... |
tools/build.sh
| ... | ... | @@ -27,6 +27,7 @@ set +e |
| 27 | 27 | |
| 28 | 28 | # Define the command-line arguments |
| 29 | 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 | 32 | # parse the command-line |
| 32 | 33 | FLAGS "$@" || exit 1 |
| ... | ... | @@ -37,6 +38,7 @@ eval set -- "${FLAGS_ARGV}" |
| 37 | 38 | set -e |
| 38 | 39 | |
| 39 | 40 | printInfo "install = ${FLAGS_install}" |
| 41 | +printInfo "coverage = ${FLAGS_coverage}" | |
| 40 | 42 | |
| 41 | 43 | BUILD_DIRECTORY_NAME="build" |
| 42 | 44 | |
| ... | ... | @@ -47,8 +49,13 @@ printInfo "Making and/or changing into build directory (${script_dir}/../${BUILD |
| 47 | 49 | mkdir -p ${script_dir}/../${BUILD_DIRECTORY_NAME}/ |
| 48 | 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 | 60 | printInfo 'Invoking make...' |
| 54 | 61 | make -j8 | ... | ... |