diff options
author | Robert Griebl <robert.griebl@qt.io> | 2021-05-03 16:42:46 +0200 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2021-06-18 13:06:27 +0200 |
commit | 26e09279f3cd12324657011c640972e297928f53 (patch) | |
tree | 17839d952b17fcc6338105a85604f543dc95547b /tests/packagecreator/tst_packagecreator.cpp | |
parent | 12b4ee7d85b1197cd4b6024e710430a747f76838 (diff) |
cmake: Nearly full cmake build
Had to rename a lot of things to conform with the standard Qt module
layout that the cmake system expects:
- all non-manual tests were moved to a sub-dir named auto/
- the benchmark was moved to tests/
- the 3rdparty folder was moved into src/
Other changes:
- libyaml was updated to 2.2.5 while fixing a weird build issue that
led to crashes on 64bit systems.
- fixed build issues with the new 8.1 MingW compiler.
- added support for QT_NO_OPENGL builds.
The remaining issues are:
- examples still don't build with qmake due to a potential bug in
module.pri generation.
- tests do run, but the test data is not generated yet dynamically.
- qml-only tests are not built and run yet.
- qml-only examples are not built yet.
Fixes: AUTOSUITE-1632
Change-Id: Ic5fe0148e738b05835c73bed78e624b55861b75e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Diffstat (limited to 'tests/packagecreator/tst_packagecreator.cpp')
-rw-r--r-- | tests/packagecreator/tst_packagecreator.cpp | 185 |
1 files changed, 0 insertions, 185 deletions
diff --git a/tests/packagecreator/tst_packagecreator.cpp b/tests/packagecreator/tst_packagecreator.cpp deleted file mode 100644 index 4882a871..00000000 --- a/tests/packagecreator/tst_packagecreator.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Copyright (C) 2019 Luxoft Sweden AB -** Copyright (C) 2018 Pelagicore AG -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtApplicationManager module 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 <QtTest> - -#include "global.h" -#include "installationreport.h" -#include "packageutilities.h" -#include "packagecreator.h" -#include "utilities.h" - -#include "../error-checking.h" - -QT_USE_NAMESPACE_AM - -static int processTimeout = 3000; - -class tst_PackageCreator : public QObject -{ - Q_OBJECT - -public: - tst_PackageCreator(); - -private slots: - void initTestCase(); - - void createAndVerify_data(); - void createAndVerify(); - -private: - QString escapeFilename(const QString &name); - -private: - QDir m_baseDir; - bool m_tarAvailable = false; - bool m_isCygwin = false; -}; - -tst_PackageCreator::tst_PackageCreator() - : m_baseDir(qSL(AM_TESTDATA_DIR)) -{ } - -void tst_PackageCreator::initTestCase() -{ - processTimeout *= timeoutFactor(); - - // check if tar command is available at all - QProcess tar; - tar.start(qSL("tar"), { qSL("--version") }); - m_tarAvailable = tar.waitForStarted(processTimeout) - && tar.waitForFinished(processTimeout) - && (tar.exitStatus() == QProcess::NormalExit); - - m_isCygwin = tar.readAllStandardOutput().contains("Cygwin"); - - QVERIFY(PackageUtilities::checkCorrectLocale()); -} - -void tst_PackageCreator::createAndVerify_data() -{ - QTest::addColumn<QStringList>("files"); - QTest::addColumn<bool>("expectedSuccess"); - QTest::addColumn<QString>("errorString"); - - QTest::newRow("basic") << QStringList { qSL("testfile") } << true << QString(); - QTest::newRow("no-such-file") << QStringList { qSL("tastfile") } << false << qSL("~file not found: .*"); -} - -void tst_PackageCreator::createAndVerify() -{ - QFETCH(QStringList, files); - QFETCH(bool, expectedSuccess); - QFETCH(QString, errorString); - - QTemporaryFile output; - QVERIFY(output.open()); - - InstallationReport report(qSL("com.pelagicore.test")); - report.addFiles(files); - - PackageCreator creator(m_baseDir, &output, report); - bool result = creator.create(); - output.close(); - - if (expectedSuccess) { - QVERIFY2(result, qPrintable(creator.errorString())); - } else { - QVERIFY(creator.errorCode() != Error::None); - QVERIFY(creator.errorCode() != Error::Canceled); - QVERIFY(!creator.wasCanceled()); - - AM_CHECK_ERRORSTRING(creator.errorString(), errorString); - return; - } - - // check the tar listing - if (!m_tarAvailable) - QSKIP("No tar command found in PATH - skipping the verification part of the test!"); - - QProcess tar; - tar.start(qSL("tar"), { qSL("-tzf"), escapeFilename(output.fileName()) }); - QVERIFY2(tar.waitForStarted(processTimeout) && - tar.waitForFinished(processTimeout) && - (tar.exitStatus() == QProcess::NormalExit) && - (tar.exitCode() == 0), qPrintable(tar.errorString())); - - QStringList expectedContents = files; - expectedContents.sort(); - expectedContents.prepend(qSL("--PACKAGE-HEADER--")); - expectedContents.append(qSL("--PACKAGE-FOOTER--")); - - QStringList actualContents = QString::fromLocal8Bit(tar.readAllStandardOutput()).split(qL1C('\n'), Qt::SkipEmptyParts); -#if defined(Q_OS_WIN) - actualContents.replaceInStrings(qSL("\r"), QString()); -#endif - QCOMPARE(actualContents, expectedContents); - - // check the contents of the files - - for (const QString &file : qAsConst(files)) { - QFile src(m_baseDir.absoluteFilePath(file)); - QVERIFY2(src.open(QFile::ReadOnly), qPrintable(src.errorString())); - QByteArray data = src.readAll(); - - tar.start(qSL("tar"), { qSL("-xzOf"), escapeFilename(output.fileName()), file }); - QVERIFY2(tar.waitForStarted(processTimeout) && - tar.waitForFinished(processTimeout) && - (tar.exitStatus() == QProcess::NormalExit) && - (tar.exitCode() == 0), qPrintable(tar.errorString())); - - QCOMPARE(tar.readAllStandardOutput(), data); - } -} - -QString tst_PackageCreator::escapeFilename(const QString &name) -{ - if (!m_isCygwin) { - return name; - } else { - QString s = QFileInfo(name).absoluteFilePath(); - QString t = qSL("/cygdrive/"); - t.append(s.at(0)); - return t + s.mid(2); - } -} - -int main(int argc, char *argv[]) -{ - PackageUtilities::ensureCorrectLocale(); - QCoreApplication app(argc, argv); - app.setAttribute(Qt::AA_Use96Dpi, true); - tst_PackageCreator tc; - QTEST_SET_MAIN_SOURCE_PATH - return QTest::qExec(&tc, argc, argv); -} - -#include "tst_packagecreator.moc" |