1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-04-21 21:52:03 +02:00

misc: use BUILD_TESTING like the daemon and update instructions

Change-Id: I5e92e47ada4c4225c68065179245d96723397575
This commit is contained in:
Sébastien Blin 2024-02-16 09:39:03 -05:00
parent 0f62829588
commit 5371dac882
11 changed files with 31 additions and 19 deletions

View file

@ -33,7 +33,6 @@ include(${PROJECT_SOURCE_DIR}/extras/build/cmake/extra_tools.cmake)
option(WITH_DAEMON_SUBMODULE "Build with daemon submodule" ON) option(WITH_DAEMON_SUBMODULE "Build with daemon submodule" ON)
option(JAMICORE_AS_SUBDIR "Build Jami-core as a subdir dependency" OFF) option(JAMICORE_AS_SUBDIR "Build Jami-core as a subdir dependency" OFF)
option(ENABLE_TESTS "Build with tests" OFF)
option(WITH_WEBENGINE "Build with WebEngine" ON) option(WITH_WEBENGINE "Build with WebEngine" ON)
option(ENABLE_LIBWRAP "Enable libwrap (single process mode)" ON) option(ENABLE_LIBWRAP "Enable libwrap (single process mode)" ON)
if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Linux") if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
@ -871,7 +870,7 @@ qt_import_qml_plugins(${PROJECT_NAME})
qt_finalize_executable(${PROJECT_NAME}) qt_finalize_executable(${PROJECT_NAME})
# tests # tests
if(ENABLE_TESTS) if(BUILD_TESTING)
message("Add Jami tests") message("Add Jami tests")
add_subdirectory(${TESTS_DIR}) add_subdirectory(${TESTS_DIR})
endif() endif()

View file

@ -131,6 +131,11 @@ Notes:
- `--global-install` to install client-qt globally under /usr/local - `--global-install` to install client-qt globally under /usr/local
- `--prefix` to change the destination of the install. - `--prefix` to change the destination of the install.
+ For developers:
+ `--asan` add address sanitizer on the binary
+ `--debug` enable debug symbols
+ `--testing` will build the tests for both the daemon and client
+ `--no-libwrap` will build the DBUS version.
## Build only the client ## Build only the client

View file

@ -389,6 +389,8 @@ def run_install(args):
install_args.append('-u') install_args.append('-u')
if args.debug: if args.debug:
install_args.append('-d') install_args.append('-d')
if args.testing:
install_args.append('-t')
if args.asan: if args.asan:
install_args.append('-A') install_args.append('-A')
if args.no_libwrap: if args.no_libwrap:
@ -727,6 +729,9 @@ def parse_args():
default=True, action='store_false') default=True, action='store_false')
ap.add_argument('--qt', type=str, ap.add_argument('--qt', type=str,
help='Use the Qt path supplied') help='Use the Qt path supplied')
ap.add_argument('--testing', dest='testing',
default=False, action='store_true',
help='Enable testing for both client and daemon')
ap.add_argument('--no-libwrap', dest='no_libwrap', ap.add_argument('--no-libwrap', dest='no_libwrap',
default=False, action='store_true', default=False, action='store_true',
help='Disable libwrap. Also set --disable-shared option to daemon configure') help='Disable libwrap. Also set --disable-shared option to daemon configure')

View file

@ -113,7 +113,7 @@ pipeline {
cd ${dockerTopDir} cd ${dockerTopDir}
./build.py --install --qt /usr/lib/libqt-jami/ ./build.py --install --qt /usr/lib/libqt-jami/
cd build cd build
cmake .. -DENABLE_TESTS=True cmake .. -DBUILD_TESTING=True
make -j${cpuCount} make -j${cpuCount}
""") """)
// Run tests // Run tests

View file

@ -280,7 +280,7 @@ def build(config_str, qt_dir, tests):
"-DCMAKE_INSTALL_PREFIX=" + os.getcwd(), "-DCMAKE_INSTALL_PREFIX=" + os.getcwd(),
"-DCMAKE_SYSTEM_VERSION=" + WIN_SDK_VERSION, "-DCMAKE_SYSTEM_VERSION=" + WIN_SDK_VERSION,
"-DCMAKE_BUILD_TYPE=" + "Release", "-DCMAKE_BUILD_TYPE=" + "Release",
"-DENABLE_TESTS=" + str(tests).lower(), "-DBUILD_TESTING=" + str(tests).lower(),
"-DBETA=" + str((0, 1)[config_str == "Beta"]), "-DBETA=" + str((0, 1)[config_str == "Beta"]),
] ]

View file

@ -48,8 +48,9 @@ enable_webengine=true
asan= asan=
extra_cmake_flags='' extra_cmake_flags=''
arch='' arch=''
enable_testing=false
while getopts gsc:dQ:P:p:uWwa:AD: OPT; do while getopts gsc:dQ:P:p:uWwa:AtD: OPT; do
case "$OPT" in case "$OPT" in
g) g)
global='true' global='true'
@ -84,6 +85,9 @@ while getopts gsc:dQ:P:p:uWwa:AD: OPT; do
A) A)
asan='true' asan='true'
;; ;;
t)
enable_testing='true'
;;
D) D)
extra_cmake_flags="${OPTARG}" extra_cmake_flags="${OPTARG}"
;; ;;
@ -202,6 +206,12 @@ if [ "${asan}" = "true" ]; then
client_cmake_flags+=(-DENABLE_ASAN=true) client_cmake_flags+=(-DENABLE_ASAN=true)
fi fi
if [ "${enable_testing}" = "true" ]; then
client_cmake_flags+=(-DBUILD_TESTING=On)
else
client_cmake_flags+=(-DBUILD_TESTING=Off)
fi
if [[ "$OSTYPE" == "darwin"* ]]; then if [[ "$OSTYPE" == "darwin"* ]]; then
#detect arch for macos #detect arch for macos
CMAKE_OSX_ARCHITECTURES="arm64" CMAKE_OSX_ARCHITECTURES="arm64"

View file

@ -38,7 +38,7 @@
#include <clocale> #include <clocale>
#ifndef ENABLE_TESTS #ifndef BUILD_TESTING
int int
main(int argc, char* argv[]) main(int argc, char* argv[])
{ {

View file

@ -868,7 +868,7 @@ UtilsAdapter::urlFromLocalPath(const QString& filePath) const
return QUrl::fromLocalFile(filePath); return QUrl::fromLocalFile(filePath);
} }
#ifdef ENABLE_TESTS #ifdef BUILD_TESTING
// Must only be used for testing purposes // Must only be used for testing purposes
QString QString
UtilsAdapter::createDummyImage() const UtilsAdapter::createDummyImage() const

View file

@ -172,7 +172,7 @@ public:
Q_INVOKABLE QString getMimeNameForUrl(const QUrl& fileUrl) const; Q_INVOKABLE QString getMimeNameForUrl(const QUrl& fileUrl) const;
Q_INVOKABLE QUrl urlFromLocalPath(const QString& filePath) const; Q_INVOKABLE QUrl urlFromLocalPath(const QString& filePath) const;
#ifdef ENABLE_TESTS #ifdef BUILD_TESTING
Q_INVOKABLE QString createDummyImage() const; Q_INVOKABLE QString createDummyImage() const;
#endif #endif
Q_INVOKABLE bool isWayland() const; Q_INVOKABLE bool isWayland() const;

View file

@ -69,7 +69,6 @@ string(SUBSTRING ${CMAKE_GENERATOR} 0 14 CMAKE_GENERATOR_SHORT)
if(CMAKE_GENERATOR_SHORT MATCHES "Visual Studio ") if(CMAKE_GENERATOR_SHORT MATCHES "Visual Studio ")
message(STATUS "Generating VS project") message(STATUS "Generating VS project")
set(CMAKE_CXX_COMPILER_ID "MSVC") set(CMAKE_CXX_COMPILER_ID "MSVC")
set(ENABLE_TEST false)
add_definitions(-DUNICODE -D_UNICODE) add_definitions(-DUNICODE -D_UNICODE)
remove_definitions(-D_MBCS) remove_definitions(-D_MBCS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /W0 /MP /EHsc") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi /W0 /MP /EHsc")
@ -156,10 +155,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_INSTALL_RPATH "${CMAKE_CURRENT_SOURCE_DIR}") set(CMAKE_INSTALL_RPATH "${CMAKE_CURRENT_SOURCE_DIR}")
endif() endif()
if(NOT ENABLE_TEST)
set(ENABLE_TEST false)
endif()
if(NOT (${ENABLE_VIDEO} MATCHES false)) if(NOT (${ENABLE_VIDEO} MATCHES false))
message(STATUS "VIDEO enabled") message(STATUS "VIDEO enabled")
set(ENABLE_VIDEO 1 CACHE BOOL "Enable video") set(ENABLE_VIDEO 1 CACHE BOOL "Enable video")
@ -453,7 +448,7 @@ set(LIBCLIENT_HEADERS_PRIVATE
private/namedirectory_p.h private/namedirectory_p.h
private/smartInfoHub_p.h) private/smartInfoHub_p.h)
if(ENABLE_LIBWRAP AND (NOT ENABLE_TEST)) if(ENABLE_LIBWRAP)
list(APPEND LIBCLIENT_HEADERS_PRIVATE list(APPEND LIBCLIENT_HEADERS_PRIVATE
qtwrapper/callmanager_wrap.h qtwrapper/callmanager_wrap.h
qtwrapper/configurationmanager_wrap.h qtwrapper/configurationmanager_wrap.h
@ -463,9 +458,7 @@ if(ENABLE_LIBWRAP AND (NOT ENABLE_TEST))
qtwrapper/pluginmanager_wrap.h) qtwrapper/pluginmanager_wrap.h)
endif() endif()
if(NOT ENABLE_TEST) qt_wrap_cpp(LIBCLIENT_HEADERS_MOC ${LIBCLIENT_HEADERS_PRIVATE})
qt_wrap_cpp(LIBCLIENT_HEADERS_MOC ${LIBCLIENT_HEADERS_PRIVATE})
endif()
foreach(MODULE ${QT_MODULES}) foreach(MODULE ${QT_MODULES})
list(APPEND QT_LIBS "Qt::${MODULE}") list(APPEND QT_LIBS "Qt::${MODULE}")

View file

@ -49,7 +49,7 @@ target_include_directories(test_common_obj PRIVATE
${CMAKE_SOURCE_DIR}/src) ${CMAKE_SOURCE_DIR}/src)
target_link_directories(test_common_obj PRIVATE ${CLIENT_LINK_DIRS}) target_link_directories(test_common_obj PRIVATE ${CLIENT_LINK_DIRS})
target_link_libraries(test_common_obj ${QML_TEST_LIBS}) target_link_libraries(test_common_obj ${QML_TEST_LIBS})
target_compile_definitions(test_common_obj PRIVATE ENABLE_TESTS="ON") target_compile_definitions(test_common_obj PRIVATE BUILD_TESTING="ON")
set(COMMON_TESTS_SOURCES set(COMMON_TESTS_SOURCES
${QML_RESOURCES} ${QML_RESOURCES}
@ -101,7 +101,7 @@ set(ALL_TESTS_INCLUDES
function(setup_test TEST_NAME TEST_SOURCES TEST_INPUT) function(setup_test TEST_NAME TEST_SOURCES TEST_INPUT)
string(TOLOWER ${TEST_NAME} TEST_BINARY_NAME) string(TOLOWER ${TEST_NAME} TEST_BINARY_NAME)
add_executable(${TEST_BINARY_NAME} ${TEST_SOURCES}) add_executable(${TEST_BINARY_NAME} ${TEST_SOURCES})
target_compile_definitions(${TEST_BINARY_NAME} PRIVATE ENABLE_TESTS="ON") target_compile_definitions(${TEST_BINARY_NAME} PRIVATE BUILD_TESTING="ON")
target_link_libraries(${TEST_BINARY_NAME} ${ALL_TESTS_LIBS}) target_link_libraries(${TEST_BINARY_NAME} ${ALL_TESTS_LIBS})
target_include_directories(${TEST_BINARY_NAME} PUBLIC ${ALL_TESTS_INCLUDES}) target_include_directories(${TEST_BINARY_NAME} PUBLIC ${ALL_TESTS_INCLUDES})
if(MSVC) if(MSVC)