Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Coverage

on:
push:
branches: [ main ]
pull_request:

jobs:
coverage:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Install tools
run: sudo apt-get update && sudo apt-get install -y lcov gcovr

# ---- BUILD ----
- name: Configure
run: cmake -DCOVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON .

- name: Build
run: make -j

# ---- RUN TESTS ----
- name: Run tests
run: |
if [ -f "CTestTestfile.cmake" ]; then
ctest --output-on-failure
else
bin/all_tests
fi

# ---- GENERATE COVERAGE ----
- name: Generate coverage
run: |
gcovr \
--root . \
--xml-pretty \
--output coverage.xml \
--exclude 'test/*' \
--exclude 'build/*'

# ---- SEND TO COVERALLS ----
- name: Upload to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: coverage.xml
16 changes: 12 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#CMakeLists.txt file for cvx_presolver
cmake_minimum_required(VERSION 3.20)
project(PSLP
LANGUAGES C CXX
LANGUAGES C CXX # The library is written in C, but we also have some C++ test files
VERSION 0.1.0
DESCRIPTION "PSLP — A Lightweight C Presolver for Linear Programs"
)
Expand Down Expand Up @@ -95,7 +94,7 @@ else()
endif()

# Create PSLP library
add_library(PSLP ${CORE_SOURCES})# ${PRIVATE_HEADERS})
add_library(PSLP ${CORE_SOURCES})
target_include_directories(PSLP
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/PSLP>
Expand Down Expand Up @@ -126,7 +125,7 @@ else()
endif()

# Testing
option(BUILD_TESTING "Build tests" ON)
option(BUILD_TESTING "Build tests" OFF)
if(BUILD_TESTING)
include(CTest)
enable_testing()
Expand Down Expand Up @@ -158,6 +157,15 @@ else()
message(STATUS "Testing disabled")
endif()

option(COVERAGE "Enable coverage reporting" OFF)

if(COVERAGE)
message(STATUS "Building with coverage flags")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g --coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
endif()

add_executable(test_cpp EXCLUDE_FROM_ALL tests/test_cpp.cpp)
target_link_libraries(test_cpp PRIVATE PSLP)

Expand Down
2 changes: 0 additions & 2 deletions include/core/debug_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
#define HUGE_BOUND_ARG , huge_bound_ok
#endif

// OBS: The macros should be wrapped inside a DEBUG when use

#ifndef NDEBUG
#define DEBUG(code) \
do \
Expand Down