diff --git a/.circleci/config.yml b/.circleci/config.yml index 6d2b4db81..8026597d9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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/codecov@3.1.1 jobs: build: machine: @@ -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' diff --git a/README.md b/README.md index a503c305a..3a290290e 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6a5e9abfc..2fa2f63dd 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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) @@ -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()