diff options
Diffstat (limited to 'tests/auto/tools/macdeployqt')
5 files changed, 50 insertions, 137 deletions
diff --git a/tests/auto/tools/macdeployqt/CMakeLists.txt b/tests/auto/tools/macdeployqt/CMakeLists.txt index 073c2a9e70..5120b474ae 100644 --- a/tests/auto/tools/macdeployqt/CMakeLists.txt +++ b/tests/auto/tools/macdeployqt/CMakeLists.txt @@ -1,9 +1,16 @@ -# Generated from macdeployqt.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_macdeployqt Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_macdeployqt LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_macdeployqt SOURCES tst_macdeployqt.cpp diff --git a/tests/auto/tools/macdeployqt/source_basicapp/main.cpp b/tests/auto/tools/macdeployqt/source_basicapp/main.cpp index 093a882f32..1e2bb1a3a6 100644 --- a/tests/auto/tools/macdeployqt/source_basicapp/main.cpp +++ b/tests/auto/tools/macdeployqt/source_basicapp/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QGuiApplication> #include <QRasterWindow> diff --git a/tests/auto/tools/macdeployqt/source_plugin_sqlite/main.cpp b/tests/auto/tools/macdeployqt/source_plugin_sqlite/main.cpp index 31e2e8117c..12343141f8 100644 --- a/tests/auto/tools/macdeployqt/source_plugin_sqlite/main.cpp +++ b/tests/auto/tools/macdeployqt/source_plugin_sqlite/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtSql> diff --git a/tests/auto/tools/macdeployqt/source_plugin_tls/main.cpp b/tests/auto/tools/macdeployqt/source_plugin_tls/main.cpp index 7d1070b2c5..61b5edd614 100644 --- a/tests/auto/tools/macdeployqt/source_plugin_tls/main.cpp +++ b/tests/auto/tools/macdeployqt/source_plugin_tls/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** 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$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtNetwork> diff --git a/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp b/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp index 8922025570..d408554319 100644 --- a/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp +++ b/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp @@ -1,35 +1,11 @@ -/**************************************************************************** -** -** Copyright (C) 2020 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$ -** -****************************************************************************/ +// Copyright (C) 2020 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtCore> #include <QtTest> -bool g_testDirectoryBuild = false; // toggle to keep build output for debugging. +Q_LOGGING_CATEGORY(lcTests, "qt.tools.tests") + QTemporaryDir *g_temporaryDirectory; QString g_macdeployqtBinary; QString g_qmakeBinary; @@ -59,6 +35,24 @@ static bool runProcess(const QString &binary, process.setProcessEnvironment(env); if (!workingDir.isEmpty()) process.setWorkingDirectory(workingDir); + + const auto outputReader = qScopeGuard([&] { + QByteArray standardOutput = process.readAllStandardOutput(); + if (!standardOutput.trimmed().isEmpty()) + qCDebug(lcTests).nospace() << "Standard output:\n" << qUtf8Printable(standardOutput.trimmed()); + if (stdOut) + *stdOut = standardOutput; + QByteArray standardError = process.readAllStandardError(); + if (!standardError.trimmed().isEmpty()) + qCDebug(lcTests).nospace() << "Standard error:\n" << qUtf8Printable(standardError.trimmed()); + if (stdErr) + *stdErr = standardError; + }); + + qCDebug(lcTests).noquote() << "Running" << binary + << "with arguments" << arguments + << "in" << workingDir; + process.start(binary, arguments, QIODevice::ReadOnly); if (!process.waitForStarted()) { *errorMessage = msgProcessError(process, "Failed to start"); @@ -71,10 +65,7 @@ static bool runProcess(const QString &binary, process.kill(); return false; } - if (stdOut) - *stdOut = process.readAllStandardOutput(); - if (stdErr) - *stdErr= process.readAllStandardError(); + if (process.exitStatus() != QProcess::NormalExit) { *errorMessage = msgProcessError(process, "Crashed"); return false; @@ -116,8 +107,6 @@ QString sourcePath(const QString &name) QString buildPath(const QString &name) { - if (g_testDirectoryBuild) - return "build_" + name; return g_temporaryDirectory->path() + "/build_" + name; } @@ -173,26 +162,14 @@ bool deploy(const QString &name, const QStringList &options, QString *errorMessa QString bundle = name + ".app"; QString path = buildPath(name); QStringList args = QStringList() << bundle << options; +#if defined(QT_DEBUG) + args << "-use-debug-libs"; +#endif + if (lcTests().isDebugEnabled()) + args << "-verbose=3"; return runProcess(g_macdeployqtBinary, args, errorMessage, path); } -bool debugDeploy(const QString &name, const QStringList &options, QString *errorMessage) -{ - QString bundle = name + ".app"; - QString path = buildPath(name); - QStringList args = QStringList() << bundle << options << "-verbose=3"; - QByteArray stdOut; - QByteArray stdErr; - bool exitOK = runProcess(g_macdeployqtBinary, args, errorMessage, path, QProcessEnvironment(), - 10000, &stdOut, &stdErr); - - qDebug() << "macdeployqt exit OK" << exitOK; - qDebug() << qPrintable(stdOut); - qDebug() << qPrintable(stdErr); - - return exitOK; -} - bool run(const QString &name, QString *errorMessage) { QString path = buildPath(name); @@ -222,11 +199,11 @@ void runVerifyDeployment(const QString &name) const QList<QString> parts = QString::fromLocal8Bit(libraries).split("dyld: loaded:"); const QString qtPath = QLibraryInfo::path(QLibraryInfo::PrefixPath); // Let assume Qt is not installed in system - foreach (QString part, parts) { - part = part.trimmed(); - if (part.isEmpty()) + for (const QString &part : parts) { + const auto trimmed = part.trimmed(); + if (trimmed.isEmpty()) continue; - QVERIFY(!parts.startsWith(qtPath)); + QVERIFY(!trimmed.startsWith(qtPath)); } } @@ -247,8 +224,12 @@ void tst_macdeployqt::initTestCase() QSKIP("This test requires QProcess support"); #endif + if (QProcess::execute("xcode-select", { "-p" }) != 0) + QSKIP("Xcode or Xcode command line tools not installed"); + // Set up test-global unique temporary directory g_temporaryDirectory = new QTemporaryDir(); + g_temporaryDirectory->setAutoRemove(!lcTests().isDebugEnabled()); QVERIFY(g_temporaryDirectory->isValid()); // Locate build and deployment tools |