From 2fe31ee45342a4140f2384bb5b0e8d4c55ded33e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Wed, 2 Jul 2025 11:10:45 +0200 Subject: [PATCH] Add viewcoverage and fix coverage generation --- .gitignore | 3 ++- Makefile | 19 +++++++++++++++++-- README.md | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 47544ec..4eaed88 100644 --- a/.gitignore +++ b/.gitignore @@ -39,4 +39,5 @@ build_release .idea cmake-* **/CMakeFiles -**/gcovr-report \ No newline at end of file +**/gcovr-report +CMakeUserPresets.json diff --git a/Makefile b/Makefile index e65bae0..e3c9b89 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,12 @@ SHELL := /bin/bash .DEFAULT_GOAL := release -.PHONY: debug release install test conan-create +.PHONY: debug release install test conan-create viewcoverage lcov := lcov f_debug = build_debug f_release = build_release +genhtml = genhtml +docscdir = docs define build_target @echo ">>> Building the project for $(1)..." @@ -38,7 +40,8 @@ test: ## Build Debug version and run tests $(lcov) --remove coverage.info 'lib/*' --output-file coverage.info >/dev/null 2>&1; \ $(lcov) --remove coverage.info 'libtorch/*' --output-file coverage.info >/dev/null 2>&1; \ $(lcov) --remove coverage.info 'tests/*' --output-file coverage.info >/dev/null 2>&1; \ - $(lcov) --remove coverage.info 'gtest/*' --output-file coverage.info >/dev/null 2>&1; + $(lcov) --remove coverage.info 'gtest/*' --output-file coverage.info >/dev/null 2>&1; \ + $(lcov) --remove coverage.info '*/.conan2/*' --ignore-errors unused --output-file coverage.info >/dev/null 2>&1; @genhtml $(f_debug)/tests/coverage.info --demangle-cpp --output-directory $(f_debug)/tests/coverage --title "Discretizer mdlp Coverage Report" -s -k -f --legend @echo "* Coverage report is generated at $(f_debug)/tests/coverage/index.html" @which python || (echo ">>> Please install python"; exit 1) @@ -48,6 +51,18 @@ test: ## Build Debug version and run tests fi @echo ">>> Updating coverage badge..." @env python update_coverage.py $(f_debug)/tests + @echo ">>> Done" + +viewcoverage: ## View the html coverage report + @which $(genhtml) >/dev/null || (echo ">>> Please install lcov (genhtml not found)"; exit 1) + @if [ ! -d $(docscdir)/coverage ]; then mkdir -p $(docscdir)/coverage; fi + @if [ ! -f $(f_debug)/tests/coverage.info ]; then \ + echo ">>> No coverage.info file found. Run make coverage first!"; \ + exit 1; \ + fi + @$(genhtml) $(f_debug)/tests/coverage.info --demangle-cpp --output-directory $(docscdir)/coverage --title "FImdlp Coverage Report" -s -k -f --legend >/dev/null 2>&1; + @xdg-open $(docscdir)/coverage/index.html || open $(docscdir)/coverage/index.html 2>/dev/null + @echo ">>> Done"; conan-create: ## Create the conan package @echo ">>> Creating the conan package..." diff --git a/README.md b/README.md index a1e2a47..94d5880 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ [![Build](https://github.com/rmontanana/mdlp/actions/workflows/build.yml/badge.svg)](https://github.com/rmontanana/mdlp/actions/workflows/build.yml) [![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rmontanana_mdlp&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rmontanana_mdlp) [![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=rmontanana_mdlp&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=rmontanana_mdlp) -[![Coverage Badge](https://img.shields.io/badge/Coverage-100,0%25-green)](html/index.html) +[![Coverage Badge](https://img.shields.io/badge/Coverage-91,5%25-green)](html/index.html) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/rmontanana/mdlp) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14245443.svg)](https://doi.org/10.5281/zenodo.14245443)