Skip to content

Commit

Permalink
Codecov (#324)
Browse files Browse the repository at this point in the history
### What problem were solved in this pull request?

Issue Number: close #172

Problem:
增加单元测试统计信息
  • Loading branch information
hnwyllmm authored Nov 29, 2023
1 parent 63b1f03 commit 9c2c6d7
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 29 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
37 changes: 9 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 <file>] [CODE <code>]] [...])
# script 表示安装时,调用cmake 脚步
# code 表示安装时,执行cmake 命令, 例如
INSTALL(CODE "MESSAGE(\"Sample install message.\")")
# EXEC_PROGRAM make时执行命令
#EXEC_PROGRAM(Executable [directory in which to run]
# [ARGS <arguments to executable>]
# [OUTPUT_VARIABLE <var>]

#EXEC_PROGRAM(Executable [directory in which to run]
# [ARGS <arguments to executable>]
# [OUTPUT_VARIABLE <var>]
# [RETURN_VALUE <var>])
# 生产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)
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<div align="center">

[![Coverage Status](https://codecov.io/gh/oceanbase/miniob/branch/main/graph/badge.svg)](https://codecov.io/gh/oceanbase/miniob)

</div>

# MiniOB 概述

MiniOB 是 [OceanBase](https://github.com/oceanbase/oceanbase) 团队基于华中科技大学数据库课程原型,联合多所高校重新开发的、专为零基础的同学设计的数据库入门学习项目。我们的目标是为在校学生、数据库从业者、爱好者或对基础技术感兴趣的人提供一个友好的数据库学习项目。
Expand Down
2 changes: 1 addition & 1 deletion src/observer/storage/trx/mvcc_trx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9c2c6d7

Please sign in to comment.