Skip to content

Commit

Permalink
fix(tests): Fix code coverage generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
na2axl committed Oct 30, 2024
1 parent 945ea63 commit 2629cd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ jobs:
shell: bash
working-directory: ${{ inputs.project-path }}/build
run: |
lcov --capture --directory . --output-file coverage.info --base-directory . --ignore-errors inconsistent --ignore-errors range --ignore-errors negative
lcov --remove coverage.info '/usr/*' '${{ github.workspace }}/build/vcpkg_installed/*' '${{ github.workspace }}/src/Utils/*' '${{ github.workspace }}/samples/*' --output-file coverage.info --ignore-errors inconsistent --ignore-errors range
lcov --list coverage.info --ignore-errors inconsistent --ignore-errors range
lcov --capture --directory . --output-file coverage.info --base-directory . --ignore-errors inconsistent,range,mismatch,source,count,negative
lcov --remove coverage.info '/usr/*' '${{ github.workspace }}/build/vcpkg_installed/*' '${{ github.workspace }}/src/Utils/*' '${{ github.workspace }}/samples/*' --output-file coverage.info --ignore-errors inconsistent,range,mismatch,source,count,negative
lcov --list coverage.info --ignore-errors inconsistent,range,mismatch,source,count,negative
- name: Upload coverage to Codecov
if: matrix.build_type == 'debug' && !startsWith(matrix.config.os, 'windows')
Expand Down
10 changes: 5 additions & 5 deletions cmake/CodeCoverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ function(setup_target_for_coverage_lcov)
# Cleanup lcov
set(LCOV_CLEAN_CMD
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -directory .
-b ${BASEDIR} --zerocounters --ignore-errors inconsistent,range,mismatch,source,count
-b ${BASEDIR} --zerocounters --ignore-errors inconsistent,range,mismatch,source,count,negative
)
# Create baseline to make sure untouched files show up in the report
set(LCOV_BASELINE_CMD
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -c -i -d . -b
${BASEDIR} -o ${Coverage_NAME}.base --ignore-errors inconsistent,range,mismatch,source,count
${BASEDIR} -o ${Coverage_NAME}.base --ignore-errors inconsistent,range,mismatch,source,count,negative
)
# Run tests
set(LCOV_EXEC_TESTS_CMD
Expand All @@ -293,17 +293,17 @@ function(setup_target_for_coverage_lcov)
# Capturing lcov counters and generating report
set(LCOV_CAPTURE_CMD
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --directory . -b
${BASEDIR} --capture --output-file ${Coverage_NAME}.capture --ignore-errors inconsistent,range,mismatch,source,count
${BASEDIR} --capture --output-file ${Coverage_NAME}.capture --ignore-errors inconsistent,range,mismatch,source,count,negative
)
# add baseline counters
set(LCOV_BASELINE_COUNT_CMD
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -a ${Coverage_NAME}.base
-a ${Coverage_NAME}.capture --output-file ${Coverage_NAME}.total --ignore-errors inconsistent,range,mismatch,source,count
-a ${Coverage_NAME}.capture --output-file ${Coverage_NAME}.total --ignore-errors inconsistent,range,mismatch,source,count,negative
)
# filter collected data to final coverage report
set(LCOV_FILTER_CMD
${LCOV_PATH} ${Coverage_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --remove
${Coverage_NAME}.total ${LCOV_EXCLUDES} --output-file ${Coverage_NAME}.info --ignore-errors inconsistent,range,mismatch,source,count
${Coverage_NAME}.total ${LCOV_EXCLUDES} --output-file ${Coverage_NAME}.info --ignore-errors inconsistent,range,mismatch,source,count,negative
)
# Generate HTML output
set(LCOV_GEN_HTML_CMD
Expand Down

0 comments on commit 2629cd3

Please sign in to comment.