Skip to content

Commit

Permalink
feat: add test coverage script
Browse files Browse the repository at this point in the history
Add script to measure the coverage of unit test.

Log: add test coverage script
  • Loading branch information
asterwyx committed Aug 10, 2023
1 parent 333d053 commit 3abe01b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test-coverage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: LGPL-3.0-or-later

BUILD_DIR=`pwd`/build/tests/
HTML_DIR=${BUILD_DIR}/html
XML_DIR=${BUILD_DIR}/report

export ASAN_OPTIONS="halt_on_error=0"

cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug

cmake --build build --target unit-tests -j$(nproc)

cd $BUILD_DIR

./unit-tests --gtest_output=xml:${XML_DIR}/report_qtintegration.xml

lcov -d ./ -c -o coverage_all.info
lcov --remove coverage_all.info "*/tests/*" "*/usr/include*" "*build/*" --output-file coverage.info
genhtml -o $HTML_DIR $BUILD_DIR/coverage.info && mv ${BUILD_DIR}/html/index.html ${BUILD_DIR}/html/cov_qtintegration.html

0 comments on commit 3abe01b

Please sign in to comment.