diff options
author | Sami Shalayel <[email protected]> | 2025-03-03 14:28:12 +0100 |
---|---|---|
committer | Sami Shalayel <[email protected]> | 2025-05-22 17:28:15 +0200 |
commit | 36de3c1aa8278aca973e44127f0e7ec0531ef18d (patch) | |
tree | 61a5ba2b268afd1d93cbd0d69a1d8b7818df8e25 | |
parent | b739545a12c5d28bed94609e4035d93e48b7e49a (diff) |
Add a test using runCMake to make sure that .qmlls.ini is updated when
the build folder changes.
The test is automatic and can be run locally via:
ctest -V -R RunCMake.generate_qmlls_ini
Pick-to: 6.8 6.9
Fixes: QTBUG-133793
Change-Id: Icde34425e8755e04dff454c3875e567ff29fcd6e
Reviewed-by: Alexandru Croitor <[email protected]>
4 files changed, 80 insertions, 0 deletions
diff --git a/tests/auto/cmake/RunCMake/CMakeLists.txt b/tests/auto/cmake/RunCMake/CMakeLists.txt index 5573203bf7..aac180192f 100644 --- a/tests/auto/cmake/RunCMake/CMakeLists.txt +++ b/tests/auto/cmake/RunCMake/CMakeLists.txt @@ -5,3 +5,6 @@ _qt_internal_get_cmake_test_configure_options(config_flags) if(NOT CMAKE_CROSSCOMPILING) add_RunCMake_test(qt_target_qml_sources ${config_flags} "-D_Qt6CTestMacros=${_Qt6CTestMacros}") endif() + +_qt_internal_get_cmake_test_configure_options(option_list) +add_RunCMake_test(generate_qmlls_ini ${option_list}) diff --git a/tests/auto/cmake/RunCMake/generate_qmlls_ini/CMakeLists.txt b/tests/auto/cmake/RunCMake/generate_qmlls_ini/CMakeLists.txt new file mode 100644 index 0000000000..ab5119af57 --- /dev/null +++ b/tests/auto/cmake/RunCMake/generate_qmlls_ini/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} LANGUAGES CXX) + +find_package(Qt6 REQUIRED COMPONENTS Qml Core) + +# Setting AUTOMOC to true to make sure Qt package is used +set(CMAKE_AUTOMOC ON) + +qt_standard_project_setup(REQUIRES 6.8) +qt_add_library(generate_qmlls_ini STATIC) +qt_add_qml_module(generate_qmlls_ini + URI generate_qmlls_ini + QML_FILES Main.qml +) diff --git a/tests/auto/cmake/RunCMake/generate_qmlls_ini/Main.qml b/tests/auto/cmake/RunCMake/generate_qmlls_ini/Main.qml new file mode 100644 index 0000000000..3052615aef --- /dev/null +++ b/tests/auto/cmake/RunCMake/generate_qmlls_ini/Main.qml @@ -0,0 +1,3 @@ +import QtQuick + +Item {} diff --git a/tests/auto/cmake/RunCMake/generate_qmlls_ini/RunCMakeTest.cmake b/tests/auto/cmake/RunCMake/generate_qmlls_ini/RunCMakeTest.cmake new file mode 100644 index 0000000000..23d5731f14 --- /dev/null +++ b/tests/auto/cmake/RunCMake/generate_qmlls_ini/RunCMakeTest.cmake @@ -0,0 +1,57 @@ +# Copyright (C) 2025 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +include(RunCMake) + +function(check_qmlls_ini expectedBuild) + set(sourceQmllsIni "${RunCMake_SOURCE_DIR}/.qmlls.ini") + + file(READ "${sourceQmllsIni}" qmllsIniContent) + + string(FIND "${qmllsIniContent}" "${expectedBuild}" result) + if(result EQUAL -1) + message(FATAL_ERROR "Test failed: qmlls.ini does not contain expected ${expectedBuild} " + "in its content:\n${qmllsIniContent}") + endif() +endfunction() + +function(buildProject name build) + set(RunCMake_TEST_BINARY_DIR "${build}") + run_cmake_command(${name} ${CMAKE_COMMAND} --build ${build}) +endfunction() + +set(build1 "${RunCMake_BINARY_DIR}/MyApplication-build1/generate_qmlls_ini") +set(build2 "${RunCMake_BINARY_DIR}/MyApplication-build2/generate_qmlls_ini") +set(expectedBuild1 "${RunCMake_BINARY_DIR}/MyApplication-build1") +set(expectedBuild2 "${RunCMake_BINARY_DIR}/MyApplication-build2") + +# configure and build the project into build1 +set(RunCMake_TEST_BINARY_DIR "${build1}") +run_cmake_with_options( + configuration1 + "-DQT_QML_GENERATE_QMLLS_INI=ON" + "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" +) +set(RunCMake_TEST_NO_CLEAN 1) +set(RunCMake_TEST_OUTPUT_MERGE 1) +buildProject(build1 "${build1}") + +# check qmlls.ini +check_qmlls_ini("${expectedBuild1}") + +# configure the project again into build2 +set(RunCMake_TEST_BINARY_DIR "${build2}") +run_cmake_with_options( + configuration2 + "-DQT_QML_GENERATE_QMLLS_INI=ON" + "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" +) +buildProject(build2 "${build2}") +check_qmlls_ini("${expectedBuild2}") + +#rebuild in previous build folder and check that qmlls gets updated: +buildProject(build1again "${build1}") +check_qmlls_ini("${expectedBuild1}") + +buildProject(build2again "${build2}") +check_qmlls_ini("${expectedBuild2}") |