File tree 4 files changed +42
-5
lines changed
4 files changed +42
-5
lines changed Original file line number Diff line number Diff line change @@ -23,8 +23,10 @@ before_script:
23
23
- cd ..
24
24
25
25
script :
26
- - ./build.sh test noVerbose
26
+ - ./build.sh test codecov noVerbose
27
27
28
+ after_success :
29
+ - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"
28
30
29
31
30
32
matrix :
Original file line number Diff line number Diff line change @@ -191,7 +191,24 @@ if(NOT APPLE)
191
191
list (APPEND deplibs rt)
192
192
endif ()
193
193
list (APPEND deplibs z)
194
-
194
+ # Code Coverage Configuration
195
+ add_library (coverage_config INTERFACE )
196
+
197
+ option (CODE_COVERAGE "Enable coverage reporting" OFF )
198
+ if (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" )
199
+ # Add required flags (GCC & LLVM/Clang)
200
+ target_compile_options (coverage_config INTERFACE
201
+ -O0 # no optimization
202
+ -g # generate debug info
203
+ --coverage # sets all required flags
204
+ )
205
+ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
206
+ target_link_options (coverage_config INTERFACE --coverage)
207
+ else ()
208
+ target_link_libraries (coverage_config INTERFACE --coverage)
209
+ endif ()
210
+ list (APPEND deplibs coverage_config)
211
+ endif (CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang" )
195
212
# add include dir for bsd (posix uses /usr/include/)
196
213
set (CMAKE_INCLUDE_PATH "${CMAKE_INCLUDE_PATH} :/usr/local/include" )
197
214
ENDIF ()
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ need_build_libevent=1
41
41
need_build_boost=1
42
42
test=0
43
43
verbose=1
44
+ codecov=0
44
45
cpu_num=4
45
46
46
47
pasres_arguments (){
@@ -59,6 +60,9 @@ pasres_arguments(){
59
60
noVerbose)
60
61
verbose=0
61
62
;;
63
+ codecov)
64
+ codecov=1
65
+ ;;
62
66
test)
63
67
test=1
64
68
esac
@@ -90,6 +94,16 @@ PrintParams()
90
94
else
91
95
echo " need build boost lib"
92
96
fi
97
+ if [ $test -eq 1 ]
98
+ then
99
+ echo " build unit tests"
100
+ else
101
+ echo " without build unit tests"
102
+ fi
103
+ if [ $codecov -eq 1 ]
104
+ then
105
+ echo " run unit tests with code coverage"
106
+ fi
93
107
if [ $verbose -eq 0 ]
94
108
then
95
109
echo " no need print detail logs"
@@ -305,7 +319,11 @@ BuildRocketMQClient()
305
319
if [ $test -eq 0 ]; then
306
320
cmake ..
307
321
else
308
- cmake .. -DRUN_UNIT_TEST=ON
322
+ if [ $codecov -eq 1 ]; then
323
+ cmake .. -DRUN_UNIT_TEST=ON -DCODE_COVERAGE=ON
324
+ else
325
+ cmake .. -DRUN_UNIT_TEST=ON
326
+ fi
309
327
fi
310
328
if [ $verbose -eq 0 ];
311
329
then
Original file line number Diff line number Diff line change @@ -42,14 +42,14 @@ include_directories(${Gmock_INCLUDE_DIR}/internal)
42
42
set (Gtest_LIBRARY_DIRS ${CMAKE_SOURCE_DIR} /bin/lib)
43
43
set (Gtest_LIBRARIES ${Gtest_LIBRARY_DIRS} /libgtest_main.a;${Gtest_LIBRARY_DIRS} /libgtest.a)
44
44
set (Gmock_LIBRARIES ${Gtest_LIBRARY_DIRS} /libgmock_main.a;${Gtest_LIBRARY_DIRS} /libgmock.a)
45
- message (status "** Gmock_LIBRARIES: ${Gmock_LIBRARIES} " )
45
+ message (STATUS "** Gmock_LIBRARIES: ${Gmock_LIBRARIES} " )
46
46
47
47
link_directories (${Boost_LIBRARY_DIRS} )
48
48
link_directories (${LIBEVENT_LIBRARY} )
49
49
link_directories (${JSONCPP_LIBRARY} )
50
50
51
51
set (ROCKETMQ_LIBRARIES ${CMAKE_SOURCE_DIR} /bin/librocketmq.a)
52
- message (status " ROCKETMQ_LIBRARIES ${ROCKETMQ_LIBRARIES} " )
52
+ message (STATUS "** ROCKETMQ_LIBRARIES ${ROCKETMQ_LIBRARIES} " )
53
53
54
54
set (CMAKE_BUILD_TYPE "Debug" )
55
55
You can’t perform that action at this time.
0 commit comments