Skip to content

Commit 7844947

Browse files
committed
Add gcovr support
#17
1 parent 6fbca51 commit 7844947

File tree

5 files changed

+14
-15
lines changed

5 files changed

+14
-15
lines changed

.github/workflows/ctest.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,16 @@ jobs:
3737
cd build
3838
cmake .. -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build }}
3939
40-
# Runs only when Linux
40+
# Build for Linux
4141
- name: Build for Linux
42-
if: ${{ matrix.os == 'ubuntu-latest' }}
42+
if: matrix.os == 'ubuntu-latest'
4343
run: |
4444
cd build
4545
cmake --build . --target all --config ${{ matrix.build }} --clean-first -j4
4646
47-
48-
# Runs only when Windows
47+
# Build for Windows
4948
- name: Build for Windows
50-
if: ${{ matrix.os == 'windows-latest' }}
49+
if: matrix.os == 'windows-latest'
5150
run: |
5251
cd build
5352
cmake --build . --target all_build --config ${{ matrix.build }} --clean-first -j4
@@ -57,4 +56,11 @@ jobs:
5756
cd build
5857
ctest --rerun-failed --output-on-failure -j 4
5958
59+
# Created report only when Linux and Debug
60+
- name: Gcovr ( Linux and Debug only )
61+
if: matrix.os == 'ubuntu-latest' && matrix.build == 'Debug'
62+
run: |
63+
sudo apt-get install gcovr -y > /dev/null
64+
gcovr -r . -e build
65+
6066

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased] - YYYY-MM-DD
88
### Added
9+
- [Issue #17](https://github.com/suikan4github/template_application/issues/17) : Add gcovr support.
910
### Changed
1011
### Fixed
1112

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A CMake file template and sample C++ application which allows unit test by Googl
1313
- Windows 11 with Visual Studio C++ compiler.
1414
- WSL2 with VS CODE remote server.
1515
- Automatically tested by GitHub Actions.
16-
- linux-latest, Debug
16+
- linux-latest, Debug (With gcovr report)
1717
- linux-latest, Release
1818
- windows-latest, Debug
1919
- windows-latest, Release

src/CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,3 @@ if (NOT(MSVC))
1616
target_link_libraries(${EXECUTABLE_NAME} "pthread")
1717
endif(NOT(MSVC))
1818

19-
20-
# Remove the "main file" from list to create a library for test
21-
set( LIB_SRCS ${ALL_SRCS}) # create a new list as copy
22-
list(FILTER LIB_SRCS EXCLUDE REGEX ${MAIN_FILE_PATTERN}) # Filter out the main file
23-
24-
# Library for testing ( without main file)
25-
add_library(${TEST_LIBRARY_NAME} STATIC
26-
${LIB_SRCS})

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ list(FILTER LIB_SRC EXCLUDE REGEX ${MAIN_FILE_PATTERN}) # Filter out the main
1414
file(GLOB TEST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
1515

1616
# Test executable and library name
17-
set(TEST_EXECUTABLE_NAME test_${MY_LIBRARY_NAME})
17+
set(TEST_EXECUTABLE_NAME test_${PROJECT_NAME})
1818

1919
# Add the executable for the testcase which is using googletest
2020
add_executable(${TEST_EXECUTABLE_NAME} ${TEST_SRC} ${LIB_SRC})

0 commit comments

Comments
 (0)