File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -85,6 +85,11 @@ set(CMAKE_MODULE_PATH
85
85
set (CMAKE_CXX_STANDARD 17 )
86
86
set (CMAKE_CXX_STANDARD_REQUIRED True )
87
87
88
+ if (COVERAGE_ENABLED )
89
+ # Add code coverage
90
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage" )
91
+ endif ()
92
+
88
93
# include(fb_cxx_flags)
89
94
message (STATUS "Update CXXFLAGS: ${CMAKE_CXX_FLAGS} " )
90
95
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ BUILD_DIR=' build-cachelib'
4
+ mkdir ${BUILD_DIR}
5
+ cd ${BUILD_DIR}
6
+ cmake ../cachelib -DBUILD_TESTS=ON -DCMAKE_INSTALL_PREFIX=/opt -DCMAKE_BUILD_TYPE=Debug -DCOVERAGE_ENABLED=ON
7
+ make install -j
8
+ cd -
9
+
10
+ # Track coverage
11
+ lcov -c -i -b . -d . -o Coverage.baseline
12
+ ./run_tests.sh
13
+ lcov -c -d . -b . -o Coverage.out
14
+ lcov -a Coverage.baseline -a Coverage.out -o Coverage.combined
15
+
16
+ # Generate report
17
+ COVERAGE_DIR=' coverage_report'
18
+ genhtml Coverage.combined -o ${COVERAGE_DIR}
19
+ COVERAGE_REPORT=" ${COVERAGE_DIR} .tgz"
20
+ tar -zcvf ${COVERAGE_REPORT} ${COVERAGE_DIR}
21
+ echo " Created coverage report ${COVERAGE_REPORT} "
22
+
23
+ # Cleanup
24
+ rm Coverage.baseline Coverage.out Coverage.combined
25
+ rm -rf ${COVERAGE_DIR}
You can’t perform that action at this time.
0 commit comments