From aa049ec2f2a920c20ab8ebf3afdb6926f5f2648c Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Fri, 13 Jan 2023 16:25:08 +0100 Subject: [PATCH] Concatenate blacklist files for test batch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This works by collecting the paths of all blacklist files and deferring a call which ultimately reads all of the files and glues them together to form a master blacklist file for the batch. There might be conflicting function names inside the batch. For now we ignore the problem, while keeping in mind that it exists. Fixes: QTBUG-110016 Change-Id: I9c8412097418c6e93297ab89af718d7466e2e451 Reviewed-by: Jörg Bornemann (cherry picked from commit 6a9e89121d7766a34c4281d298057bfbe8af36b3) Reviewed-by: Alexey Edelev --- cmake/QtSetup.cmake | 6 +++--- cmake/QtTestHelpers.cmake | 25 ++++++++++++++++++++++--- src/corelib/Qt6CoreMacros.cmake | 20 ++++++++++++++++++++ 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index 298f7b6fb90..aa98041411b 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -313,10 +313,10 @@ endif() option(QT_BUILD_TESTS_BATCHED "Link all tests into a single binary." ${_qt_batch_tests}) -if(QT_BUILD_TESTS AND QT_BUILD_TESTS_BATCHED AND CMAKE_VERSION VERSION_LESS "3.18") +if(QT_BUILD_TESTS AND QT_BUILD_TESTS_BATCHED AND CMAKE_VERSION VERSION_LESS "3.19") message(FATAL_ERROR - "Test batching requires at least CMake 3.18, due to requiring per-source " - "TARGET_DIRECTORY assignments.") + "Test batching requires at least CMake 3.19, due to requiring per-source " + "TARGET_DIRECTORY assignments and DEFER calls.") endif() # QT_BUILD_TOOLS_WHEN_CROSSCOMPILING -> QT_FORCE_BUILD_TOOLS diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake index 527aa56d8ca..98d04e3c967 100644 --- a/cmake/QtTestHelpers.cmake +++ b/cmake/QtTestHelpers.cmake @@ -667,10 +667,29 @@ function(qt_internal_add_test name) foreach(testdata IN LISTS arg_TESTDATA) list(APPEND builtin_files ${testdata}) endforeach() + foreach(file IN LISTS builtin_files) + set_source_files_properties(${file} + PROPERTIES QT_SKIP_QUICKCOMPILER TRUE + ) + endforeach() - set(blacklist_path "BLACKLIST") - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}") - list(APPEND builtin_files ${blacklist_path}) + if(setting_up_batched_test) + set(blacklist_path "BLACKLIST") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}") + get_target_property(blacklist_files ${name} _qt_blacklist_files) + if(NOT blacklist_files) + set_target_properties(${name} PROPERTIES _qt_blacklist_files "") + set(blacklist_files "") + cmake_language(EVAL CODE "cmake_language(DEFER DIRECTORY \"${CMAKE_SOURCE_DIR}\" CALL \"_qt_internal_finalize_batch\" \"${name}\") ") + endif() + list(PREPEND blacklist_files "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}") + set_target_properties(${name} PROPERTIES _qt_blacklist_files "${blacklist_files}") + endif() + else() + set(blacklist_path "BLACKLIST") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${blacklist_path}") + list(APPEND builtin_files ${blacklist_path}) + endif() endif() list(REMOVE_DUPLICATES builtin_files) diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake index 22da35f3e38..3cb7e37950b 100644 --- a/src/corelib/Qt6CoreMacros.cmake +++ b/src/corelib/Qt6CoreMacros.cmake @@ -660,6 +660,26 @@ function(_qt_internal_finalize_executable target) endif() endfunction() +function(_cat IN_FILE OUT_FILE) + file(READ ${IN_FILE} CONTENTS) + file(APPEND ${OUT_FILE} "${CONTENTS}\n") +endfunction() + +function(_qt_internal_finalize_batch name) + find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS Core) + + set(generated_blacklist_file "${CMAKE_CURRENT_BINARY_DIR}/BLACKLIST") + get_target_property(blacklist_files "${name}" _qt_blacklist_files) + file(WRITE "${generated_blacklist_file}" "") + foreach(blacklist_file ${blacklist_files}) + _cat("${blacklist_file}" "${generated_blacklist_file}") + endforeach() + qt_internal_add_resource(${name} "batch_blacklist" + PREFIX "/" + FILES "${CMAKE_CURRENT_BINARY_DIR}/BLACKLIST" + BASE ${CMAKE_CURRENT_BINARY_DIR}) +endfunction() + # If a task needs to run before any targets are finalized in the current directory # scope, call this function and pass the ID of that task as the argument. function(_qt_internal_delay_finalization_until_after defer_id)