Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ NamespaceIndentation: All
PenaltyBreakComment: 20
PenaltyExcessCharacter: 5
PointerAlignment: Middle
SortUsingDeclarations: false
SortUsingDeclarations: true
SpaceAfterTemplateKeyword: false
SpaceBeforeCpp11BracedList: true
SpacesBeforeTrailingComments: 1
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ jobs:
run: ctest -V

# - name: Test with Coverage
# working-directory: build
# run: cmake --build ${BUILD_DIR} --target os_test_coverage
# run: cmake --build build --target Wavefront_coverage

lint:
runs-on: ubuntu-latest
Expand Down
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"configurations": [
// https://stackoverflow.com/a/76447033
{
"name": "(ctest) Launch",
"type": "cppdbg",
"cwd": "${cmake.testWorkingDirectory}",
"request": "launch",
"program": "${cmake.testProgram}",
"args": [
"${cmake.testArgs}"
]
}
]
}
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"cmake.ctest.testSuiteDelimiter": "\\.",
"cmake.ctest.testExplorerIntegrationEnabled": true
}
28 changes: 28 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ project(Wavefront
option(WAVEFRONT_BUILD_DOCS "Builds the Wavefront documentation" ON)
option(WAVEFRONT_BUILD_TESTS "Builds the Wavefront tests" ON)

option(WAVEFRONT_TEST_COVERAGE "Generate gcov target for calculating code coverage" ON)
option(WAVEFRONT_TEST_COVERAGE_CAN_FAIL "Tests can fail for coverage" ON)
option(WAVEFRONT_TEST_COVERAGE_DARK "Use dark theme for html output" ON)

# Only if this is the top level project (not included with add_subdirectory)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
# Use -std=c++xx instead of -std=g++xx
Expand All @@ -17,6 +21,19 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

if(WAVEFRONT_BUILD_TESTS)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
if(WAVEFRONT_TEST_COVERAGE AND CMAKE_COMPILER_IS_GNUCXX)
include(CodeCoverage)
append_coverage_compiler_flags()
if(WAVEFRONT_TEST_COVERAGE_CAN_FAIL)
set(GCOVR_ADDITIONAL_ARGS ${GCOVR_ADDITIONAL_ARGS} --html-high-threshold 100 --html-medium-threshold 90 --fail-under-line 100 --fail-under-branch 100)
endif()
if(WAVEFRONT_TEST_COVERAGE_DARK)
set(GCOVR_ADDITIONAL_ARGS ${GCOVR_ADDITIONAL_ARGS} --html-theme github.dark-green)
else()
set(GCOVR_ADDITIONAL_ARGS ${GCOVR_ADDITIONAL_ARGS} --html-theme github.green)
endif()
endif()
# Testing only available for top level projects. It calls enable_testing
# which must be in the main CMakeLists.
include(CTest)
Expand Down Expand Up @@ -71,3 +88,14 @@ install(FILES
if((CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME OR MODERN_CMAKE_BUILD_TESTING) AND WAVEFRONT_BUILD_TESTS)
add_subdirectory(tests)
endif()

if(WAVEFRONT_TEST_COVERAGE AND CMAKE_COMPILER_IS_GNUCXX)
setup_target_for_coverage_gcovr_html(
NAME ${PROJECT_NAME}_coverage
EXECUTABLE ctest
EXECUTABLE_ARGS --output-on-failure
DEPENDENCIES ${PROJECT_NAME}
BASE_DIRECTORY .
EXCLUDE ${PROJECT_SOURCE_DIR}/tests ${PROJECT_BINARY_DIR}/*
)
endif()
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ test: build
test-ci: build
cd build && GTEST_COLOR=1 ctest -V

.PHONY: setup build install lint format test test-ci
test-cov: test coverage

coverage:
cmake --build build --target Wavefront_coverage

show_coverage:
gio open build/Wavefront_coverage/index.html

.PHONY: setup build install lint format test test-ci test-cov coverage
Loading