refact: add test-coverage.sh and some docs

Signed-off-by: ComixHe <heyuming@deepin.org>
This commit is contained in:
ComixHe
2023-08-14 16:30:16 +08:00
committed by Comix
parent c4c1d72568
commit de09f3dbc2
12 changed files with 89 additions and 28 deletions

24
tools/test-coverage.sh Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
#
# SPDX-License-Identifier: LGPL-3.0-or-later
cd "$(git rev-parse --show-toplevel)" || exit 255
BUILD_DIR=${BUILD_DIR:="build-cov"}
HTML_DIR=${BUILD_DIR}/html
export ASAN_OPTIONS="halt_on_error=0"
cmake -B "$BUILD_DIR" \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_FLAGS="--coverage -fsanitize=address -fsanitize-recover=address " \
-DCMAKE_CXX_LINK_FLAGS="-lasan"
cmake --build "$BUILD_DIR" -j$(nproc)
cmake --build "$BUILD_DIR" -j$(nproc) -t test
gcovr -f "src/*" --html-details "$BUILD_DIR"/coverage.html