From a87126ff934ad1b473f7cb8865cbd480b897d38f Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Fri, 15 Dec 2023 11:55:43 +0100 Subject: [PATCH] Fix test coverage settings Set new OPENCMW_ENABLE_COVERAGE flag in CI setup. Make sure SonarCloud doesn't complain about tests not covered by tests. Add all tests as dependencies of the coverage targets. --- .github/workflows/build_cmake.yml | 2 +- CMakeLists.txt | 26 ++++++++++++++++++++++++++ sonar-project.properties | 4 ++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_cmake.yml b/.github/workflows/build_cmake.yml index 9138fa45..35d75154 100644 --- a/.github/workflows/build_cmake.yml +++ b/.github/workflows/build_cmake.yml @@ -88,7 +88,7 @@ jobs: if: matrix.configurations.compiler != 'emscripten' # Use a bash shell, so we can use the same syntax for environment variable access regardless of the host operating system shell: bash - run: cmake -S . -B ../build -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DENABLE_COVERAGE=${{ matrix.configurations.name == env.REFERENCE_CONFIG && matrix.cmake-build-type == 'Debug' }} + run: cmake -S . -B ../build -DCMAKE_BUILD_TYPE=${{ matrix.cmake-build-type }} -DOPENCMW_ENABLE_COVERAGE=${{ matrix.configurations.name == env.REFERENCE_CONFIG && matrix.cmake-build-type == 'Debug' }} - name: Configure CMake Emscripten if: matrix.configurations.compiler == 'emscripten' diff --git a/CMakeLists.txt b/CMakeLists.txt index f1706848..17f02171 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,9 +146,22 @@ if(OPENCMW_ENABLE_TESTING) EXECUTABLE ctest DEPENDENCIES + base64pp_tests + clientPublisher_tests + client_tests core_tests + disruptor_core_tests + disruptor_tests + disruptor_waitstrategy_tests + majordomo_worker_rest_tests + majordomo_worker_tests majordomo_tests + mockserver_tests + RBAC_tests + rest_client_mock_server_tests + rest_client_only_tests serialiser_tests + SubscriptionMatch_tests EXCLUDE "$CMAKE_BUILD_DIR/*" "concepts/.*" @@ -159,9 +172,22 @@ if(OPENCMW_ENABLE_TESTING) EXECUTABLE ctest DEPENDENCIES + base64pp_tests + clientPublisher_tests + client_tests core_tests + disruptor_core_tests + disruptor_tests + disruptor_waitstrategy_tests + majordomo_worker_rest_tests + majordomo_worker_tests majordomo_tests + mockserver_tests + RBAC_tests + rest_client_mock_server_tests + rest_client_only_tests serialiser_tests + SubscriptionMatch_tests EXCLUDE "$CMAKE_BUILD_DIR/*" "concepts/.*" diff --git a/sonar-project.properties b/sonar-project.properties index 5fe7d891..0a7a0618 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -14,3 +14,7 @@ sonar.organization=fair-acc # exclude benchmark which crashes the Analysis # sonar.exclusions=bench/bm_case1.cpp sonar.coverageReportPaths=/home/runner/work/opencmw-cpp/build/coverage_sonarcube.xml +sonar.sources = src/ +sonar.tests = src/ +sonar.exclusions = src/**/test/**/* +sonar.test.inclusions = src/**/test/**/*