diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 3e39db0..401e807 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -28,6 +28,9 @@ jobs: os: - ubuntu-latest include: + - julia-version: 1 + os: ubuntu-latest + cxx-coverage: true # Add a few windows and macOS jobs (not too many, the number we can run in parallel is limited) - julia-version: lts os: macOS-latest @@ -53,6 +56,8 @@ jobs: update_packager_index: false - name: "Build package" uses: julia-actions/julia-buildpkg@v1 + env: + NORMALIZ_JL_CXX_COVERAGE: ${{ matrix.cxx-coverage == true && 'true' || 'false' }} - name: "Run tests" uses: julia-actions/julia-runtest@v1 with: @@ -70,11 +75,30 @@ jobs: - name: "Process code coverage" uses: julia-actions/julia-processcoverage@v1 + - name: "Install gcovr" + if: ${{ matrix.cxx-coverage == true }} + run: python -m pip install gcovr + - name: "Process C++ coverage" + if: ${{ matrix.cxx-coverage == true }} + run: | + gcovr --version + gcovr \ + --root "$PWD" \ + --filter deps/src/normaliz.cpp \ + --gcov-object-directory deps/src/build \ + --exclude-throw-branches \ + --xml-pretty \ + --output coverage.xml \ + --print-summary - name: "Upload coverage data to Codecov" continue-on-error: true uses: codecov/codecov-action@v6 with: token: ${{ secrets.CODECOV_TOKEN }} + files: coverage.xml + disable_search: true + fail_ci_if_error: true + verbose: true docs: name: Documentation diff --git a/deps/build.jl b/deps/build.jl index 64829f2..9f0af59 100644 --- a/deps/build.jl +++ b/deps/build.jl @@ -6,6 +6,9 @@ using normaliz_jll # Parse some basic command-line arguments const verbose = "--verbose" in ARGS +const cxx_coverage = + lowercase(get(ENV, "NORMALIZ_JL_CXX_COVERAGE", "false")) in + ("1", "true", "yes", "on") jlcxx_cmake_dir = joinpath(CxxWrap.prefix_path(), "lib", "cmake", "JlCxx") julia_exec = joinpath(Sys.BINDIR, Base.julia_exename()) @@ -48,7 +51,8 @@ CMake_jll.cmake() do exe run(`$exe -DJulia_EXECUTABLE=$julia_exec -DJlCxx_DIR=$jlcxx_cmake_dir - -DCMAKE_BUILD_TYPE=Release + -DCMAKE_BUILD_TYPE=$(cxx_coverage ? "Debug" : "Release") + -DNORMALIZ_JULIA_ENABLE_COVERAGE=$(cxx_coverage ? "ON" : "OFF") -Dnormaliz_prefix=$(jll_artifact_dir(normaliz_jll)) -Dgmp_prefix=$(jll_artifact_dir(normaliz_jll.GMP_jll)) -Dmpfr_prefix=$(jll_artifact_dir(normaliz_jll.MPFR_jll)) @@ -67,7 +71,7 @@ CMake_jll.cmake() do exe run(`$exe --build $(builddir) - --config Release + --config $(cxx_coverage ? "Debug" : "Release") -- -j$(div(Sys.CPU_THREADS,2)) `) diff --git a/deps/src/CMakeLists.txt b/deps/src/CMakeLists.txt index 95af051..60b7071 100644 --- a/deps/src/CMakeLists.txt +++ b/deps/src/CMakeLists.txt @@ -18,6 +18,9 @@ set(CMAKE_CXX_STANDARD 14) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib;${JlCxx_location}") +option(NORMALIZ_JULIA_ENABLE_COVERAGE + "Build libnormaliz_julia with C++ coverage instrumentation" OFF) + include_directories( ${gmp_prefix}/include ${normaliz_prefix}/include @@ -28,6 +31,17 @@ include_directories( add_library(${JL_TARGET} SHARED normaliz.cpp) +if(NORMALIZ_JULIA_ENABLE_COVERAGE) + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + message(STATUS "Building ${JL_TARGET} with C++ coverage flags") + target_compile_options(${JL_TARGET} PRIVATE --coverage -O0 -g) + target_link_libraries(${JL_TARGET} --coverage) + else() + message(FATAL_ERROR + "C++ coverage is only supported with GCC or Clang") + endif() +endif() + target_link_libraries(${JL_TARGET} JlCxx::cxxwrap_julia JlCxx::cxxwrap_julia_stl diff --git a/test/runtests.jl b/test/runtests.jl index 39e2031..1bf0c81 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -238,6 +238,21 @@ end @test occursin("Complex", err.value.msg) end +@testset "cone property output types" begin + @test String(Normaliz._cone_property_output_type("HilbertBasis")) == "Matrix" + @test String(Normaliz._cone_property_output_type("ExtremeRaysFloat")) == "MatrixFloat" + @test String(Normaliz._cone_property_output_type("Grading")) == "Vector" + @test String(Normaliz._cone_property_output_type("TriangulationDetSum")) == "Integer" + @test String(Normaliz._cone_property_output_type("ExternalIndex")) == "GMPInteger" + @test String(Normaliz._cone_property_output_type("Multiplicity")) == "Rational" + @test String(Normaliz._cone_property_output_type("RenfVolume")) == "FieldElem" + @test String(Normaliz._cone_property_output_type("EuclideanVolume")) == "Float" + @test String(Normaliz._cone_property_output_type("EmbeddingDim")) == "MachineInteger" + @test String(Normaliz._cone_property_output_type("IsPointed")) == "Bool" + @test String(Normaliz._cone_property_output_type("Triangulation")) == "Complex" + @test String(Normaliz._cone_property_output_type("DefaultMode")) == "Void" +end + # TODO: reactivate these tests once Renf support is back #@testset "basic renf test" begin # r = Normaliz.RenfClass("a4-5a2+5", "a", "1.9021+/-0.01")