summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/tools/macdeployqt/tst_macdeployqt.cpp')
-rw-r--r--tests/auto/tools/macdeployqt/tst_macdeployqt.cpp88
1 files changed, 33 insertions, 55 deletions
diff --git a/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp b/tests/auto/tools/macdeployqt/tst_macdeployqt.cpp
index 8922025570..3c17acda56 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));
}
}
@@ -249,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