Merge integration refs/builds/qtci/dev/1617880670

This commit is contained in:
Qt CI Bot 2021-04-08 16:21:16 +00:00
commit 9690e7bdd3
9 changed files with 97 additions and 4 deletions

View File

@ -221,8 +221,6 @@ function(qt_internal_add_test name)
INCLUDE_DIRECTORIES
${private_includes}
DEFINES
QT_TESTCASE_BUILDDIR="${CMAKE_CURRENT_BINARY_DIR}"
QT_TESTCASE_SOURCEDIR="${CMAKE_CURRENT_SOURCE_DIR}"
${arg_DEFINES}
PUBLIC_LIBRARIES ${QT_CMAKE_EXPORT_NAMESPACE}::Core ${QT_CMAKE_EXPORT_NAMESPACE}::Test ${arg_PUBLIC_LIBRARIES}
LIBRARIES ${arg_LIBRARIES}

View File

@ -110,6 +110,16 @@ qt_internal_extend_target(Test CONDITION MACOS
${FWIOKit}
)
set(qt_tc_build_dir "$<TARGET_PROPERTY:QT_TESTCASE_BUILDDIR>")
set(qt_bool_tc_build_dir "$<BOOL:${qt_tc_build_dir}>")
set(qt_tc_build_dir_def
"$<IF:${qt_bool_tc_build_dir},${qt_tc_build_dir},$<TARGET_PROPERTY:BINARY_DIR>>"
)
set_property(TARGET Test PROPERTY INTERFACE_COMPILE_DEFINITIONS
QT_TESTCASE_BUILDDIR="${qt_tc_build_dir_def}"
QT_TESTCASE_SOURCEDIR="$<TARGET_PROPERTY:SOURCE_DIR>"
)
# special case begin
# Do not bother with disabled stuff:
# qt_internal_extend_target(Test CONDITION (MACOS) AND (OFF AND NOT lessThan(QMAKE_XCODE_VERSION, "6.0")) ...

View File

@ -522,6 +522,10 @@
absolute paths to the source files are passed to the compiler. Otherwise, the
absolute path of the source directory cannot be determined.
\note The \c{QT_TESTCASE_BUILDDIR} macro is also implicitly defined if CMake is used
and the QtTest module is linked to the target. You can change the default
\c{QT_TESTCASE_BUILDDIR} by setting the QT_TESTCASE_BUILDDIR property on the target.
\note For tests that use the \l QTEST_APPLESS_MAIN() macro to generate a
\c{main()} function, \c{QFINDTESTDATA} will not attempt to find test data
relative to QCoreApplication::applicationDirPath(). In practice, this means that

View File

@ -112,6 +112,10 @@ if (CMAKE_GENERATOR STREQUAL Ninja AND UNIX AND NOT WIN32)
BINARY "tests/test_QFINDTESTDATA"
SIMULATE_IN_SOURCE
)
_qt_internal_test_expect_pass(test_QT_TESTCASE_BUILDDIR
BINARY "test_qt_testcase_builddir"
SIMULATE_IN_SOURCE
)
endif()
if (NOT NO_DBUS)

View File

@ -2,5 +2,3 @@
add_executable(test_QFINDTESTDATA WIN32 main.cpp)
target_link_libraries(test_QFINDTESTDATA Qt::Test)
target_compile_definitions(test_QFINDTESTDATA PRIVATE QT_TESTCASE_BUILDDIR="${CMAKE_CURRENT_BINARY_DIR}")
target_compile_definitions(test_QFINDTESTDATA PRIVATE QT_TESTCASE_SOURCEDIR="${CMAKE_CURRENT_SOURCE_DIR}")

View File

@ -0,0 +1,20 @@
# The test is simply testing that manual specification of QT_TESTCASE_BUILDDIR works,
# despite the weird paths.
cmake_minimum_required(VERSION 3.14)
project(test_qt_testcase_builddir)
find_package(Qt6Test REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_executable(test_qt_testcase_builddir WIN32 main.cpp)
target_link_libraries(test_qt_testcase_builddir Qt::Test)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/testdata.txt"
"${CMAKE_CURRENT_BINARY_DIR}/level1/level2/testdata_build.txt"
COPYONLY
)
set_target_properties(test_qt_testcase_builddir PROPERTIES
QT_TESTCASE_BUILDDIR "${CMAKE_CURRENT_BINARY_DIR}/level1/level2"
)

View File

@ -0,0 +1 @@
This is the test data found in QT_TESTCASE_SOURCEDIR.

View File

@ -0,0 +1,57 @@
/****************************************************************************
**
** Copyright (C) 2021 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QCoreApplication>
#include <QtTest/QTest>
#include <QDebug>
class TestClass : public QObject
{
Q_OBJECT
public:
TestClass(QObject *parent = nullptr) { }
private slots:
void doTest();
};
void TestClass::doTest()
{
QFile fsrc(QFINDTESTDATA("data/testdata.txt"));
QVERIFY(fsrc.open(QFile::ReadOnly));
QCOMPARE(fsrc.readAll().trimmed(),
QByteArrayLiteral("This is the test data found in QT_TESTCASE_SOURCEDIR."));
QFile fbuild(QFINDTESTDATA("level2/testdata_build.txt"));
QVERIFY(fbuild.open(QFile::ReadOnly));
QCOMPARE(fbuild.readAll().trimmed(),
QByteArrayLiteral("This is the test data found in custom QT_TESTCASE_BUILDDIR."));
}
QTEST_MAIN(TestClass)
#include "main.moc"

View File

@ -0,0 +1 @@
This is the test data found in custom QT_TESTCASE_BUILDDIR.