Skip to content

Commit

Permalink
try to setup coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Dec 21, 2018
1 parent 477e968 commit 38013c0
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,26 @@ SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# global vars
SET (MDAL_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output CACHE PATH "Output base directory")
SET (ENABLE_TESTS TRUE CACHE BOOL "Build tests?")
SET (ENABLE_COVERAGE FALSE CACHE BOOL "Enable GCOV code coverage?")
SET (BUILD_TOOLS TRUE CACHE BOOL "Build tool executables?")
SET (WITH_HDF5 TRUE CACHE BOOL "Build providers that require HDF5")
SET (WITH_GDAL TRUE CACHE BOOL "Build providers that require GDAL (e.g. GRIB)")
SET (WITH_NETCDF TRUE CACHE BOOL "Build providers that require NETCDF (e.g. 3Di)")

#############################################################
# Setup code coverage
IF(ENABLE_COVERAGE)
IF (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
MESSAGE(FATAL_ERROR "gcov coverage must be run in debug build type")
ENDIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")

IF(MSVC)
MESSAGE(FATAL_ERROR "gcov coverage is not implemented for Windows")
ENDIF(MSVC)

SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
ENDIF()

#############################################################
# warnings https://stackoverflow.com/a/3818084/2838364
IF(MSVC)
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
[![CircleCI](https://circleci.com/gh/lutraconsulting/MDAL.svg?style=svg)](https://circleci.com/gh/lutraconsulting/MDAL)
<!-- [<img src="https://my.cdash.org/images/cdash.gif" alt="cdash" width="20"/>](https://my.cdash.org/index.php?project=MDAL) -->

[![Coverage Status](https://coveralls.io/repos/github/lutraconsulting/MDAL/badge.svg?branch=master)](https://coveralls.io/github/lutraconsulting/MDAL?branch=master)

# MDAL
Mesh Data Abstraction Library

Expand Down
9 changes: 9 additions & 0 deletions scripts/ci/linux/build.bash
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,14 @@ if grep -q "Defects:" "memcheck.log"; then
cat /home/travis/build/lutraconsulting/MDAL/build_db_lnx/Testing/Temporary/MemoryChecker.*.log
exit 1
fi
cd ..

echo "Linux code coverage"
mkdir -p build_coverage_lnx
cd build_coverage_lnx
cmake ${CMAKE_OPTIONS} -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON -DENABLE_COVERAGE=ON ..
make
CTEST_TARGET_SYSTEM=Linux-gcc; ctest -VV
coveralls --exclude lib --exclude tests --gcov-options '\-lp'

cd ..
6 changes: 5 additions & 1 deletion scripts/ci/linux/install.bash
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ sudo apt-get install -y libhdf5-dev libnetcdf-dev
sudo apt-get install mingw-w64

# Valgrind
sudo apt-get install libc6-dbg gdb valgrind
sudo apt-get install libc6-dbg gdb valgrind

# Code coverage
sudo apt-get install python-pip
sudo pip install cpp-coveralls

0 comments on commit 38013c0

Please sign in to comment.