This is an automated email from the ASF dual-hosted git repository. haonan pushed a commit to branch code_coverage_v2 in repository https://gitbox.apache.org/repos/asf/tsfile.git
commit f2492e73f5aa2b2628f5e96c64df3874e2a8fb18 Author: HTHou <[email protected]> AuthorDate: Thu Aug 1 12:14:52 2024 +0800 try --- .github/workflows/code-coverage.yml | 15 ++++++++------- cpp/CMakeLists.txt | 10 +++++++--- cpp/pom.xml | 9 +++++++++ cpp/src/CMakeLists.txt | 12 +++++++++--- cpp/test/CMakeLists.txt | 7 ++++++- 5 files changed, 39 insertions(+), 14 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 29076c3c..deda813a 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -3,6 +3,7 @@ on: push: branches: - develop + - code_coverage_v2 paths-ignore: - 'docs/**' pull_request: @@ -26,10 +27,10 @@ jobs: restore-keys: ${{ runner.os }}-m2- - name: Test run: | - ./mvnw -B -P with-java,with-cpp,with-python,with-code-coverage clean verify - ./mvnw -B -P with-code-coverage post-integration-test - - name: Upload coverage reports to codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./code-coverage/target/jacoco-merged-reports/jacoco.xml + ./mvnw -B -P with-cpp,with-code-coverage clean verify + ll cpp/target/build/test +# - name: Upload coverage reports to codecov +# uses: codecov/codecov-action@v4 +# with: +# token: ${{ secrets.CODECOV_TOKEN }} +# files: ./code-coverage/target/jacoco-merged-reports/jacoco.xml diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index afca5202..185b3905 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -33,7 +33,7 @@ if(DEFINED ENV{CXX}) message("cmake using: CXX=${CMAKE_CXX_COMPILER}") endif() -if(DEFINED ENV{CC}) +if(DEFINED ENV{CC}) set(CMAKE_C_COMPILER $ENV{CC}) message("cmake using: CC=${CMAKE_C_COMPILER}") endif() @@ -44,6 +44,11 @@ if (${DEBUG_SE}) message("add_definitions -DDEBUG_SE=1") endif() +if (${COV_ENABLED}) + add_definitions(-DCOV_ENABLED=1) + message("add_definitions -DCOV_ENABLED=1") +endif() + message("build type: ${BUILD_TYPE}") if (CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g") @@ -74,8 +79,7 @@ configure_file( "${PROJECT_BINARY_DIR}/cmake_config.h" ) -set(TESTS_ENABLED OFF) add_subdirectory(test) if(TESTS_ENABLED) add_dependencies(TsFile_Test tsfile) -endif() \ No newline at end of file +endif() diff --git a/cpp/pom.xml b/cpp/pom.xml index 8f563255..2654abb2 100644 --- a/cpp/pom.xml +++ b/cpp/pom.xml @@ -69,7 +69,10 @@ <configuration> <options> <option>-DBUILD_PHASE=test-compile</option> + <option>${cmake.addition.option}</option> </options> + <sourcePath/> + <targetPath/> </configuration> </execution> <!-- Compile the test code --> @@ -119,6 +122,12 @@ </plugins> </build> <profiles> + <profile> + <id>with-code-coverage</id> + <properties> + <cmake.addition.option>-DCOV_ENABLED=ON</cmake.addition.option> + </properties> + </profile> <!-- When running on jenkins, download the sonar build-wrapper, so we can do a code analysis --> <profile> <id>jenkins-build</id> diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index 9f323c77..0d7825a1 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -18,7 +18,6 @@ under the License. ]] message("Running in src diectory") include(${PROJECT_SOURCE_DIR}/cmake/build_function.cmake) - add_subdirectory(common) add_subdirectory(compress) add_subdirectory(cwrapper) @@ -29,7 +28,14 @@ add_subdirectory(utils) add_subdirectory(writer) add_library(tsfile SHARED) -target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj ) +target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj) +#if (${COV_ENABLED}) +# message("Enable code cov...") +# target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin -lclang_rt.profile_osx) +#else() +# message("Disable code cov...") +# target_link_libraries(tsfile common_obj compress_obj cwrapper_obj file_obj read_obj write_obj) +#endif() set(LIBTSFILE_PROJECT_VERSION 1.0) set(LIBTSFILE_SO_VERSION 1.0) @@ -53,4 +59,4 @@ install(TARGETS tsfile LIBRARY DESTINATION ${LIBTSFILE_SDK_DIR}) # if(CMAKE_SYSTEM_NAME MATCHES "Darwin") # add_custom_command(TARGET tsfile POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change `otool -L ${LIBRARY_OUTPUT_PATH}/libtsfile.dylib | grep liblz4 | sed 's/dylib.*/dylib/g'` ${my_lz4_lib} ${LIBRARY_OUTPUT_PATH}/libtsfile.dylib) # add_custom_command(TARGET tsfile POST_BUILD COMMAND ${CMAKE_INSTALL_NAME_TOOL} -change `otool -L ${LIBRARY_OUTPUT_PATH}/libtsfile.dylib | grep libz | sed 's/dylib.*/dylib/g'` ${my_z_lib} ${LIBRARY_OUTPUT_PATH}/libtsfile.dylib) -# endif() \ No newline at end of file +# endif() diff --git a/cpp/test/CMakeLists.txt b/cpp/test/CMakeLists.txt index 91fa71c5..6091e9ac 100644 --- a/cpp/test/CMakeLists.txt +++ b/cpp/test/CMakeLists.txt @@ -74,6 +74,11 @@ file(GLOB_RECURSE TEST_SRCS "compress/*_test.cc" "writer/*_test.cc" ) +if (${COV_ENABLED}) + message("Enable code cov...") + add_compile_options(-fprofile-instr-generate -fcoverage-mapping) +endif () + add_executable(TsFile_Test ${TEST_SRCS}) target_link_libraries( TsFile_Test @@ -84,4 +89,4 @@ target_link_libraries( set_target_properties(TsFile_Test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${LIBTSFILE_SDK_DIR}) include(GoogleTest) -gtest_discover_tests(TsFile_Test) \ No newline at end of file +gtest_discover_tests(TsFile_Test)
