summaryrefslogtreecommitdiffstats
path: root/cmake/QtTestHelpers.cmake
diff options
context:
space:
mode:
authorAssam Boudjelthia <[email protected]>2024-10-07 17:43:31 +0300
committerAssam Boudjelthia <[email protected]>2024-10-16 20:40:08 +0300
commita905d26f14da1cf86b8490331c0cc41c2a45b283 (patch)
tree9579bfbd65adadb15eb7ccd5a38421484a60a1b9 /cmake/QtTestHelpers.cmake
parent1d0ec32f71e24760780d826fd4560bac7d2348d5 (diff)
CMake:Android: add wrapper scripts to easily run apps
Create a script that allows running an app or a test easily similar to running on host. This improves development workflow and time by allowing quick runs without having to manually call the various adb commands to launch, get a pid of the app and then print the logcat, let alone passing parameters or environment variables. For normal apps, the app package name is retrieved by the script, run and live logcat is printed as long as the app is still running. For tests, the script calls androidtestrunner, allowing test parameters to be passed to the test. For CI debugging, this would save quite a lot of hussle and frustration trying to run or debug a test app. One other benefit for this is enabling running Android tests from Qt Creator's testlib plugin without big changes to Qt Creator to support androidtestrunner explicitly. Because file(GENERATE) would fail if called twice for the same file, I use file(WRITE). This is used because at the time of calling the target executable finalizer, we don't know if the target is a test or not, so we rely on writing the script first as a normal target, then call it if the target is a test where it overrides the script. For this also, parameters passed to the runner or androidtestrunner can't handle generator expressions. [ChangeLog][CMake][Android] Add wrapper scripts to run Android apps and tests with ease from the host. Task-number: QTBUG-129889 Change-Id: I84e85ce2bbf6944c8aa20bdc2c2b6d7b956bc748 Reviewed-by: Alexey Edelev <[email protected]>
Diffstat (limited to 'cmake/QtTestHelpers.cmake')
-rw-r--r--cmake/QtTestHelpers.cmake24
1 files changed, 18 insertions, 6 deletions
diff --git a/cmake/QtTestHelpers.cmake b/cmake/QtTestHelpers.cmake
index 42cbb2180bd..289c2690c94 100644
--- a/cmake/QtTestHelpers.cmake
+++ b/cmake/QtTestHelpers.cmake
@@ -250,11 +250,19 @@ function(qt_internal_add_test_to_batch batch_name name)
# Lazy-init the test batch
if(NOT TARGET ${target})
+ if(${arg_MANUAL})
+ set(is_manual "QT_MANUAL_TEST")
+ else()
+ set(is_manual "")
+ endif()
+
qt_internal_add_executable(${target}
${exceptions_text}
${gui_text}
${version_arg}
NO_INSTALL
+ QT_TEST
+ ${is_manual}
OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/build_dir"
SOURCES "${QT_CMAKE_DIR}/qbatchedtestrunner.in.cpp"
DEFINES QTEST_BATCH_TESTS ${deprecation_define}
@@ -273,8 +281,6 @@ function(qt_internal_add_test_to_batch batch_name name)
set_property(TARGET ${target} PROPERTY _qt_has_gui ${arg_GUI})
set_property(TARGET ${target} PROPERTY _qt_has_lowdpi ${arg_LOWDPI})
set_property(TARGET ${target} PROPERTY _qt_version ${version_arg})
- set_property(TARGET ${target} PROPERTY _qt_is_test_executable TRUE)
- set_property(TARGET ${target} PROPERTY _qt_is_manual_test ${arg_MANUAL})
else()
# Check whether the args match with the batch. Some differences between
# flags cannot be reconciled - one should not combine these tests into
@@ -512,11 +518,19 @@ function(qt_internal_add_test name)
qt_internal_prepare_test_target_flags(version_arg exceptions_text gui_text ${ARGN})
+ if(${arg_MANUAL})
+ set(is_manual "QT_MANUAL_TEST")
+ else()
+ set(is_manual "")
+ endif()
+
qt_internal_add_executable("${name}"
${exceptions_text}
${gui_text}
${version_arg}
NO_INSTALL
+ QT_TEST
+ ${is_manual}
OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
SOURCES "${arg_SOURCES}"
INCLUDE_DIRECTORIES
@@ -579,8 +593,6 @@ function(qt_internal_add_test name)
qt_internal_extend_target("${name}" CONDITION ANDROID
LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::Gui
)
- set_target_properties(${name} PROPERTIES _qt_is_test_executable TRUE)
- set_target_properties(${name} PROPERTIES _qt_is_manual_test ${arg_MANUAL})
set(blacklist_file "${CMAKE_CURRENT_SOURCE_DIR}/BLACKLIST")
if(EXISTS ${blacklist_file})
@@ -653,8 +665,8 @@ function(qt_internal_add_test name)
"This is fine if OpenSSL was built statically.")
endif()
endif()
- qt_internal_android_test_arguments(
- "${name}" "${android_timeout}" test_executable extra_test_args)
+ qt_internal_android_test_runner_arguments("${name}" test_executable extra_test_args)
+ list(APPEND extra_test_args "--timeout" "${android_timeout}" "--verbose")
set(test_working_dir "${CMAKE_CURRENT_BINARY_DIR}")
elseif(QNX)
set(test_working_dir "")