Skip to content

Commit

Permalink
Add coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
kunitoki committed Jan 21, 2024
1 parent 83c0884 commit 5e3af2b
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Code Coverage

on: push

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
code-coverage:
name: Code Coverage
runs-on: ubuntu-latest

steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Setup and install python
uses: actions/setup-python@v4
with:
python-version: "3.11"

- name: Build wheels and test
uses: pypa/[email protected]
env:
CIBW_ARCHS: x86_64
CIBW_BUILD: cp310-manylinux_x86_64
CIBW_TEST_SKIP: "*-manylinux_aarch64 *-macosx_universal2:arm64 *-win_arm64"
CIBW_ENVIRONMENT: POPSICLE_COVERAGE=1

- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
19 changes: 17 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,27 @@ _juce_set_output_name (${PROJECT_NAME} $<TARGET_PROPERTY:${PROJECT_NAME},JUCE_PR
# Configure code coverage
if (ENABLE_COVERAGE)
include (cmake/CodeCoverage.cmake)

append_coverage_compiler_flags()

set (COVERAGE_TARGET ${PROJECT_NAME}_coverage)
set (COVERAGE_EXCLUDES
"*/juce_core/juce_core.*"
"*/juce_data_structures/juce_data_structures.*"
"*/juce_events/juce_events.*"
"*/juce_graphics/juce_graphics.*"
"*/juce_gui_basics/juce_gui_basics.*")

if (APPLE)
list (APPEND COVERAGE_EXCLUDES
"/Applications/*"
"/Library/*")
endif()

setup_target_for_coverage_lcov (
NAME ${COVERAGE_TARGET}
EXECUTABLE pytest -s ${CMAKE_CURRENT_LIST_DIR}/tests
DEPENDENCIES ${PROJECT_NAME}
LCOV_ARGS "--keep-going" "--branch-coverage" "--no-external"
GENHTML_ARGS "--keep-going" "--branch-coverage")
LCOV_ARGS "--rc" "branch_coverage=1" "--branch-coverage" "--keep-going"
GENHTML_ARGS "--rc" "branch_coverage=1" "--branch-coverage" "--keep-going" "--prefix" "${CMAKE_CURRENT_LIST_DIR}")
endif()
5 changes: 3 additions & 2 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ foreach(LANG ${LANGUAGES})
endif()
endforeach()

set(COVERAGE_COMPILER_FLAGS "-g --coverage"
set(COVERAGE_COMPILER_FLAGS "-O0 -g --coverage"
CACHE INTERNAL "")
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
include(CheckCXXCompilerFlag)
Expand Down Expand Up @@ -734,7 +734,8 @@ function(append_coverage_compiler_flags)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${COVERAGE_COMPILER_FLAGS}" PARENT_SCOPE)
message(STATUS "Appending code coverage compiler flags: ${COVERAGE_COMPILER_FLAGS}")
message(STATUS "Appending code coverage C compiler flags: ${COVERAGE_C_COMPILER_FLAGS}")
message(STATUS "Appending code coverage CXX compiler flags: ${COVERAGE_CXX_COMPILER_FLAGS}")
endfunction() # append_coverage_compiler_flags

# Setup coverage for specific library
Expand Down
10 changes: 10 additions & 0 deletions tests/test_juce_core/test_File.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

import popsicle as juce

#==================================================================================================

def test_constructor():
a = juce.File(__file__)
assert a.getFullPathName() == __file__
assert a.getFileName() == os.path.split(__file__)[1]

0 comments on commit 5e3af2b

Please sign in to comment.