diff options
Diffstat (limited to 'tests')
11 files changed, 149 insertions, 2 deletions
diff --git a/tests/auto/cmake/RunCMake/CMakeLists.txt b/tests/auto/cmake/RunCMake/CMakeLists.txt index ec182debccd..aac9b43bac7 100644 --- a/tests/auto/cmake/RunCMake/CMakeLists.txt +++ b/tests/auto/cmake/RunCMake/CMakeLists.txt @@ -30,3 +30,7 @@ if(TARGET Qt6::Platform) qt_internal_add_RunCMake_test(Sbom ${extra_run_cmake_args}) endif() endif() + +list(APPEND extra_run_cmake_args "-DQT_WILL_INSTALL=${QT_WILL_INSTALL}") +list(APPEND extra_run_cmake_args "-DQT_REPO_MODULE_VERSION=${QT_REPO_MODULE_VERSION}") +qt_internal_add_RunCMake_test(StandaloneToolsPackage ${extra_run_cmake_args}) diff --git a/tests/auto/cmake/RunCMake/StandaloneToolsPackage/CMakeLists.txt b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/CMakeLists.txt new file mode 100644 index 00000000000..d490ae0713c --- /dev/null +++ b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} LANGUAGES CXX VERSION "${QT_REPO_MODULE_VERSION}") +include(${RunCMake_TEST}.cmake) diff --git a/tests/auto/cmake/RunCMake/StandaloneToolsPackage/Qt6GarageToolsConfigExtras.cmake.in b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/Qt6GarageToolsConfigExtras.cmake.in new file mode 100644 index 00000000000..35271634fde --- /dev/null +++ b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/Qt6GarageToolsConfigExtras.cmake.in @@ -0,0 +1 @@ +set(QT_GARAGE_TOOLS_CONFIG_EXTRAS_LOADED TRUE) diff --git a/tests/auto/cmake/RunCMake/StandaloneToolsPackage/Qt6GarageToolsExtraInclude.cmake b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/Qt6GarageToolsExtraInclude.cmake new file mode 100644 index 00000000000..4997381e6f4 --- /dev/null +++ b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/Qt6GarageToolsExtraInclude.cmake @@ -0,0 +1 @@ +set(QT_GARAGE_TOOLS_EXTRA_INCLUDE_LOADED TRUE) diff --git a/tests/auto/cmake/RunCMake/StandaloneToolsPackage/RunCMakeTest.cmake b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/RunCMakeTest.cmake new file mode 100644 index 00000000000..4581f694f5a --- /dev/null +++ b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/RunCMakeTest.cmake @@ -0,0 +1,56 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +include(QtRunCMake) + +set(build_case "build_and_install_tools_package") +set(consume_case "consume_tools_package") +set(consume_case_via_module "consume_tools_package_via_module") + +function(run_cmake_and_build case) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + + # Set an install prefix that is common to both projects. + set(cmake_install_prefix ${RunCMake_BINARY_DIR}/installed) + + set(options + "-DQt6_DIR=${Qt6_DIR}" + "-DQT_REPO_MODULE_VERSION=${QT_REPO_MODULE_VERSION}" + ) + + # For prefix builds, install into a separate dir rather than the Qt one. + # For non-prefix, files will end up being copied to the Qt dir. + if(QT_WILL_INSTALL) + list(APPEND options + "-DCMAKE_INSTALL_PREFIX=${cmake_install_prefix}" + "-DQT_ADDITIONAL_PACKAGES_PREFIX_PATH=${cmake_install_prefix}" + "-DQT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH=${cmake_install_prefix}" + ) + endif() + + # Merge output, because some of configure also outputs some stuff to stderr even when + # everything is fine and CMake treats it as an error. + set(RunCMake_TEST_OUTPUT_MERGE 1) + + # Configure. + run_cmake_with_options(${case} ${options}) + + # Do not remove the current RunCMake_TEST_BINARY_DIR for the next operations. + set(RunCMake_TEST_NO_CLEAN 1) + + # Build and install + run_cmake_command(${case}-build "${CMAKE_COMMAND}" --build .) + + if(QT_WILL_INSTALL) + run_cmake_command(${case}-install "${CMAKE_COMMAND}" --install .) + endif() +endfunction() + +# Build and install the tools package. +run_cmake_and_build("${build_case}") + +# Find the tools package. +run_cmake_and_build("${consume_case}") + +# Find the tools package via module. +run_cmake_and_build("${consume_case_via_module}") diff --git a/tests/auto/cmake/RunCMake/StandaloneToolsPackage/build_and_install_tools_package.cmake b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/build_and_install_tools_package.cmake new file mode 100644 index 00000000000..7cc9ecc38d1 --- /dev/null +++ b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/build_and_install_tools_package.cmake @@ -0,0 +1,48 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +find_package(Qt6 REQUIRED COMPONENTS Core BuildInternals) + +# Avoid erorrs in CI about unsupported SDK and Xcode versions on older CI macOS versions. +if(APPLE) + set(QT_NO_APPLE_SDK_AND_XCODE_CHECK ON) +endif() + +qt_internal_project_setup() + +qt_build_repo_begin() + +set(base_name "Garage") +set(extra_file_base_path "${CMAKE_CURRENT_SOURCE_DIR}/${QT_CMAKE_EXPORT_NAMESPACE}${base_name}") + +# Add a standalone tools package. +qt_internal_add_tools_package( + PACKAGE_BASE_NAME ${base_name} + EXTRA_CMAKE_FILES + "${extra_file_base_path}ToolsExtraInclude.cmake" + EXTRA_CMAKE_INCLUDES + "${QT_CMAKE_EXPORT_NAMESPACE}${base_name}ToolsExtraInclude.cmake" +) + +# Check that we can add third party dependencies to the tools package. +qt_internal_record_tools_package_extra_third_party_dependency( + PACKAGE_BASE_NAME ${base_name} + DEPENDENCY_PACKAGE_NAME WrapScrewdriver) + +# Add a module that should be look up the standalone tools package when the module itself is +# looked up. +qt_internal_add_module(Workshop + HEADER_MODULE + NO_MODULE_HEADERS + NO_PRIVATE_MODULE + NO_GENERATE_CPP_EXPORTS + NO_ADDITIONAL_TARGET_INFO + NO_GENERATE_METATYPES + NO_PACKAGE_CONFIG_FILE + NO_MODULE_JSON_FILE + NO_QMAKE_SUPPORT_FILES +) +qt_record_extra_qt_main_tools_package_dependency(Workshop GarageTools "6") + +qt_build_repo_post_process() +qt_build_repo_end() diff --git a/tests/auto/cmake/RunCMake/StandaloneToolsPackage/cmake/FindWrapScrewdriver.cmake b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/cmake/FindWrapScrewdriver.cmake new file mode 100644 index 00000000000..484dc8f35d8 --- /dev/null +++ b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/cmake/FindWrapScrewdriver.cmake @@ -0,0 +1,2 @@ +set(WrapScrewdriver_FOUND TRUE) +set(QT_SCREW_DRIVER_LOADED TRUE) diff --git a/tests/auto/cmake/RunCMake/StandaloneToolsPackage/consume_tools_package.cmake b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/consume_tools_package.cmake new file mode 100644 index 00000000000..9b37905d569 --- /dev/null +++ b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/consume_tools_package.cmake @@ -0,0 +1,16 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +find_package(Qt6 REQUIRED COMPONENTS GarageTools) + +if(NOT QT_GARAGE_TOOLS_CONFIG_EXTRAS_LOADED) + message(FATAL_ERROR "Qt6GarageToolsConfigExtras.cmake was not loaded.") +endif() + +if(NOT QT_GARAGE_TOOLS_EXTRA_INCLUDE_LOADED) + message(FATAL_ERROR "Qt6GarageToolsExtraInclude.cmake was not loaded.") +endif() + +if(NOT QT_SCREW_DRIVER_LOADED) + message(FATAL_ERROR "FindWrapScrewdriver.cmake was not loaded.") +endif() diff --git a/tests/auto/cmake/RunCMake/StandaloneToolsPackage/consume_tools_package_via_module.cmake b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/consume_tools_package_via_module.cmake new file mode 100644 index 00000000000..4fe592a1f69 --- /dev/null +++ b/tests/auto/cmake/RunCMake/StandaloneToolsPackage/consume_tools_package_via_module.cmake @@ -0,0 +1,16 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +find_package(Qt6 REQUIRED COMPONENTS Workshop) + +if(NOT QT_GARAGE_TOOLS_CONFIG_EXTRAS_LOADED) + message(FATAL_ERROR "Qt6GarageToolsConfigExtras.cmake was not loaded.") +endif() + +if(NOT QT_GARAGE_TOOLS_EXTRA_INCLUDE_LOADED) + message(FATAL_ERROR "Qt6GarageToolsExtraInclude.cmake was not loaded.") +endif() + +if(NOT QT_SCREW_DRIVER_LOADED) + message(FATAL_ERROR "FindWrapScrewdriver.cmake was not loaded.") +endif() diff --git a/tests/auto/corelib/text/qlocaledata/tst_qlocaledata.cpp b/tests/auto/corelib/text/qlocaledata/tst_qlocaledata.cpp index a63dea4c679..93024bb4a6c 100644 --- a/tests/auto/corelib/text/qlocaledata/tst_qlocaledata.cpp +++ b/tests/auto/corelib/text/qlocaledata/tst_qlocaledata.cpp @@ -260,7 +260,7 @@ void tst_QLocaleData::numericData_data() << u"\u00D7\u06F1\u06F0^"_s << GS(1, 3, 3) << U'\u06F0' << false; // Grouping separator variants: - QTest::newRow("gsw-Latn-CH/exp") // Right single quote for grouping: + QTest::newRow("gsw-Latn-CH/exp") // Uses apostrophe for grouping (matching C++): << LOCALE_DATA_PTR(SwissGerman, LatinScript, Switzerland) << QLocaleData::DoubleScientificMode << u"."_s << u"'"_s << u"\u2212"_s << u"+"_s << u"E"_s diff --git a/tests/auto/corelib/text/qstring/tst_qstring.cpp b/tests/auto/corelib/text/qstring/tst_qstring.cpp index db2b18a5c01..8217da843e0 100644 --- a/tests/auto/corelib/text/qstring/tst_qstring.cpp +++ b/tests/auto/corelib/text/qstring/tst_qstring.cpp @@ -9409,7 +9409,7 @@ void tst_QString::rawData() void tst_QString::testUtf16() { { - const char16_t arr[] = {'a', 'b', 'c'}; + constexpr char16_t arr[] = {u'a', u'b', u'c'}; QString s = QString::fromRawData(arr, 3); // doesn't guarantee null-termination QCOMPARE(s.size(), qsizetype(std::size(arr))); // The string points to the raw data |
