Skip to content

Commit

Permalink
Add coverage reports to channelflow (epfl-ecps#8)
Browse files Browse the repository at this point in the history
* Added coverage computation to unit and integration tests

The code is compiled passing '--coverage -g' during the 'Unit and
integration tests' stage. Once tests are run data is processed using
lcov and printed to stdout, if tests succeeded.

* Tests done for coverage are built in debug mode with -Og

* Added summary badges to the README file.

- Build status
- Total coverage
- License
  • Loading branch information
alalazo authored Aug 30, 2018
1 parent d8c56a3 commit b7f9366
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
coverage:
ignore:
- tests/
- bundled/
9 changes: 6 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ jobs:
- ubuntu-toolchain-r-test
- sourceline: 'ppa:likemartinma/devel'
packages:
- lcov
- ccache
- g++-8
- openmpi-bin
- libopenmpi-dev
- libhdf5-dev
Expand All @@ -45,8 +45,8 @@ jobs:
- libeigen3-dev
env:
- CMAKE_PREFIX_PATH=/usr/lib/x86_64-linux-gnu
- OMPI_CC=gcc-8
- OMPI_CXX=g++-8
- OMPI_CC=gcc
- OMPI_CXX=g++
- CPLUS_INCLUDE_PATH=/usr/lib/openmpi/include
script: ./share/qa/unit_and_integration_test.sh

Expand Down Expand Up @@ -171,5 +171,8 @@ jobs:
install:
- ccache -M 2G

after_success:
- if [[ -f "${TRAVIS_BUILD_DIR}/cmake-build-release/Testing/Temporary/LastTest.log" ]] ; then ./share/qa/compute_coverage.sh ; fi

after_failure:
- if [[ -f "${TRAVIS_BUILD_DIR}/cmake-build-release/Testing/Temporary/LastTest.log" ]] ; then cat "${TRAVIS_BUILD_DIR}/cmake-build-release/Testing/Temporary/LastTest.log" ; fi
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[![Build Status](https://travis-ci.com/epfl-ecps/channelflow.svg?branch=master)](https://travis-ci.com/epfl-ecps/channelflow)
[![codecov](https://codecov.io/gh/epfl-ecps/channelflow/branch/master/graph/badge.svg)](https://codecov.io/gh/epfl-ecps/channelflow)
[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)

# Channelflow Project

Channelflow is a software system for numerical analysis of the incompressible fluid flow in
Expand Down
17 changes: 17 additions & 0 deletions share/qa/compute_coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash -e

if [[ "${OMPI_CC}" == "gcc" ]]
then
# Go to the build directory and compute coverage
cd ${TRAVIS_BUILD_DIR}/cmake-build-release
lcov --version
echo $PWD
lcov --rc lcov_branch_coverage=1 --directory . --capture --output-file coverage.info
lcov --rc lcov_branch_coverage=1 --remove coverage.info '/*tests/*' --output-file coverage.info
lcov --rc lcov_branch_coverage=1 --remove coverage.info '/*/bundled/*' --output-file coverage.info
lcov --rc lcov_branch_coverage=1 --remove coverage.info '/usr/*' --output-file coverage.info
lcov --rc lcov_branch_coverage=1 --list coverage.info

# Upload to codecov website
bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
fi
12 changes: 10 additions & 2 deletions share/qa/unit_and_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@
ccache -V
ccache -z

# Parallel build in Release mode
mkdir ${TRAVIS_BUILD_DIR}/cmake-build-release && cd ${TRAVIS_BUILD_DIR}/cmake-build-release
CC="ccache mpicc" CXX="ccache mpicxx" cmake -DCMAKE_BUILD_TYPE:STRING=Release -DWITH_HDF5CXX:BOOL=ON -DWITH_PYTHON:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON -DWITH_NSOLVER:BOOL=ON -DWITH_NETCDF:STRING=Serial ${TRAVIS_BUILD_DIR}
# Tests done for coverage are built in debug mode, to hit assertions.
# We use -Og not to slow down excessively the executables and tests
if [[ "${OMPI_CC}" == "gcc" ]]
then
# Parallel build in Release mode
CXXFLAGS="--coverage -ggdb3 -Og" CC="ccache mpicc" CXX="ccache mpicxx" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=Debug -DWITH_HDF5CXX:BOOL=ON -DWITH_PYTHON:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON -DWITH_NSOLVER:BOOL=ON -DWITH_NETCDF:STRING=Serial ${TRAVIS_BUILD_DIR}
else
# Parallel build in Release mode
CC="ccache mpicc" CXX="ccache mpicxx" cmake -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=Release -DWITH_HDF5CXX:BOOL=ON -DWITH_PYTHON:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON -DWITH_NSOLVER:BOOL=ON -DWITH_NETCDF:STRING=Serial ${TRAVIS_BUILD_DIR}
fi
make -j 4

# Print ccache statistics
Expand Down

0 comments on commit b7f9366

Please sign in to comment.