summaryrefslogtreecommitdiffstats
path: root/cmake/QtTestHelpers.cmake
diff options
context:
space:
mode:
authorPiotr Wierciński <piotr.wiercinski@qt.io>2023-09-07 15:13:01 +0200
committerPiotr Wierciński <piotr.wiercinski@qt.io>2023-09-14 11:58:48 +0200
commit9468ef2cfb9a3ebe14382427b67aaafbbad7d847 (patch)
tree104ee997bc2fb0fddac59180e3a293b6e9ef9b5c /cmake/QtTestHelpers.cmake
parent5ac97a38e840da4dad0d5b0e1acbf2ecb46ecf74 (diff)
CI: Enable some tests under corelib/thread for Wasm platform
This is part of our testing effort where we try enabling more tests for Web Assembly platform on CI. Not all tests work out of box, so some of them will require followup work. This commmit also introduces a new mechanism of automatically renaming files when they are added many times with the same filename to single translation unit. Change-Id: I620536494ea83aeb9b294c4a35ef72b51e85a38b Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Diffstat (limited to 'cmake/QtTestHelpers.cmake')
-rw-r--r--cmake/QtTestHelpers.cmake39
1 files changed, 29 insertions, 10 deletions
diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake
index 4978f95538..daa24ef70d 100644
--- a/cmake/QtTestHelpers.cmake
+++ b/cmake/QtTestHelpers.cmake
@@ -315,6 +315,34 @@ function(qt_internal_add_test_to_batch batch_name name)
list(PREPEND batched_test_list ${name})
set_property(GLOBAL PROPERTY _qt_batched_test_list_property ${batched_test_list})
+ # Test batching produces single executable which can result in one source file being added
+ # multiple times (with different definitions) to one translation unit. This is not supported by
+ # CMake so instead we try to detect such situation and rename file every time it's added
+ # to the build more than once. This avoids filenames collisions in one translation unit.
+ get_property(batched_test_sources_list GLOBAL PROPERTY _qt_batched_test_sources_list_property)
+ if(NOT batched_test_sources_list)
+ set_property(GLOBAL PROPERTY _qt_batched_test_sources_list_property "")
+ set(batched_test_sources_list "")
+ endif()
+ foreach(source ${arg_SOURCES})
+ set(source_path ${source})
+ if(${source} IN_LIST batched_test_sources_list)
+ set(new_filename ${name}.cpp)
+ configure_file(${source} ${new_filename})
+ set(source_path ${CMAKE_CURRENT_BINARY_DIR}/${new_filename})
+ set(skip_automoc ON)
+ list(APPEND arg_SOURCES ${source_path})
+ else()
+ set(skip_automoc OFF)
+ list(APPEND batched_test_sources_list ${source})
+ endif()
+ set_source_files_properties(${source_path}
+ TARGET_DIRECTORY ${target} PROPERTIES
+ SKIP_AUTOMOC ${skip_automoc}
+ COMPILE_DEFINITIONS "BATCHED_TEST_NAME=\"${name}\";${arg_DEFINES}")
+ endforeach()
+ set_property(GLOBAL PROPERTY _qt_batched_test_sources_list_property ${batched_test_sources_list})
+
# Merge the current test with the rest of the batch
qt_internal_extend_target(${target}
INCLUDE_DIRECTORIES ${arg_INCLUDE_DIRECTORIES}
@@ -330,15 +358,6 @@ function(qt_internal_add_test_to_batch batch_name name)
NO_UNITY_BUILD # Tests should not be built using UNITY_BUILD
)
- foreach(source ${arg_SOURCES})
- # We define the test name which is later used to launch this test using
- # commandline parameters. Target directory is that of the target test_batch,
- # otherwise the batch won't honor our choices of compile definitions.
- set_source_files_properties(${source}
- TARGET_DIRECTORY ${target}
- PROPERTIES COMPILE_DEFINITIONS
- "BATCHED_TEST_NAME=\"${name}\";${arg_DEFINES}" )
- endforeach()
set(${batch_name} ${target} PARENT_SCOPE)
# Add a dummy target so that new tests don't have problems with a nonexistent
@@ -616,7 +635,7 @@ function(qt_internal_add_test name)
# TODO: Add functionality to specify browser
list(APPEND extra_test_args "--browser=chrome")
list(APPEND extra_test_args "--browser_args=\"--password-store=basic\"")
- list(APPEND extra_test_args "--kill_exit")
+ #list(APPEND extra_test_args "--kill_exit")
# Tests may require asyncify if they use exec(). Enable asyncify for
# batched tests since this is the configuration used on the CI system.