From 11891ae9c9fcf7cb911648675eca83f3189ccbed Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Tue, 3 Jan 2023 14:42:33 +0100 Subject: [PATCH] Skip tests outside of qtbase on batching+superbuild The batcher does not currently work properly with non-qtbase submodules. Disable them temporarily so that at least the tests in qtbase are batched. Do this from qtbase so that changes to each and every submodule are not necessary. Also, maintain a list of tests that were thus skipped. On any qt cmake internal function call that refers to such a target, identify the target as skipped and make the call a no-op. Fixes: QTBUG-109785 Change-Id: Ib0aa5d39eee8315ffd4ac62f6d1f44fe9bbf7a2f Reviewed-by: Alexandru Croitor --- cmake/QtResourceHelpers.cmake | 4 ++++ cmake/QtTargetHelpers.cmake | 8 +++++++ cmake/QtTestHelpers.cmake | 40 +++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/cmake/QtResourceHelpers.cmake b/cmake/QtResourceHelpers.cmake index 3dcad1f5d8..2df1fed50f 100644 --- a/cmake/QtResourceHelpers.cmake +++ b/cmake/QtResourceHelpers.cmake @@ -5,6 +5,10 @@ function(qt_internal_add_resource target resourceName) if(NOT TARGET "${target}") message(FATAL_ERROR "${target} is not a target.") endif() + qt_internal_is_skipped_test(skipped ${target}) + if(skipped) + return() + endif() qt_internal_is_in_test_batch(in_batch ${target}) if(in_batch) _qt_internal_test_batch_target_name(target) diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index 4bb187a44e..183baa8da4 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -20,6 +20,10 @@ function(qt_internal_extend_target target) if(NOT TARGET "${target}") message(FATAL_ERROR "${target} is not a target.") endif() + qt_internal_is_skipped_test(skipped ${target}) + if(skipped) + return() + endif() qt_internal_is_in_test_batch(in_batch ${target}) if(in_batch) _qt_internal_test_batch_target_name(target) @@ -1075,6 +1079,10 @@ function(qt_internal_undefine_global_definition target) if(NOT TARGET "${target}") message(FATAL_ERROR "${target} is not a target.") endif() + qt_internal_is_skipped_test(skipped ${target}) + if(skipped) + return() + endif() qt_internal_is_in_test_batch(in_batch ${target}) if(in_batch) _qt_internal_test_batch_target_name(target) diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake index 945311b4a7..463229abd5 100644 --- a/cmake/QtTestHelpers.cmake +++ b/cmake/QtTestHelpers.cmake @@ -398,6 +398,34 @@ function(qt_internal_is_in_test_batch out name) endif() endfunction() +function(qt_internal_is_skipped_test out name) + get_target_property(is_skipped_test ${name} _qt_is_skipped_test) + set(${out} ${is_skipped_test} PARENT_SCOPE) +endfunction() + +function(qt_internal_set_skipped_test name) + set_target_properties(${name} PROPERTIES _qt_is_skipped_test TRUE) +endfunction() + +function(qt_internal_is_qtbase_test out) + get_filename_component(dir "${CMAKE_CURRENT_BINARY_DIR}" ABSOLUTE) + set(${out} FALSE PARENT_SCOPE) + + while(TRUE) + get_filename_component(filename "${dir}" NAME) + if("${filename}" STREQUAL "qtbase") + set(${out} TRUE PARENT_SCOPE) + break() + endif() + + set(prev_dir "${dir}") + get_filename_component(dir "${dir}" DIRECTORY) + if("${dir}" STREQUAL "${prev_dir}") + break() + endif() + endwhile() +endfunction() + function(qt_internal_get_batched_test_arguments out testname) if(WASM) # Add a query string to the runner document, so that the script therein @@ -434,6 +462,18 @@ function(qt_internal_add_test name) ) _qt_internal_validate_all_args_are_parsed(arg) + if(QT_BUILD_TESTS_BATCHED AND QT_SUPERBUILD AND NOT arg_NO_BATCH AND NOT arg_QMLTEST) + qt_internal_is_qtbase_test(is_qtbase_test) + if(NOT is_qtbase_test) + file(GENERATE OUTPUT "dummy${name}.cpp" CONTENT "int main() { return 0; }") + # Add a dummy target to tackle some potential problems + qt_internal_add_executable(${name} SOURCES "dummy${name}.cpp") + # Batched tests outside of qtbase are unsupported and skipped + qt_internal_set_skipped_test(${name}) + return() + endif() + endif() + if (NOT arg_OUTPUT_DIRECTORY) set(arg_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") endif()