Skip to content

Commit

Permalink
Merge pull request #4084 from Holzhaus/coverage
Browse files Browse the repository at this point in the history
Add support for test coverage information
  • Loading branch information
uklotzde committed Jul 10, 2021
2 parents 86112e4 + 49c8684 commit 9de885c
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
include:
- name: clazy
- name: clang-tidy
- name: coverage
runs-on: ubuntu-20.04
name: ${{ matrix.name }}
steps:
Expand Down Expand Up @@ -71,6 +72,31 @@ jobs:
-DWAVPACK=ON \
..
working-directory: build
- name: Configure (coverage)
if: matrix.name == 'coverage'
run: |
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DOPTIMIZE=off \
-DCOVERAGE=ON \
-DWARNINGS_FATAL=OFF \
-DDEBUG_ASSERTIONS_FATAL=OFF \
-DBATTERY=ON \
-DBROADCAST=ON \
-DBULK=ON \
-DHID=ON \
-DLILV=ON \
-DOPUS=ON \
-DQTKEYCHAIN=ON \
-DVINYLCONTROL=ON \
-DFFMPEG=ON \
-DKEYFINDER=ON \
-DLOCALECOMPARE=ON \
-DMAD=ON \
-DMODPLUG=ON \
-DWAVPACK=ON \
..
working-directory: build
- name: Set up problem matcher
uses: ammaraskar/gcc-problem-matcher@master
- name: Build
Expand All @@ -80,3 +106,34 @@ jobs:
env:
CLAZY_CHECKS: level2,no-rule-of-two-soft,no-non-pod-global-static,no-qproperty-without-notify,no-wrong-qevent-cast,no-qstring-allocations,no-function-args-by-value,no-copyable-polymorphic,no-ctor-missing-parent-argument,no-missing-qobject-macro,no-rule-of-three,no-returning-void-expression,no-missing-typeinfo,no-base-class-event
CLAZY_IGNORE_DIRS: lib/.*
- name: "Test"
if: matrix.name == 'coverage'
run: ctest --timeout 45
working-directory: build
env:
# Render analyzer waveform tests to an offscreen buffer
QT_QPA_PLATFORM: ${{ matrix.qt_qpa_platform }}
GTEST_COLOR: 1
# Only use single thread to prevent *.gcna files from overwriting each other
CTEST_PARALLEL_LEVEL: 1
CTEST_OUTPUT_ON_FAILURE: 1
- name: "Generate Coverage Report"
if: matrix.name == 'coverage'
run: >-
lcov
--capture
--directory .
--base-directory ..
--include "${PWD%/*}/src/*"
--exclude "${PWD%/*}/src/test/*"
--exclude "${PWD%/*}/build/*"
--exclude "${PWD%/*}/lib/*"
--output-file lcov.info
working-directory: build
- name: "Upload Coverage Report to coveralls.io"
if: matrix.name == 'coverage'
uses: coverallsapp/github-action@master
with:
flag-name: ubuntu-20.04
path-to-lcov: build/lcov.info
github-token: ${{ secrets.GITHUB_TOKEN }}
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ if(NOT BUILD_LOW_MEMORY)
add_compile_options(-pipe)
endif()

# Coverage
#
# This is only available with GCC, therefore this option is forcibly set to OFF
# for all other compilers.
cmake_dependent_option(COVERAGE "Coverage (i.e. gcov) support" OFF "GNU_GCC" OFF)
if(COVERAGE)
add_compile_options(--coverage -fprofile-arcs -ftest-coverage)
add_link_options(--coverage -fprofile-arcs -ftest-coverage)
endif()

# Profiling
#
# This is only available on Linux, therefore this option is forcibly set to OFF
Expand Down
1 change: 1 addition & 0 deletions tools/debian_buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ case "$1" in
fonts-open-sans \
fonts-ubuntu \
g++ \
lcov \
libchromaprint-dev \
libdistro-info-perl \
libebur128-dev \
Expand Down

0 comments on commit 9de885c

Please sign in to comment.