summaryrefslogtreecommitdiffstats
path: root/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp')
-rw-r--r--tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp69
1 files changed, 23 insertions, 46 deletions
diff --git a/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp b/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp
index 31d7c7847..617141d9b 100644
--- a/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp
+++ b/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the Qt Linguist 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) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QtCore/qdir.h>
#include <QtCore/qdebug.h>
@@ -56,7 +31,7 @@ private:
tst_qtattributionsscanner::tst_qtattributionsscanner()
{
- QString binPath = QLibraryInfo::location(QLibraryInfo::BinariesPath);
+ QString binPath = QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath);
m_cmd = binPath + QLatin1String("/qtattributionsscanner");
m_basePath = QFINDTESTDATA("testdata");
}
@@ -65,26 +40,23 @@ tst_qtattributionsscanner::tst_qtattributionsscanner()
void tst_qtattributionsscanner::test_data()
{
QTest::addColumn<QString>("input");
+ QTest::addColumn<bool>("success");
QTest::addColumn<QString>("stdout_file");
QTest::addColumn<QString>("stderr_file");
- QTest::newRow("good")
- << QStringLiteral("good")
- << QStringLiteral("good/expected.json")
- << QStringLiteral("good/expected.error");
- QTest::newRow("warnings (incomplete)")
- << QStringLiteral("warnings/incomplete")
- << QStringLiteral("warnings/incomplete/expected.json")
- << QStringLiteral("warnings/incomplete/expected.error");
+ QTest::newRow("good") << QStringLiteral("good") << true << QStringLiteral("good/expected.json")
+ << QStringLiteral("good/expected.error");
+ QTest::newRow("warnings (incomplete)") << QStringLiteral("warnings/incomplete") << false
+ << QStringLiteral("warnings/incomplete/expected.json")
+ << QStringLiteral("warnings/incomplete/expected.error");
QTest::newRow("warnings (unknown attribute)")
- << QStringLiteral("warnings/unknown")
+ << QStringLiteral("warnings/unknown") << false
<< QStringLiteral("warnings/unknown/expected.json")
<< QStringLiteral("warnings/unknown/expected.error");
- QTest::newRow("singlefile")
- << QStringLiteral("good/minimal/qt_attribution_test.json")
- << QStringLiteral("good/minimal/expected.json")
- << QStringLiteral("good/minimal/expected.error");
- QTest::newRow("variants") << QStringLiteral("good/variants/qt_attribution_test.json")
+ QTest::newRow("singlefile") << QStringLiteral("good/minimal/qt_attribution_test.json") << true
+ << QStringLiteral("good/minimal/expected.json")
+ << QStringLiteral("good/minimal/expected.error");
+ QTest::newRow("variants") << QStringLiteral("good/variants/qt_attribution_test.json") << true
<< QStringLiteral("good/variants/expected.json")
<< QStringLiteral("good/variants/expected.error");
}
@@ -95,11 +67,15 @@ void tst_qtattributionsscanner::readExpectedFile(const QString &baseDir, const Q
QVERIFY2(file.open(QIODevice::ReadOnly | QIODevice::Text), "Could not open " + file.fileName().toLocal8Bit());
*content = file.readAll();
content->replace("%{PWD}", baseDir.toUtf8());
+
+ QDir licensesDir(QStringLiteral(QTTOOLS_LICENSES_DIR));
+ content->replace("%{LICENSES_DIR}", licensesDir.canonicalPath().toUtf8());
}
void tst_qtattributionsscanner::test()
{
QFETCH(QString, input);
+ QFETCH(bool, success);
QFETCH(QString, stdout_file);
QFETCH(QString, stderr_file);
@@ -120,9 +96,9 @@ void tst_qtattributionsscanner::test()
QVERIFY2(proc.exitStatus() == QProcess::NormalExit,
"\"qtattributionsscanner " + m_cmd.toLatin1() + "\" crashed");
- QVERIFY2(!proc.exitCode(),
- "\"qtattributionsscanner " + m_cmd.toLatin1() + "\" exited with code " +
- QByteArray::number(proc.exitCode()));
+ QVERIFY2(success ? (proc.exitCode() == 0) : (proc.exitCode() != 0),
+ "\"qtattributionsscanner " + m_cmd.toLatin1() + "\" exited with code "
+ + QByteArray::number(proc.exitCode()));
{ // compare error output
QByteArray stdErr = proc.readAllStandardError();
@@ -134,7 +110,8 @@ void tst_qtattributionsscanner::test()
QCOMPARE(stdErr, expectedErrorOutput);
}
- { // compare json output
+ if (proc.exitCode() == 0) {
+ // compare json output
QByteArray stdOut = proc.readAllStandardOutput();
QJsonParseError jsonError;