Skip to content

Commit

Permalink
Enable code coverage (#188)
Browse files Browse the repository at this point in the history
* add codecoverage

* minor change

* use xml instead of html

* add include folder

* add newer gcc compiler

* use g++-5

* back to default compiler

* Add all tests

* add no inline

* test fix

* Revert and add badge

This reverts commit 913ec2a.
  • Loading branch information
vaithak authored Oct 18, 2021
1 parent af5e2a0 commit f8ba770
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 25 deletions.
11 changes: 8 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@
# Copyright (c) 2012-2018 Vissarion Fisikopoulos
# Licensed under GNU LGPL.3, see LICENCE file

version: 2
version: 2.1
orbs:
codecov: codecov/[email protected]
jobs:
build:
machine:
Expand All @@ -52,10 +54,13 @@ jobs:
- checkout
- run:
sudo apt-get update || true;
sudo apt-get install cmake lp-solve;
sudo apt-get install cmake lp-solve gcovr;
rm -rf build;
mkdir build;
cd build;
cmake -DDISABLE_NLP_ORACLES=ON -DUSE_MKL=OFF ../test;
cmake -DDISABLE_NLP_ORACLES=ON -DUSE_MKL=OFF -DCODE_COVERAGE=ON ../test;
make;
ctest -j8 --verbose;
gcovr -r ../include . --xml -o coverage.xml;
- codecov/upload:
file: './build/coverage.xml'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
[![CircleCI develop](https://circleci.com/gh/GeomScale/volesti/tree/develop.svg?style=shield)](https://circleci.com/gh/GeomScale/volesti/tree/develop)
[![gcc-test](https://github.com/GeomScale/volesti/workflows/gcc-test/badge.svg)](https://github.com/GeomScale/volesti/actions?query=workflow%3Agcc-test)
[![clang-test](https://github.com/GeomScale/volesti/workflows/clang-test/badge.svg)](https://github.com/GeomScale/volesti/actions?query=workflow%3Aclang-test)
[![codecov](https://codecov.io/gh/GeomScale/volesti/branch/develop/graph/badge.svg)](https://codecov.io/gh/GeomScale/volesti)

[![R-CMD-ubuntu](https://github.com/GeomScale/volesti/workflows/R-CMD-check-ubuntu/badge.svg)](https://github.com/GeomScale/volesti/actions?query=workflow%3AR-CMD-ubuntu)
[![R-CMD-macOS](https://github.com/GeomScale/volesti/workflows/R-CMD-check-macOS/badge.svg)](https://github.com/GeomScale/volesti/actions?query=workflow%3AR-CMD-macOS)
Expand Down
62 changes: 40 additions & 22 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,24 @@ GetBoost()
include("LPSolve.cmake")
GetLPSolve()

# Code Coverage Configuration
add_library(coverage_config INTERFACE)

option(CODE_COVERAGE "Enable coverage reporting" OFF)
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Add required flags (GCC & LLVM/Clang)
target_compile_options(coverage_config INTERFACE
-O1 # O0 (or no) optimization takes too much time and causes CircleCI test failure.
-g # generate debug info
--coverage # sets all required flags
)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
target_link_options(coverage_config INTERFACE --coverage)
else()
target_link_libraries(coverage_config INTERFACE --coverage)
endif()
endif(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")

find_library(LP_SOLVE NAMES liblpsolve55.so liblpsolve55.dylib PATHS /usr/lib/lp_solve /usr/local/lib)

if (NOT LP_SOLVE)
Expand Down Expand Up @@ -287,33 +305,33 @@ else ()
add_test(NAME order_polytope_reflection COMMAND order_polytope -tc=reflection)
add_test(NAME order_polytope_vec_mult COMMAND order_polytope -tc=vec_mult)

TARGET_LINK_LIBRARIES(new_volume_example ${LP_SOLVE})
TARGET_LINK_LIBRARIES(volume_sob_hpolytope ${LP_SOLVE})
TARGET_LINK_LIBRARIES(volume_sob_vpolytope ${LP_SOLVE})
TARGET_LINK_LIBRARIES(volume_cg_hpolytope ${LP_SOLVE})
TARGET_LINK_LIBRARIES(volume_cg_vpolytope ${LP_SOLVE})
TARGET_LINK_LIBRARIES(volume_cb_hpolytope ${LP_SOLVE})
TARGET_LINK_LIBRARIES(volume_cb_vpolytope ${LP_SOLVE})
TARGET_LINK_LIBRARIES(volume_cb_zonotopes ${LP_SOLVE})
TARGET_LINK_LIBRARIES(volume_cb_vpoly_intersection_vpoly ${LP_SOLVE})
TARGET_LINK_LIBRARIES(new_rounding_test ${LP_SOLVE})
TARGET_LINK_LIBRARIES(max_ellipsoid_rounding_test ${LP_SOLVE})
TARGET_LINK_LIBRARIES(mcmc_diagnostics_test ${LP_SOLVE})
TARGET_LINK_LIBRARIES(benchmarks_sob ${LP_SOLVE})
TARGET_LINK_LIBRARIES(benchmarks_cg ${LP_SOLVE})
TARGET_LINK_LIBRARIES(simple_mc_integration ${LP_SOLVE})
TARGET_LINK_LIBRARIES(benchmarks_cb ${LP_SOLVE})
TARGET_LINK_LIBRARIES(ode_solvers_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3})
TARGET_LINK_LIBRARIES(boundary_oracles_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3})
TARGET_LINK_LIBRARIES(root_finders_test ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3})
TARGET_LINK_LIBRARIES(new_volume_example ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(volume_sob_hpolytope ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(volume_sob_vpolytope ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(volume_cg_hpolytope ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(volume_cg_vpolytope ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(volume_cb_hpolytope ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(volume_cb_vpolytope ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(volume_cb_zonotopes ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(volume_cb_vpoly_intersection_vpoly ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(new_rounding_test ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(max_ellipsoid_rounding_test ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(mcmc_diagnostics_test ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(benchmarks_sob ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(benchmarks_cg ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(simple_mc_integration ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(benchmarks_cb ${LP_SOLVE} coverage_config)
TARGET_LINK_LIBRARIES(ode_solvers_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} coverage_config)
TARGET_LINK_LIBRARIES(boundary_oracles_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} coverage_config)
TARGET_LINK_LIBRARIES(root_finders_test ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} coverage_config)

if (USE_MKL)
TARGET_LINK_LIBRARIES(logconcave_sampling_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${BLAS} "-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl")
TARGET_LINK_LIBRARIES(logconcave_sampling_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${BLAS} coverage_config "-L${MKLROOT}/lib/intel64 -Wl,--no-as-needed -lmkl_intel_ilp64 -lmkl_gnu_thread -lmkl_core -lgomp -lpthread -lm -ldl")
else()
TARGET_LINK_LIBRARIES(logconcave_sampling_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${BLAS})
TARGET_LINK_LIBRARIES(logconcave_sampling_test ${LP_SOLVE} ${IFOPT} ${IFOPT_IPOPT} ${PTHREAD} ${GMP} ${MPSOLVE} ${FFTW3} ${BLAS} coverage_config)
endif()

TARGET_LINK_LIBRARIES(order_polytope ${LP_SOLVE})
TARGET_LINK_LIBRARIES(order_polytope ${LP_SOLVE} coverage_config)


endif()

0 comments on commit f8ba770

Please sign in to comment.