diff options
Diffstat (limited to 'src/corelib/Qt6CTestMacros.cmake')
-rw-r--r-- | src/corelib/Qt6CTestMacros.cmake | 83 |
1 files changed, 51 insertions, 32 deletions
diff --git a/src/corelib/Qt6CTestMacros.cmake b/src/corelib/Qt6CTestMacros.cmake index 0f1efc79ba..8722553cd0 100644 --- a/src/corelib/Qt6CTestMacros.cmake +++ b/src/corelib/Qt6CTestMacros.cmake @@ -1,5 +1,5 @@ # Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +# SPDX-License-Identifier: BSD-3-Clause # # W A R N I N G @@ -11,14 +11,9 @@ # # We mean it. -message("CMAKE_VERSION: ${CMAKE_VERSION}") -message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") -message("CMAKE_MODULES_UNDER_TEST: ${CMAKE_MODULES_UNDER_TEST}") -foreach(_mod ${CMAKE_MODULES_UNDER_TEST}) - message("CMAKE_${_mod}_MODULE_MAJOR_VERSION: ${CMAKE_${_mod}_MODULE_MAJOR_VERSION}") - message("CMAKE_${_mod}_MODULE_MINOR_VERSION: ${CMAKE_${_mod}_MODULE_MINOR_VERSION}") - message("CMAKE_${_mod}_MODULE_PATCH_VERSION: ${CMAKE_${_mod}_MODULE_PATCH_VERSION}") -endforeach() +message(STATUS "CMAKE_VERSION: ${CMAKE_VERSION}") +message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") +message(STATUS "CMAKE_MODULES_UNDER_TEST: ${CMAKE_MODULES_UNDER_TEST}") # Generate a shell script wrapper that calls ninja with -v parameter. # Upstream issue to allow specifying custom build tool options when using ctest's --build-and-test @@ -147,22 +142,30 @@ function(_qt_internal_get_cmake_test_configure_options out_var) ) endforeach() - set(prefixes "") - foreach(prefix_path IN LISTS CMAKE_PREFIX_PATH) - file(TO_CMAKE_PATH "${prefix_path}" prefix_path) - list(APPEND prefixes "${prefix_path}") - endforeach() + _qt_internal_get_build_vars_for_external_projects( + PREFIXES_VAR prefixes + ADDITIONAL_PACKAGES_PREFIXES_VAR additional_prefixes + ) + if(arg_OUT_PREFIX_PATH) set(${arg_OUT_PREFIX_PATH} "${prefixes}" PARENT_SCOPE) endif() string(REPLACE ";" "\;" prefixes "${prefixes}") list(APPEND option_list "-DCMAKE_PREFIX_PATH=${prefixes}") + list(APPEND option_list "-DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=${additional_prefixes}") set(${out_var} "${option_list}" PARENT_SCOPE) endfunction() function(_qt_internal_set_up_test_run_environment testname) + set(no_value_options NO_PLUGIN_PATH) + set(single_value_options "") + set(multi_value_options "") + cmake_parse_arguments(PARSE_ARGV 1 arg + "${no_value_options}" "${single_value_options}" "${multi_value_options}" + ) + # This is copy-pasted from qt_add_test and adapted to the standalone project case. if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows") set(QT_PATH_SEPARATOR "\\;") @@ -201,20 +204,20 @@ function(_qt_internal_set_up_test_run_environment testname) set_property(TEST "${testname}" APPEND PROPERTY ENVIRONMENT "${test_env_path}") set_property(TEST "${testname}" APPEND PROPERTY ENVIRONMENT "QT_TEST_RUNNING_IN_CTEST=1") - # Add the install prefix to list of plugin paths when doing a prefix build - if(NOT QT_INSTALL_DIR) - foreach(install_prefix ${install_prefixes}) - list(APPEND plugin_paths "${install_prefix}/${INSTALL_PLUGINSDIR}") - endforeach() - endif() - - #TODO: Collect all paths from known repositories when performing a super - # build. - list(APPEND plugin_paths "${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}") - list(JOIN plugin_paths "${QT_PATH_SEPARATOR}" plugin_paths_joined) - set_property(TEST "${testname}" - APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${plugin_paths_joined}") + if(NOT arg_NO_PLUGIN_PATH) + # Add the install prefix to list of plugin paths when doing a prefix build + if(NOT QT_INSTALL_DIR) + foreach(install_prefix ${install_prefixes}) + list(APPEND plugin_paths "${install_prefix}/${INSTALL_PLUGINSDIR}") + endforeach() + endif() + # TODO: Collect all paths from known repositories when performing a super build. + list(APPEND plugin_paths "${PROJECT_BINARY_DIR}/${INSTALL_PLUGINSDIR}") + list(JOIN plugin_paths "${QT_PATH_SEPARATOR}" plugin_paths_joined) + set_property(TEST "${testname}" + APPEND PROPERTY ENVIRONMENT "QT_PLUGIN_PATH=${plugin_paths_joined}") + endif() endfunction() # Checks if the test project can be built successfully. Arguments: @@ -252,13 +255,21 @@ endfunction() # TESTNAME: a custom test name to use instead of the one derived from the source directory name # # BUILD_OPTIONS: a list of -D style CMake definitions to pass to ctest's --build-options (which -# are ultimately passed to the CMake invocation of the test project) +# are ultimately passed to the CMake invocation of the test project). You may +# escape semicolons inside the definitions using: +# https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#bracket-argument +# so the argument containing list will look as following: +# -DLIST_ARGUMENT=item1[[;]]item2[[;]]...itemN. macro(_qt_internal_test_expect_pass _dir) + if(WASM) + return() + endif() set(_test_option_args SIMULATE_IN_SOURCE NO_CLEAN_STEP NO_BUILD_PROJECT_ARG NO_IOS_DEFAULT_ARGS + NO_RUN_ENVIRONMENT_PLUGIN_PATH ) set(_test_single_args BINARY @@ -373,7 +384,7 @@ macro(_qt_internal_test_expect_pass _dir) endif() if(build_environment STREQUAL "ci" AND osx_arch_count GREATER_EQUAL 2 - AND NOT QT_UIKIT_SDK + AND NOT QT_APPLE_SDK AND NOT QT_NO_IOS_BUILD_ADJUSTMENT_IN_CI) list(APPEND additional_configure_args -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_OSX_SYSROOT=iphonesimulator) @@ -414,6 +425,8 @@ macro(_qt_internal_test_expect_pass _dir) ) endif() + string(REPLACE "[[;]]" "\;" _ARGS_BUILD_OPTIONS "${_ARGS_BUILD_OPTIONS}") + _qt_internal_get_cmake_test_configure_options(option_list) set(ctest_command_args --build-and-test @@ -425,17 +438,23 @@ macro(_qt_internal_test_expect_pass _dir) --build-makeprogram "${make_program}" ${build_project} --build-options "${option_list}" - ${_ARGS_BUILD_OPTIONS} ${additional_configure_args} + "${_ARGS_BUILD_OPTIONS}" ${additional_configure_args} ${test_command} ) add_test(${testname} ${CMAKE_CTEST_COMMAND} ${ctest_command_args}) if(_ARGS_SIMULATE_IN_SOURCE) set_tests_properties(${testname} PROPERTIES - FIXTURES_REQUIRED "${testname}SIMULATE_IN_SOURCE_FIXTURE") + FIXTURES_REQUIRED "${testname}SIMULATE_IN_SOURCE_FIXTURE" + ) endif() + set_tests_properties(${testname} PROPERTIES ENVIRONMENT "ASAN_OPTIONS=detect_leaks=0") if(_ARGS_BINARY) - _qt_internal_set_up_test_run_environment("${testname}") + set(run_env_args "") + if(_ARGS_NO_RUN_ENVIRONMENT_PLUGIN_PATH) + list(APPEND run_env_args NO_PLUGIN_PATH) + endif() + _qt_internal_set_up_test_run_environment("${testname}" ${run_env_args}) endif() unset(__expect_pass_source_dir) |