From 5371dac88246cadd6e9b8d0dc73d5ea550b60a36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Fri, 16 Feb 2024 09:39:03 -0500 Subject: [PATCH] misc: use BUILD_TESTING like the daemon and update instructions Change-Id: I5e92e47ada4c4225c68065179245d96723397575 --- CMakeLists.txt | 3 +-- INSTALL.md | 5 +++++ build.py | 5 +++++ extras/ci/client-qt-gnulinux/Jenkinsfile | 2 +- extras/scripts/build-windows.py | 2 +- extras/scripts/install.sh | 12 +++++++++++- src/app/main.cpp | 2 +- src/app/utilsadapter.cpp | 2 +- src/app/utilsadapter.h | 2 +- src/libclient/CMakeLists.txt | 11 ++--------- tests/CMakeLists.txt | 4 ++-- 11 files changed, 31 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 63640c062..b3f0106d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,6 @@ include(${PROJECT_SOURCE_DIR}/extras/build/cmake/extra_tools.cmake) option(WITH_DAEMON_SUBMODULE "Build with daemon submodule" ON) 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(ENABLE_LIBWRAP "Enable libwrap (single process mode)" ON) if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Linux") @@ -871,7 +870,7 @@ qt_import_qml_plugins(${PROJECT_NAME}) qt_finalize_executable(${PROJECT_NAME}) # tests -if(ENABLE_TESTS) +if(BUILD_TESTING) message("Add Jami tests") add_subdirectory(${TESTS_DIR}) endif() diff --git a/INSTALL.md b/INSTALL.md index ca6c58fac..a005c2d22 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -131,6 +131,11 @@ Notes: - `--global-install` to install client-qt globally under /usr/local - `--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 diff --git a/build.py b/build.py index cd86b5cb9..cc6309ea0 100755 --- a/build.py +++ b/build.py @@ -389,6 +389,8 @@ def run_install(args): install_args.append('-u') if args.debug: install_args.append('-d') + if args.testing: + install_args.append('-t') if args.asan: install_args.append('-A') if args.no_libwrap: @@ -727,6 +729,9 @@ def parse_args(): default=True, action='store_false') ap.add_argument('--qt', type=str, 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', default=False, action='store_true', help='Disable libwrap. Also set --disable-shared option to daemon configure') diff --git a/extras/ci/client-qt-gnulinux/Jenkinsfile b/extras/ci/client-qt-gnulinux/Jenkinsfile index e21b8e880..bd3a501f6 100644 --- a/extras/ci/client-qt-gnulinux/Jenkinsfile +++ b/extras/ci/client-qt-gnulinux/Jenkinsfile @@ -113,7 +113,7 @@ pipeline { cd ${dockerTopDir} ./build.py --install --qt /usr/lib/libqt-jami/ cd build - cmake .. -DENABLE_TESTS=True + cmake .. -DBUILD_TESTING=True make -j${cpuCount} """) // Run tests diff --git a/extras/scripts/build-windows.py b/extras/scripts/build-windows.py index 8268ab31f..03c527d8a 100644 --- a/extras/scripts/build-windows.py +++ b/extras/scripts/build-windows.py @@ -280,7 +280,7 @@ def build(config_str, qt_dir, tests): "-DCMAKE_INSTALL_PREFIX=" + os.getcwd(), "-DCMAKE_SYSTEM_VERSION=" + WIN_SDK_VERSION, "-DCMAKE_BUILD_TYPE=" + "Release", - "-DENABLE_TESTS=" + str(tests).lower(), + "-DBUILD_TESTING=" + str(tests).lower(), "-DBETA=" + str((0, 1)[config_str == "Beta"]), ] diff --git a/extras/scripts/install.sh b/extras/scripts/install.sh index dec0c76e3..e39d541ce 100755 --- a/extras/scripts/install.sh +++ b/extras/scripts/install.sh @@ -48,8 +48,9 @@ enable_webengine=true asan= extra_cmake_flags='' 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 g) global='true' @@ -84,6 +85,9 @@ while getopts gsc:dQ:P:p:uWwa:AD: OPT; do A) asan='true' ;; + t) + enable_testing='true' + ;; D) extra_cmake_flags="${OPTARG}" ;; @@ -202,6 +206,12 @@ if [ "${asan}" = "true" ]; then client_cmake_flags+=(-DENABLE_ASAN=true) fi +if [ "${enable_testing}" = "true" ]; then + client_cmake_flags+=(-DBUILD_TESTING=On) +else + client_cmake_flags+=(-DBUILD_TESTING=Off) +fi + if [[ "$OSTYPE" == "darwin"* ]]; then #detect arch for macos CMAKE_OSX_ARCHITECTURES="arm64" diff --git a/src/app/main.cpp b/src/app/main.cpp index ece26cc18..129ce9537 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -38,7 +38,7 @@ #include <clocale> -#ifndef ENABLE_TESTS +#ifndef BUILD_TESTING int main(int argc, char* argv[]) { diff --git a/src/app/utilsadapter.cpp b/src/app/utilsadapter.cpp index b46add5ce..70f559fa8 100644 --- a/src/app/utilsadapter.cpp +++ b/src/app/utilsadapter.cpp @@ -868,7 +868,7 @@ UtilsAdapter::urlFromLocalPath(const QString& filePath) const return QUrl::fromLocalFile(filePath); } -#ifdef ENABLE_TESTS +#ifdef BUILD_TESTING // Must only be used for testing purposes QString UtilsAdapter::createDummyImage() const diff --git a/src/app/utilsadapter.h b/src/app/utilsadapter.h index 5cb5c5a89..d4e1aa920 100644 --- a/src/app/utilsadapter.h +++ b/src/app/utilsadapter.h @@ -172,7 +172,7 @@ public: Q_INVOKABLE QString getMimeNameForUrl(const QUrl& fileUrl) const; Q_INVOKABLE QUrl urlFromLocalPath(const QString& filePath) const; -#ifdef ENABLE_TESTS +#ifdef BUILD_TESTING Q_INVOKABLE QString createDummyImage() const; #endif Q_INVOKABLE bool isWayland() const; diff --git a/src/libclient/CMakeLists.txt b/src/libclient/CMakeLists.txt index a415bacd8..bab7003bd 100644 --- a/src/libclient/CMakeLists.txt +++ b/src/libclient/CMakeLists.txt @@ -69,7 +69,6 @@ string(SUBSTRING ${CMAKE_GENERATOR} 0 14 CMAKE_GENERATOR_SHORT) if(CMAKE_GENERATOR_SHORT MATCHES "Visual Studio ") message(STATUS "Generating VS project") set(CMAKE_CXX_COMPILER_ID "MSVC") - set(ENABLE_TEST false) add_definitions(-DUNICODE -D_UNICODE) remove_definitions(-D_MBCS) 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}") endif() -if(NOT ENABLE_TEST) - set(ENABLE_TEST false) -endif() - if(NOT (${ENABLE_VIDEO} MATCHES false)) message(STATUS "VIDEO enabled") set(ENABLE_VIDEO 1 CACHE BOOL "Enable video") @@ -453,7 +448,7 @@ set(LIBCLIENT_HEADERS_PRIVATE private/namedirectory_p.h private/smartInfoHub_p.h) -if(ENABLE_LIBWRAP AND (NOT ENABLE_TEST)) +if(ENABLE_LIBWRAP) list(APPEND LIBCLIENT_HEADERS_PRIVATE qtwrapper/callmanager_wrap.h qtwrapper/configurationmanager_wrap.h @@ -463,9 +458,7 @@ if(ENABLE_LIBWRAP AND (NOT ENABLE_TEST)) qtwrapper/pluginmanager_wrap.h) endif() -if(NOT ENABLE_TEST) - qt_wrap_cpp(LIBCLIENT_HEADERS_MOC ${LIBCLIENT_HEADERS_PRIVATE}) -endif() +qt_wrap_cpp(LIBCLIENT_HEADERS_MOC ${LIBCLIENT_HEADERS_PRIVATE}) foreach(MODULE ${QT_MODULES}) list(APPEND QT_LIBS "Qt::${MODULE}") diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index bc68fcf03..b2730b719 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -49,7 +49,7 @@ target_include_directories(test_common_obj PRIVATE ${CMAKE_SOURCE_DIR}/src) target_link_directories(test_common_obj PRIVATE ${CLIENT_LINK_DIRS}) 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 ${QML_RESOURCES} @@ -101,7 +101,7 @@ set(ALL_TESTS_INCLUDES function(setup_test TEST_NAME TEST_SOURCES TEST_INPUT) string(TOLOWER ${TEST_NAME} TEST_BINARY_NAME) 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_include_directories(${TEST_BINARY_NAME} PUBLIC ${ALL_TESTS_INCLUDES}) if(MSVC) -- GitLab