Skip to content

Commit 6a667e7

Browse files
committed
Update the CI checks workflow and cmake to fix lcov errors
1 parent 4781fc0 commit 6a667e7

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ jobs:
2828
- name: Run Coverage
2929
run: |
3030
make -C build/ coverage
31-
declare -a EXCLUDE=("\*test\*" "\*CMakeCCompilerId\*" "\*mocks\*" "\*vendor/unity\*" "\*_deps\*")
32-
echo ${EXCLUDE[@]} | xargs lcov --rc branch_coverage=1 -r build/coverage.info -o build/coverage.info
33-
lcov --rc branch_coverage=1 --list build/coverage.info
31+
declare -a EXCLUDE=("\*_deps\*")
32+
echo ${EXCLUDE[@]} | xargs lcov --rc lcov_branch_coverage=1 -r build/coverage.info -o build/coverage.info
33+
lcov --rc lcov_branch_coverage=1 --summary build/coverage.info
3434
- name: Check Coverage
3535
uses: FreeRTOS/CI-CD-Github-Actions/coverage-cop@main
3636
with:
@@ -93,7 +93,7 @@ jobs:
9393
- name: Clone coreJSON
9494
run: git clone https://github.com/FreeRTOS/coreJSON.git --depth 1 --branch v3.2.0
9595
- name: Clone tinycbor
96-
run: git clone https://github.com/intel/tinycbor.git --depth 1 --branch main
96+
run: git clone https://github.com/intel/tinycbor.git --depth 1 --branch main
9797
- name: Install Python3
9898
uses: actions/setup-python@v3
9999
with:

tools/cmock/coverage.cmake

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
# Taken from amazon-freertos repository
22
cmake_minimum_required(VERSION 3.13)
33
set(BINARY_DIR ${CMAKE_BINARY_DIR})
4+
45
# reset coverage counters
56
execute_process(
6-
COMMAND lcov --directory ${CMAKE_BINARY_DIR} --base-directory
7-
${CMAKE_BINARY_DIR} --zerocounters
7+
COMMAND lcov --directory ${CMAKE_BINARY_DIR}
8+
--base-directory ${CMAKE_BINARY_DIR}
9+
--zerocounters
810
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/coverage)
9-
# make the initial/baseline capture a zeroed out files
11+
12+
# make the initial/baseline capture a zeroed out files
1013
execute_process(
11-
COMMAND
12-
lcov --directory ${CMAKE_BINARY_DIR} --base-directory ${CMAKE_BINARY_DIR}
13-
--initial --capture --rc lcov_branch_coverage=1 --rc
14-
genhtml_branch_coverage=1
15-
--output-file=${CMAKE_BINARY_DIR}/base_coverage.info)
16-
file(GLOB files "${CMAKE_BINARY_DIR}/bin/tests/*")
14+
COMMAND lcov --directory ${CMAKE_BINARY_DIR}
15+
--base-directory ${CMAKE_BINARY_DIR}
16+
--initial
17+
--capture
18+
--rc lcov_branch_coverage=1
19+
--rc genhtml_branch_coverage=1
20+
--output-file=${CMAKE_BINARY_DIR}/base_coverage.info
21+
--include "*source*")
1722

23+
file(GLOB files "${CMAKE_BINARY_DIR}/bin/tests/*")
1824
set(REPORT_FILE ${CMAKE_BINARY_DIR}/utest_report.txt)
1925
file(WRITE ${REPORT_FILE} "")
26+
2027
# execute all files in bin directory, gathering the output to show it in CI
2128
foreach(testname ${files})
2229
get_filename_component(test ${testname} NAME_WLE)
@@ -34,18 +41,24 @@ execute_process(COMMAND ruby ${CMOCK_DIR}/vendor/unity/auto/parse_output.rb -xml
3441

3542
# capture data after running the tests
3643
execute_process(
37-
COMMAND
38-
lcov --capture --rc lcov_branch_coverage=1 --rc genhtml_branch_coverage=1
39-
--base-directory ${CMAKE_BINARY_DIR} --directory ${CMAKE_BINARY_DIR}
40-
--output-file ${CMAKE_BINARY_DIR}/second_coverage.info)
44+
COMMAND lcov --capture
45+
--rc lcov_branch_coverage=1
46+
--rc genhtml_branch_coverage=1
47+
--base-directory ${CMAKE_BINARY_DIR}
48+
--directory ${CMAKE_BINARY_DIR}
49+
--output-file ${CMAKE_BINARY_DIR}/second_coverage.info
50+
--include "*source*")
4151

4252
# combile baseline results (zeros) with the one after running the tests
4353
execute_process(
44-
COMMAND
45-
lcov --base-directory ${CMAKE_BINARY_DIR} --directory ${CMAKE_BINARY_DIR}
46-
--add-tracefile ${CMAKE_BINARY_DIR}/base_coverage.info --add-tracefile
47-
${CMAKE_BINARY_DIR}/second_coverage.info --output-file
48-
${CMAKE_BINARY_DIR}/coverage.info --no-external --rc lcov_branch_coverage=1)
54+
COMMAND lcov --base-directory ${CMAKE_BINARY_DIR}
55+
--directory ${CMAKE_BINARY_DIR}
56+
--add-tracefile ${CMAKE_BINARY_DIR}/base_coverage.info
57+
--add-tracefile ${CMAKE_BINARY_DIR}/second_coverage.info
58+
--output-file ${CMAKE_BINARY_DIR}/coverage.info
59+
--no-external
60+
--rc lcov_branch_coverage=1)
61+
4962
execute_process(
5063
COMMAND
5164
genhtml --rc lcov_branch_coverage=1 --branch-coverage --output-directory

0 commit comments

Comments
 (0)