mirror of https://github.com/linuxdeepin/dtkcore
chore: ut linked dtkcore instead of source code
- use linked dtkcore target instead of source code - test-revoverage.sh tweak - setup_code_coverage && check_and_add_definitions functions(will move to dtkcommon)
This commit is contained in:
parent
5e2b16c51f
commit
4c50be9afb
|
@ -9,6 +9,7 @@ set(CMAKE_AUTORCC ON)
|
|||
set (DSG_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}" CACHE STRING "PREFIX of DSG_DATA_DIRS")
|
||||
add_definitions(-DPREFIX="${DSG_PREFIX_PATH}")
|
||||
add_definitions(-DLIBDTKCORE_LIBRARY)
|
||||
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
|
||||
if(LINUX)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
@ -23,6 +24,8 @@ if(LINUX)
|
|||
endif()
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Xml)
|
||||
|
||||
find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED)
|
||||
|
||||
# start text encoding
|
||||
find_package(ICU REQUIRED COMPONENTS uc)
|
||||
pkg_check_modules(uchardet REQUIRED uchardet)
|
||||
|
@ -146,6 +149,19 @@ target_link_directories(${LIB_NAME} INTERFACE
|
|||
$<INSTALL_INTERFACE:${LIBRARY_INSTALL_DIR}>
|
||||
)
|
||||
|
||||
set(EnableCov CACHE BOOL OFF)
|
||||
if (EnableCov)
|
||||
dtk_setup_code_coverage(${LIB_NAME})
|
||||
endif()
|
||||
|
||||
dtk_check_and_add_definitions(${LIB_NAME}
|
||||
DEFS
|
||||
OS_VERSION_TEST_FILE
|
||||
LSB_RELEASE_TEST_FILE
|
||||
OS_RELEASE_TEST_FILE
|
||||
DEEPIN_VERSION_TEST_FILE
|
||||
)
|
||||
|
||||
set(TOINSTALLBASE
|
||||
../include/base/dobject.h
|
||||
../include/base/dsingleton.h
|
||||
|
|
|
@ -12,10 +12,6 @@ set(CMAKE_CXX_FLAGS "-fno-access-control")
|
|||
add_compile_options(-fsanitize=address)
|
||||
add_link_options(-fsanitize=address)
|
||||
add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
|
||||
add_definitions(-DOS_VERSION_TEST_FILE="/tmp/etc/os-version")
|
||||
add_definitions(-DLSB_RELEASE_TEST_FILE="/tmp/etc/lsb-release")
|
||||
add_definitions(-DOS_RELEASE_TEST_FILE="/tmp/etc/os-release")
|
||||
add_definitions(-DDEEPIN_VERSION_TEST_FILE="/tmp/etc/deepin-version")
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui)
|
||||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)
|
||||
if(LINUX)
|
||||
|
@ -34,36 +30,6 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Concurrent)
|
|||
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test)
|
||||
find_package(GTest REQUIRED)
|
||||
|
||||
# start base
|
||||
include(../src/base/base.cmake)
|
||||
|
||||
# end base
|
||||
|
||||
# start dci
|
||||
include(../src/dci/dci.cmake)
|
||||
#end dci
|
||||
|
||||
#start filesystem
|
||||
include(../src/filesystem/filesystem.cmake)
|
||||
#end filesystem
|
||||
# start log
|
||||
include(../src/log/log.cmake)
|
||||
#end log
|
||||
# start settings
|
||||
include(../src/settings/settings.cmake)
|
||||
#message(${settings_SRC})
|
||||
#end settings
|
||||
|
||||
#start utils
|
||||
|
||||
# TODO match linux and others
|
||||
include(../src/util/util.cmake)
|
||||
#end utils
|
||||
|
||||
#GLOB
|
||||
include(../src/glob.cmake)
|
||||
|
||||
#endglob
|
||||
|
||||
# for test.so
|
||||
set(TEST_SO_NAME vtabletest${DTK_VERSION_MAJOR})
|
||||
|
@ -96,13 +62,6 @@ set(test_SRC
|
|||
# end test
|
||||
if(LINUX)
|
||||
add_executable(${BIN_NAME}
|
||||
${base_SRCS}
|
||||
${dci_SRCS}
|
||||
${filesystem_SRCS}
|
||||
${log_SRCS}
|
||||
${settings_SRC}
|
||||
${utils_SRC}
|
||||
${glob_SRC}
|
||||
${test_SRC}
|
||||
./data.qrc
|
||||
)
|
||||
|
@ -117,6 +76,7 @@ if(LINUX)
|
|||
Qt${QT_VERSION_MAJOR}::Concurrent
|
||||
Qt${QT_VERSION_MAJOR}::Test
|
||||
${GTEST_LIBRARIES}
|
||||
${LIB_NAME}
|
||||
-lpthread
|
||||
-lm
|
||||
-lgcov
|
||||
|
@ -138,12 +98,6 @@ if(LINUX)
|
|||
)
|
||||
endif()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(${BIN_NAME} PRIVATE -fprofile-instr-generate -ftest-coverage)
|
||||
endif()
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${BIN_NAME} PRIVATE -fprofile-arcs -ftest-coverage)
|
||||
endif()
|
||||
target_link_directories(${BIN_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/testso/)
|
||||
target_include_directories(${BIN_NAME} PUBLIC
|
||||
../include/util/
|
||||
|
@ -161,13 +115,6 @@ if(LINUX)
|
|||
)
|
||||
else()
|
||||
add_executable(${BIN_NAME}
|
||||
${base_SRCS}
|
||||
${dci_SRCS}
|
||||
${filesystem_SRCS}
|
||||
${log_SRCS}
|
||||
${settings_SRC}
|
||||
${utils_SRC}
|
||||
${glob_SRC}
|
||||
${test_SRC}
|
||||
./data.qrc
|
||||
)
|
||||
|
@ -181,17 +128,12 @@ else()
|
|||
Qt${QT_VERSION_MAJOR}::Concurrent
|
||||
Qt${QT_VERSION_MAJOR}::Test
|
||||
${GTEST_LIBRARIES}
|
||||
${LIB_NAME}
|
||||
-lpthread
|
||||
-lm
|
||||
-lgcov
|
||||
-l${TEST_SO_NAME}
|
||||
)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
target_compile_options(${BIN_NAME} PRIVATE -fprofile-instr-generate -ftest-coverage)
|
||||
endif()
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${BIN_NAME} PRIVATE -fprofile-arcs -ftest-coverage)
|
||||
endif()
|
||||
|
||||
target_link_directories(${BIN_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/testso/)
|
||||
target_include_directories( ${BIN_NAME} PUBLIC
|
||||
../include/util/
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
# SPDX-FileCopyrightText: 2022 UnionTech Software Technology Co., Ltd.
|
||||
# SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
|
||||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
BUILD_DIR=`pwd`/../build/tests/
|
||||
HTML_DIR=${BUILD_DIR}/html
|
||||
|
@ -14,16 +14,21 @@ export ASAN_OPTIONS="halt_on_error=0"
|
|||
# back to project directroy
|
||||
cd ..
|
||||
|
||||
cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug
|
||||
osv_def="-DOS_VERSION_TEST_FILE=\"/tmp/etc/os-version\""
|
||||
lsb_def="-DLSB_RELEASE_TEST_FILE=\"/tmp/etc/lsb-release\""
|
||||
os_def="-DOS_RELEASE_TEST_FILE=\"/tmp/etc/os-release\""
|
||||
dpv_def="-DDEEPIN_VERSION_TEST_FILE=\"/tmp/etc/deepin-version\""
|
||||
|
||||
cmake --build build --target ut-DtkCore -j$(nproc)
|
||||
cmake -Bbuild -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_EXAMPLE=OFF -DBUILD_DOCS=OFF -DEnableCov=ON ${osv_def} ${lsb_def} ${os_def} ${dpv_def}
|
||||
|
||||
cmake --build build -j$(nproc)
|
||||
|
||||
cd $BUILD_DIR
|
||||
|
||||
./ut-DtkCore --gtest_output=xml:${XML_DIR}/report_dtkcore.xml
|
||||
|
||||
lcov -d ./ -c -o coverage_all.info
|
||||
#lcov --extract coverage_all.info $EXTRACT_ARGS --output-file coverage.info
|
||||
# find *.gcda from build dir
|
||||
lcov -d ../ -c -o coverage_all.info
|
||||
lcov --remove coverage_all.info "*/tests/*" "*/usr/include*" "*build/src*" "*build-ut/src*" --output-file coverage.info
|
||||
cd ..
|
||||
genhtml -o $HTML_DIR $BUILD_DIR/coverage.info && mv ${BUILD_DIR}/html/index.html ${BUILD_DIR}/html/cov_dtkcore.html
|
||||
|
|
Loading…
Reference in New Issue