From 9c2c6d7592107a791cfb3985d20b9f46e874ef6b Mon Sep 17 00:00:00 2001 From: wangyunlai Date: Wed, 29 Nov 2023 10:47:10 +0800 Subject: [PATCH] Codecov (#324) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What problem were solved in this pull request? Issue Number: close #172 Problem: 增加单元测试统计信息 --- .github/workflows/build.yml | 14 ++++++++++ CMakeLists.txt | 37 +++++++-------------------- README.md | 6 +++++ src/observer/storage/trx/mvcc_trx.cpp | 2 +- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6ca3ffd3f..2f8a5836f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -39,6 +39,20 @@ jobs: cd build_debug make test + - name: lcov + shell: bash + run: | + export DEBIAN_FRONTEND=noninteractive + sudo apt-get update && sudo apt-get install -y lcov + cd build_debug + rm -rf unittest + lcov -c -d ./ -o coverage.info + + - uses: codecov/codecov-action@v3 + with: + file: build_debug/coverage.info + token: ${{ secrets.CODECOV_TOKEN }} + build-on-mac: # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. # You can convert this to a matrix build if you need cross-platform coverage. diff --git a/CMakeLists.txt b/CMakeLists.txt index 04b50c540..2568a2cb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,6 +126,15 @@ ENDIF () INCLUDE_DIRECTORIES(. ${PROJECT_SOURCE_DIR}/deps /usr/local/include) +IF(WITH_UNIT_TESTS) + SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -fprofile-arcs -ftest-coverage") + enable_testing() +ENDIF(WITH_UNIT_TESTS) + +SET(CMAKE_CXX_FLAGS ${CMAKE_COMMON_FLAGS}) +SET(CMAKE_C_FLAGS ${CMAKE_COMMON_FLAGS}) +MESSAGE(STATUS "CMAKE_CXX_FLAGS is " ${CMAKE_CXX_FLAGS}) + # ADD_SUBDIRECTORY(src bin) bin 为目标目录, 可以省略 ADD_SUBDIRECTORY(deps) ADD_SUBDIRECTORY(src/obclient) @@ -135,34 +144,6 @@ ADD_SUBDIRECTORY(benchmark) ADD_SUBDIRECTORY(tools) IF(WITH_UNIT_TESTS) - SET(CMAKE_COMMON_FLAGS "${CMAKE_COMMON_FLAGS} -fprofile-arcs -ftest-coverage") - enable_testing() ADD_SUBDIRECTORY(unittest) ENDIF(WITH_UNIT_TESTS) -SET(CMAKE_CXX_FLAGS ${CMAKE_COMMON_FLAGS}) -SET(CMAKE_C_FLAGS ${CMAKE_COMMON_FLAGS}) -MESSAGE(STATUS "CMAKE_CXX_FLAGS is " ${CMAKE_CXX_FLAGS}) - -INSTALL(DIRECTORY etc DESTINATION . - FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) - -#INSTALL([[SCRIPT ] [CODE ]] [...]) -# script 表示安装时,调用cmake 脚步 -# code 表示安装时,执行cmake 命令, 例如 -INSTALL(CODE "MESSAGE(\"Sample install message.\")") -# EXEC_PROGRAM make时执行命令 -#EXEC_PROGRAM(Executable [directory in which to run] -# [ARGS ] -# [OUTPUT_VARIABLE ] - -#EXEC_PROGRAM(Executable [directory in which to run] -# [ARGS ] -# [OUTPUT_VARIABLE ] -# [RETURN_VALUE ]) -# 生产make时,执行 -#EXEC_PROGRAM(ls ARGS "*.c" OUTPUT_VARIABLE LS_OUTPUT RETURN_VALUE -# LS_RVALUE) -#IF(not LS_RVALUE) -# MESSAGE(STATUS "ls result: " ${LS_OUTPUT}) -#ENDIF(not LS_RVALUE) diff --git a/README.md b/README.md index 310b80aeb..fddb6b263 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ +
+ +[![Coverage Status](https://codecov.io/gh/oceanbase/miniob/branch/main/graph/badge.svg)](https://codecov.io/gh/oceanbase/miniob) + +
+ # MiniOB 概述 MiniOB 是 [OceanBase](https://github.com/oceanbase/oceanbase) 团队基于华中科技大学数据库课程原型,联合多所高校重新开发的、专为零基础的同学设计的数据库入门学习项目。我们的目标是为在校学生、数据库从业者、爱好者或对基础技术感兴趣的人提供一个友好的数据库学习项目。 diff --git a/src/observer/storage/trx/mvcc_trx.cpp b/src/observer/storage/trx/mvcc_trx.cpp index 5cd682a51..cee8897ef 100644 --- a/src/observer/storage/trx/mvcc_trx.cpp +++ b/src/observer/storage/trx/mvcc_trx.cpp @@ -177,7 +177,7 @@ RC MvccTrx::delete_record(Table *table, Record &record) begin_xid, end_xid, trx_id_, record.rid().to_string().c_str()); rc = table->delete_record(record); ASSERT(rc == RC::SUCCESS, "failed to delete record in table.table id =%d, rid=%s, begin_xid=%d, end_xid=%d, current trx id = %d", - table.->table_id(), record.rid().to_string().c_str(), begin_xid, end_xid, trx_id_); + table->table_id(), record.rid().to_string().c_str(), begin_xid, end_xid, trx_id_); return rc; }