Skip to content

Commit c7ad59e

Browse files
authored
Merge pull request #262 from ursfassler/coverage
Coverage
2 parents ae712b9 + c60ec80 commit c7ad59e

File tree

5 files changed

+29
-1
lines changed

5 files changed

+29
-1
lines changed

.github/workflows/run-all.yml

+18
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
pull_request:
55
branches: [ main ]
66
workflow_dispatch:
7+
push:
8+
branches:
9+
- main
710

811
jobs:
912
build:
@@ -17,6 +20,7 @@ jobs:
1720
sudo apt-get install --no-install-recommends \
1821
cmake \
1922
g++ \
23+
gcovr \
2024
git \
2125
libboost-date-time-dev \
2226
libboost-filesystem-dev \
@@ -52,3 +56,17 @@ jobs:
5256
export DISPLAY=:99
5357
./run-all.sh
5458
59+
- name: code coverage summary report
60+
uses: irongut/[email protected]
61+
with:
62+
filename: coverage/cobertura.xml
63+
indicators: false
64+
hide_complexity: true
65+
format: markdown
66+
output: file
67+
68+
- name: publish code coverage summary
69+
run: |
70+
echo '# Code Coverage Report' >> $GITHUB_STEP_SUMMARY
71+
cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
72+

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
# Build artifacts
99
/build/
10+
/coverage/
11+
/.local/
1012

1113
# vim swap files
1214
*.swp

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ option(CUKE_ENABLE_GTEST "Enable Google Test framework" ON)
2222
option(CUKE_ENABLE_QT "Enable Qt framework" ON)
2323
option(CUKE_TESTS_E2E "Enable end-to-end tests" ON)
2424
option(CUKE_TESTS_UNIT "Enable unit tests" ON)
25+
option(CUKE_CODE_COVERAGE "Enable instrumentation for code coverage" OFF)
2526
set(CUKE_ENABLE_SANITIZER "OFF" CACHE STRING "Sanitizer to use for checking")
2627
set_property(CACHE CUKE_ENABLE_SANITIZER PROPERTY STRINGS OFF "address" "thread" "undefined")
2728
option(CUKE_TESTS_VALGRIND "Enable tests within Valgrind" OFF)
@@ -36,6 +37,10 @@ elseif(CMAKE_CXX_STANDARD LESS 14)
3637
message(FATAL_ERROR "C++14 (above) is required")
3738
endif()
3839

40+
if(CUKE_CODE_COVERAGE)
41+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
42+
endif()
43+
3944
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
4045

4146
#

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
[![Join the chat at https://gitter.im/cucumber/cucumber-cpp](https://badges.gitter.im/cucumber/cucumber-cpp.svg)](https://gitter.im/cucumber/cucumber-cpp?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44
[![Windows build status](https://ci.appveyor.com/api/projects/status/5jeap3a4si9w8kka?svg=true)](https://ci.appveyor.com/project/paoloambrosio/cucumber-cpp-qqrt7)
5-
[![Coverage Status](https://coveralls.io/repos/github/cucumber/cucumber-cpp/badge.svg)](https://coveralls.io/github/cucumber/cucumber-cpp)
65

76
Cucumber-Cpp allows Cucumber to support step definitions written in C++.
87

run-all.sh

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ cmake -E make_directory build
2222
cmake -E chdir build cmake \
2323
-G Ninja \
2424
-DCUKE_ENABLE_EXAMPLES=on \
25+
-DCUKE_CODE_COVERAGE=on \
2526
-DBUILD_SHARED_LIBS="${BUILD_SHARED_LIBS:-OFF}" \
2627
-DCMAKE_INSTALL_PREFIX=${HOME}/.local \
2728
${CMAKE_PREFIX_PATH:+"-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}"} \
@@ -83,4 +84,7 @@ echo "unix: ${SOCK}" > examples/FeatureShowcase/features/step_definitions/cucumb
8384
(cd examples/FeatureShowcase; cucumber)
8485
wait %
8586

87+
mkdir -p coverage
88+
gcovr build/ --html-details --output coverage/index.html --xml coverage/cobertura.xml
89+
8690
cmake --build build --target install

0 commit comments

Comments
 (0)