summaryrefslogtreecommitdiffstats
path: root/cmake/QtTestHelpers.cmake
Commit message (Collapse)AuthorAgeFilesLines
* CMake: Remove WinRT leftovers from build systemYuhang Zhao2021-12-181-1/+1
| | | | | | | Qt's WinRT support was removed long time ago. Change-Id: I60b220e970072c3450e3793862d6f68801d2b5b3 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Fix exit code to be shown properly on test failureAlexandru Croitor2021-12-171-1/+1
| | | | | | | | | | | | | | | | | | | | The result variable was expanded at configure time rather than at script execution time due to missing escaping. A tidbit of information, the result variable can contain not only an exit code, but a string as well. For example on arm macOS with a crashed test it contains 'SIGTRAP'. Curiously if the crashing executable is executed directly without CMake, 'Trace/BPT trap: 5' is shown instead, perhaps because of the shell. Amends 3ef6af024be43bc18352796df61542a241192583 Pick-to: 6.2 6.3 Change-Id: I50e57922abfc6eccde205c6252eebfda510bad41 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QtTestHelpers: print exit code upon failureFabian Kosmale2021-12-151-1/+1
| | | | | | | | This might give a few insights into why the process has failed, at least if distinct return values are used for different errors. Change-Id: I61fe0ede812c4dda3d0cf0f2c96a479d198d340d Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Add missing dependency of ${target}_check to ${target}_make_apkAlexey Edelev2021-11-261-0/+3
| | | | | | | | | | When building for and running the '_check' target in Android we need to make sure that target apk is assembled and ready for deployment. Pick-to: 6.2 Change-Id: Ifc63aac230f0bb8375d319ec443174c5a436485e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* QNX: Generate empty string for WORKING_DIRECTORY test wrapperPasi Petäjäjärvi2021-10-271-1/+4
| | | | | | | | | | | | Tests for QNX are run in qemu over ssh and setting WORKING_DIRECTORY will cause created test wrapper to try change specified directory which will fail (expects local directory) when test is invoked over ssh. Task-number: QTBUG-87628 Pick-to: 6.2 Change-Id: If991002398811cc9cb9cbac54da5d2cb0d8c3589 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* testlib: Update a few remaining instances of the deprecated -xunitxml formatTor Arne Vestbø2021-07-291-1/+1
| | | | | | | | The format was renamed in 27db9e458cef512fca3a6b5c9ebbcda7a8172428. Pick-to: 6.2 Change-Id: I53975c7467d8768dc9dc9ac2d89c42eefa12e22f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* cmake: Add repository name to test labels for qt5 buildsTor Arne Vestbø2021-05-181-1/+7
| | | | | Change-Id: Icb23f2ea885f6d21bef80c587a431f7e9349f21b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Allow usage of QtStandaloneTestTemplateProject as package componentCristian Adam2021-04-231-12/+14
| | | | | | | | | | | | | | | | | | | | | | | Currently in order to compile a Qt6 test standalone one needs to use the qt-cmake-standalone-test script which will load the Qt6BuildInternals/QtStandaloneTestTemplateProject/CMakeLists.txt project with the current test source directory to create a complete CMake project. This commit will allow a test to have these lines at top: cmake_minimum_required(VERSION 3.16) if (NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) project(a_qt_test LANGUAGES C CXX ASM) find_package(Qt6BuildInternals COMPONENTS STANDALONE_TEST) endif() and be standalone and work with any IDE capable of loading CMake projects. Fixes: QTCREATORBUG-25389 Pick-to: 6.1 Change-Id: If3f878b7e560a8bfbb604a8f1aa30b7962742e66 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Specify QT_TESTCASE_BUILDDIR for Qt::Test users implicitlyAlexey Edelev2021-04-081-2/+0
| | | | | | | | | | | | | | | | | | | QT_TESTCASE_BUILDDIR was implicitly defined by Qt::Test target for library users in Qt5. By default, this definition will point to CMAKE_CURRENT_BINARY_DIR. This logic works similarly to qmake logic. From user's perspective it might be useful to not rely on standard search paths, but specify own. This can be done by setting the QT_TESTCASE_BUILDDIR property for the user's target. CMake will substute the value of the QT_TESTCASE_BUILDDIR property into the QT_TESTCASE_BUILDDIR definition. The implicit QT_TESTCASE_SOURCEDIR also seems to be useful. According to the current logic, it points to CMAKE_CURRENT_SOURCE_DIR. Fixes: QTBUG-92079 Change-Id: I8a9065f08e859c713b3c8cc08142a9ced0677770 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Don't attempt to add to a target that doesn't existMårten Nordheim2021-03-171-2/+4
| | | | | | | | | | When configuring a benchmark using the standalone-test script the 'benchmark' target is not available, causing a configure error. Pick-to: 6.1 6.0 Change-Id: I8e480c9e72b47783c0910428187f0092049e89db Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* cmake: Do not hard-code test argumentsTor Arne Vestbø2021-02-151-5/+0
| | | | | | | | | Tests should follow their default output of txt as when run directly, and any output configuration should be handled by the CI system. Change-Id: Id0d72318df5edad1c58ac637e827d6043884e829 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Toni Saario <toni.saario@qt.io>
* CMake: add Qt::Gui dependency by default for Android testsAssam Boudjelthia2021-02-111-1/+5
| | | | | | | | | | | | | | | | | Normal Android apps require Qt::Gui dependency and since tests don't need to handle any special cases for an app without Qt::Gui, let's add it by default. This also will allow us to remove some workarounds done on CI side to run tests for Android. Fixes: QTBUG-90870 Pick-to: 6.0 6.1 Change-Id: I845650c17a1b73e4c4977043f863ec44e50f06c3 Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: BogDan Vatra <bogdan@kdab.com>
* Fix warning in generated test wrappersAlexey Edelev2021-01-131-1/+2
| | | | | | | | | | | | | Since test command variable may contain quotes, there is a warning in generated test wrappers related to 'message(FATAL_ERROR', that should display full command in log in case of error. To avoid any complicated quoting of command to only display it, join command into single string in wrapper script and pass resulting variable to 'message(FATAL_ERROR'. Pick-to: 6.0 Change-Id: Ie990fc0b0bf2c19b119c7c4e2aeec092e5200103 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* Fix the CMake feature for docker-testserver to use correct mkspecs pathSona Kurazyan2020-12-231-1/+1
| | | | | | | | | | | Use the QT_MKSPECS_DIR instead of QT_SOURCE_TREE to find out the location for the testserver feature's data. QT_SOURCE_TREE points to qtbase source location, which may not be always available. This allows to use this feature by projects outside of qtbase. Task-number: QTBUG-85034 Change-Id: If7fa6ef95777be9acf35d36f8d99776bf9568a79 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* Allow other projects to use the CMake feature for docker-based testsSona Kurazyan2020-12-221-1/+5
| | | | | | | | | | | Introduce a new QT_TESTSERVER_COMPOSE_FILE variable for setting a custom docker compose file path, which can be set by projects outside of qtbase (e.g. QtCoap). If the variable is not set, fallback to the compose file located in qtbase. Task-number: QTBUG-85034 Change-Id: I4c0c9b161cad9787b089ef7e9da2aa00352a9159 Reviewed-by: Cristian Adam <cristian.adam@qt.io>
* CMake: Wrap benchmarks with cmake scriptAlexey Edelev2020-12-101-42/+57
| | | | | | | | | | | | | | | | | Wrap benchmark executable target with cmake script to run it on windows without necessity of environment variables set. Move common logic related to test and benchmark environment to 'qt_internal_collect_command_environment' function. Make error message of wrapper script a bit more verbose. Amends 61d5b019727dd1c06366205cb307a2a928a2a29c Task-number: QTBUG-89076 Pick-to: 6.0 Change-Id: I6ad3a027dc071176070cf3af4cf306f20d652039 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Use test wrapper to run android testsAlexey Edelev2020-12-101-67/+157
| | | | | | | | | | | | | | | | | | | | Refactor test adding procedure. It's expected that for each new platform we prepare test executable and arguments first and then pass them to common test adding section. Rename '_qt_internal_wrap_test' to 'qt_internal_create_command_script' Rework paramerters handling of 'qt_internal_create_command_script', make them named. Add 'qt_internal_create_test_script' to add tests and wrap them using 'qt_internal_create_command_script'. Amends f19266bd02a01d4b7b277ea769c4c17727b1e661 Fixes: QTBUG-88053 Pick-to: 6.0 Change-Id: I812f4a295005bf3a85cdcb5b8c41180f8249dc96 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Improve tests wrapper arguments handlingAlexey Edelev2020-12-081-2/+15
| | | | | | | | | | | | Use 'separate_arguments' to explicitly split arguments from environment that form 'COMMAND' for execute_process. Enclose using bracket syntax arguments, that propagated to wrapper script as pure strings. Amends f19266bd02a01d4b7b277ea769c4c17727b1e661 Pick-to: 6.0 Change-Id: I858ddff7efa281f9cecfda656a02e1fd12361758 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Force crosscompiling_emulator to empty string if not foundAlexey Edelev2020-12-071-3/+6
| | | | | | | | | | | | | In some case CROSSCOMPILING_EMULATOR property is not INHERITED and is set to 'NOTFOUND' by get_test_property. Force it to empty string in this case. Add missed 'name' argument to '_qt_internal_wrap_test'. 'name' previously was used from parent scope. Pick-to: 6.0 Fixes: QTBUG-88053 Change-Id: I5286bcb9b11659f638e178ce52172dfee994fc34 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Add extra targets to run single benchmark using CMake generatorAlexey Edelev2020-12-071-0/+11
| | | | | | | | | | | | | | | | | | Add custom targets with '_benchmark' suffixes to make run of benchmarks using generators possible, e.g.: $ ninja tst_bench_qudpsocket_benchmark Extend '-[no]make' option to pass benchmark. Rework '-[no]make' processing to unify these options processing. Also looks like it doesn't make sense to enable benchmarks without having test enabled. So '-DQT_BUILD_BENCHMARKS' enables test as own dependency automatically. Task-number: QTBUG-89076 Pick-to: 6.0 Change-Id: Ieee9eadaf6d75a1efec120242d6eb786ace1b071 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Add handling of TESTRUNNER and TESTARGS by Qt testsAlexey Edelev2020-12-041-36/+137
| | | | | | | | | | | | Wrap Qt tests to handle TESTRUNNER and TESTARGS environment variables. Variables are handled according to qmake build procedure. All test now are wrapped by generated CMake script. Fixes: QTBUG-88053 Pick-to: 6.0 Change-Id: I339977ce6ce11ddd38a4bf0bd26eb8f2ae463ba3 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Enable exceptions by defaultMårten Nordheim2020-11-161-3/+7
| | | | | | | | Without breaking currently generated CMakeLists Fixes: QTBUG-88549 Change-Id: Ibda643e1374d9024bf693c12de8ec0ac46e09b7b Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Rename some additional functions that should be internalAlexandru Croitor2020-10-121-2/+2
| | | | | | | | | Amends e0c62a48b8a826a46a143e57e94b2a0ea73c7cae Task-number: QTBUG-86815 Change-Id: Ic65d8dda1aed390c78408616fb22f38edd2e1dce Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* CMake: Fix leftover usage of qt_add_executableAlexandru Croitor2020-10-071-24/+24
| | | | | | | | | | | All usages should be replaced with qt_internal_add_executable instead. This should fix configuration failure of benchmarks and manual tests. Amends e0c62a48b8a826a46a143e57e94b2a0ea73c7cae Task-number: QTBUG-86815 Change-Id: I0791d849998ed9517e32f699d843367949b97cb9 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* CMake: Rename internal functions to contain qt_internalAlexandru Croitor2020-09-231-9/+9
| | | | | | | | | | Offer compatibility wrapper functions until we update all of the Qt repos to use the new names. Task-number: QTBUG-86815 Change-Id: I5826a4116f52a8509db32601ef7c200f9bd331de Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* CMake Build: Add qtnetwork docker testserver supportCristian Adam2020-09-171-1/+72
| | | | | | | | | | | | | | | qt_add_test supports now QT_TEST_SERVER_LIST, which will add the test servers as docker test fixtures. The docker server will be started before the test is run, and stopped after the test is run. Running the tests in parallel is not supported. Docker tests are currently only supported on Linux hosts. Task-number: QTBUG-85034 Change-Id: If3cefe05c5dec19c14b05d2fa8b01a0b6d95e259 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* CMake: Split QtBuild.cmake into smaller filesAlexandru Croitor2020-08-141-0/+340
QtBuild.cmake is huge. Split it. Move module, plugin, tools, executables and test related functions out of QtBuild.cmake into separate files. Do the same for many other things too. An additional requirement is that all the new Helpers files only define functions and macros. No global variable definitions are allowed, nor execution of commands with side effects. Some notes: qt_install_qml_files is removed because it's dead code. Some functions still need to be figured out, because they are interspersed and depend on various global state assignments. Task-number: QTBUG-86035 Change-Id: I21d79ff02eef923c202eb1000422888727cb0e2c Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>