From cee90bedac90e53138a06f6eaa716f3cf8ac485f Mon Sep 17 00:00:00 2001 From: Timm Fitschen <t.fitschen@indiscale.com> Date: Mon, 5 Jul 2021 16:46:19 +0200 Subject: [PATCH] WIP: fix coverage --- CMakeLists.txt | 2 +- cmake/CodeCoverage.cmake | 19 ++++++++++++------- src/caosdb/connection.cpp | 3 +-- test/CMakeLists.txt | 1 + test/test_connection.cpp | 2 +- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 89b8d4b..c803bca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,7 @@ add_executable(caosdbcli src/caosdbcli.cpp) # linting is active when BUILD_TYPE == "Debug" if("${CMAKE_BUILD_TYPE}" MATCHES "Debug") - #set(_LINTING ON) + set(_LINTING ON) endif() if(_LINTING) find_program(iwyu diff --git a/cmake/CodeCoverage.cmake b/cmake/CodeCoverage.cmake index 10d2743..27c6028 100644 --- a/cmake/CodeCoverage.cmake +++ b/cmake/CodeCoverage.cmake @@ -82,6 +82,11 @@ # 2021-05-20, Timm Fitschen <t.fitschen@indiscale.com> # - Fix: this script should also accept GCC as a (plain) C compiler. # +# 2021-07-05, Timm Fitschen <t.fitschen@indiscale.com> +# - Removed -fprofile-abs-path again, because it would not work when using +# gcc as compiler, but clang-tidy as linter. Probably there is a better fix. +# clang error: `error: unknown argument: '-fprofile-abs-path' [clang-diagnostic-error]` +# # USAGE: # # 1. Copy this file into your cmake modules path. @@ -165,13 +170,13 @@ endif() set(COVERAGE_COMPILER_FLAGS "-g -fprofile-arcs -ftest-coverage" CACHE INTERNAL "") -if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag(-fprofile-abs-path HAVE_fprofile_abs_path) - if(HAVE_fprofile_abs_path) - set(COVERAGE_COMPILER_FLAGS "${COVERAGE_COMPILER_FLAGS} -fprofile-abs-path") - endif() -endif() +#if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") + #include(CheckCXXCompilerFlag) + #check_cxx_compiler_flag(-fprofile-abs-path HAVE_fprofile_abs_path) + #if(HAVE_fprofile_abs_path) + #set(COVERAGE_COMPILER_FLAGS "${COVERAGE_COMPILER_FLAGS} -fprofile-abs-path") + #endif() +#endif() set(CMAKE_Fortran_FLAGS_COVERAGE ${COVERAGE_COMPILER_FLAGS} diff --git a/src/caosdb/connection.cpp b/src/caosdb/connection.cpp index f2a3bfd..2205133 100644 --- a/src/caosdb/connection.cpp +++ b/src/caosdb/connection.cpp @@ -115,7 +115,6 @@ SslCaosDBConnectionConfig::SslCaosDBConnectionConfig( : CaosDBConnectionConfig(host, port) { SslCredentialsOptions options; options.pem_root_certs = cacert->getCACertPem(); - std::cout << "HERE" << options.pem_root_certs; this->credentials = SslCredentials(options); } @@ -159,7 +158,7 @@ auto operator<<(std::ostream &out, const CaosDBConnection &connection) [[nodiscard]] auto CaosDBConnection::getVersionInfo() const -> std::unique_ptr<VersionInfo> { - GetVersionInfoRequest request; + const GetVersionInfoRequest request; GetVersionInfoResponse response; grpc::ClientContext context; const grpc::Status status = diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 80a98f8..d1e1c4d 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -77,6 +77,7 @@ if (LCOV_PATH) LCOV_ARGS --rc lcov_branch_coverage=1 --no-external GENHTML_ARGS --rc lcov_branch_coverage=1 ) + message(STATUS "Adding COMPILE_FLAGS for coverage: ${COVERAGE_COMPILER_FLAGS}") set_target_properties(caosdb PROPERTIES COMPILE_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_COMPILER_FLAGS}") else () diff --git a/test/test_connection.cpp b/test/test_connection.cpp index 0660671..6ae9f0f 100644 --- a/test/test_connection.cpp +++ b/test/test_connection.cpp @@ -27,7 +27,7 @@ #include "gtest/gtest_pred_impl.h" // for Test, AssertionResult, EXPECT_EQ namespace grpc { class ChannelCredentials; -} +} // namespace grpc namespace caosdb::connection { -- GitLab