summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/macdeployqt
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/tools/macdeployqt')
-rw-r--r--tests/auto/tools/macdeployqt/CMakeLists.txt9
-rw-r--r--tests/auto/tools/macdeployqt/source_basicapp/main.cpp2
-rw-r--r--tests/auto/tools/macdeployqt/source_plugin_sqlite/main.cpp2
-rw-r--r--tests/auto/tools/macdeployqt/source_plugin_tls/main.cpp2
-rw-r--r--tests/auto/tools/macdeployqt/tst_macdeployqt.cpp61
5 files changed, 43 insertions, 33 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 815a03be5b..1e2bb1a3a6 100644
--- a/tests/auto/tools/macdeployqt/source_basicapp/main.cpp
+++ b/tests/auto/tools/macdeployqt/source_basicapp/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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 d87933fa7c..12343141f8 100644
--- a/tests/auto/tools/macdeployqt/source_plugin_sqlite/main.cpp
+++ b/tests/auto/tools/macdeployqt/source_plugin_sqlite/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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 ae6b8da11b..61b5edd614 100644
--- a/tests/auto/tools/macdeployqt/source_plugin_tls/main.cpp
+++ b/tests/auto/tools/macdeployqt/source_plugin_tls/main.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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 fbf09fbe89..3c17acda56 100644
--- a/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp
+++ b/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp
@@ -1,10 +1,11 @@
// Copyright (C) 2020 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// 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;
@@ -34,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");
@@ -46,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;
@@ -91,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;
}
@@ -148,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);
@@ -197,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));
}
}
@@ -224,6 +226,7 @@ void tst_macdeployqt::initTestCase()
// 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