Enable code coverage
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
This commit is contained in:
parent
bad9a97c01
commit
76e25a9bdb
3
.github/workflows/test.yaml
vendored
3
.github/workflows/test.yaml
vendored
@ -72,8 +72,7 @@ jobs:
|
|||||||
needs: [ test ]
|
needs: [ test ]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
container: ghcr.io/nlohmann/json-ci:v2.4.0
|
||||||
# TODO: Temporarily disabled because not implemented
|
if: ${{ github.event_name == 'push' || github.event_name == 'pull_request' }}
|
||||||
if: ${{ false && (github.event_name == 'push' || github.event_name == 'pull_request') }}
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Get latest cmake version
|
- name: Get latest cmake version
|
||||||
|
|||||||
@ -33,6 +33,8 @@ option(JSON_VALIDATOR_INSTALL "JsonValidator: Install targets" ${PROJECT_IS_TOP_
|
|||||||
option(JSON_VALIDATOR_BUILD_TESTS "JsonValidator: Build tests" ${PROJECT_IS_TOP_LEVEL})
|
option(JSON_VALIDATOR_BUILD_TESTS "JsonValidator: Build tests" ${PROJECT_IS_TOP_LEVEL})
|
||||||
option(JSON_VALIDATOR_BUILD_EXAMPLES "JsonValidator: Build examples" ${PROJECT_IS_TOP_LEVEL})
|
option(JSON_VALIDATOR_BUILD_EXAMPLES "JsonValidator: Build examples" ${PROJECT_IS_TOP_LEVEL})
|
||||||
option(JSON_VALIDATOR_SHARED_LIBS "JsonValidator: Build as shared library" ${PROJECT_IS_TOP_LEVEL})
|
option(JSON_VALIDATOR_SHARED_LIBS "JsonValidator: Build as shared library" ${PROJECT_IS_TOP_LEVEL})
|
||||||
|
option(JSON_VALIDATOR_TEST_COVERAGE "JsonValidator: Build with test coverage" OFF)
|
||||||
|
mark_as_advanced(JSON_VALIDATOR_TEST_COVERAGE)
|
||||||
# Get a default JSON_FETCH_VERSION from environment variables to workaround the CI
|
# Get a default JSON_FETCH_VERSION from environment variables to workaround the CI
|
||||||
if (DEFINED ENV{NLOHMANN_JSON_VERSION})
|
if (DEFINED ENV{NLOHMANN_JSON_VERSION})
|
||||||
set(JSON_FETCH_VERSION_DEFAULT $ENV{NLOHMANN_JSON_VERSION})
|
set(JSON_FETCH_VERSION_DEFAULT $ENV{NLOHMANN_JSON_VERSION})
|
||||||
@ -60,6 +62,19 @@ endif ()
|
|||||||
# Enable cmake's BUILD_SHARED_LIBS
|
# Enable cmake's BUILD_SHARED_LIBS
|
||||||
set(BUILD_SHARED_LIBS ${nlohmann_json_schema_validator_SHARED_LIBS})
|
set(BUILD_SHARED_LIBS ${nlohmann_json_schema_validator_SHARED_LIBS})
|
||||||
|
|
||||||
|
if (JSON_VALIDATOR_TEST_COVERAGE)
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
|
||||||
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
|
||||||
|
else ()
|
||||||
|
message(WARNING
|
||||||
|
"JsonValidator: Other toolchain coverage flags unknown.\n"
|
||||||
|
"Using --coverage as default")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
#[==============================================================================================[
|
#[==============================================================================================[
|
||||||
# External packages #
|
# External packages #
|
||||||
]==============================================================================================]
|
]==============================================================================================]
|
||||||
|
|||||||
@ -80,6 +80,12 @@
|
|||||||
"binaryDir": "cmake-build-coverage",
|
"binaryDir": "cmake-build-coverage",
|
||||||
"errors": {
|
"errors": {
|
||||||
"deprecated": false
|
"deprecated": false
|
||||||
|
},
|
||||||
|
"cacheVariables": {
|
||||||
|
"JSON_VALIDATOR_TEST_COVERAGE": {
|
||||||
|
"type": "BOOL",
|
||||||
|
"value": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user