diff options
Diffstat (limited to 'tests/auto/qtattributionsscanner')
-rw-r--r-- | tests/auto/qtattributionsscanner/CMakeLists.txt | 14 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json | 31 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/good/expected.json | 28 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/good/licenses-dir/expected.error | 0 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/good/licenses-dir/expected.json (renamed from tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json) | 11 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/good/licenses-dir/qt_attribution_test.json | 9 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json | 1 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/good/variants/COPYRIGHT.txt | 1 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/good/variants/expected.json | 1 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json | 23 | ||||
-rw-r--r-- | tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp | 67 |
11 files changed, 95 insertions, 91 deletions
diff --git a/tests/auto/qtattributionsscanner/CMakeLists.txt b/tests/auto/qtattributionsscanner/CMakeLists.txt index 24d512afe..c7bdd56ca 100644 --- a/tests/auto/qtattributionsscanner/CMakeLists.txt +++ b/tests/auto/qtattributionsscanner/CMakeLists.txt @@ -1,13 +1,21 @@ -# Generated from qtattributionsscanner.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qtattributionsscanner Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qtattributionsscanner LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_qtattributionsscanner SOURCES tst_qtattributionsscanner.cpp ) -#### Keys ignored in scope 1:.:.:qtattributionsscanner.pro:<TRUE>: -# DISTFILES = "testdata/good/expected.json" "testdata/good/expected.error" "testdata/good/minimal/qt_attribution_test.json" "testdata/good/minimal/expected.json" "testdata/good/minimal/expected.error" "testdata/good/complete/qt_attribution_test.json" "testdata/good/complete/expected.json" "testdata/good/complete/expected.error" "testdata/good/variants/qt_attribution_test.json" "testdata/good/variants/expected.json" "testdata/good/variants/expected.error" "testdata/warnings/incomplete/qt_attribution_test.json" "testdata/warnings/incomplete/expected.json" "testdata/warnings/incomplete/expected.error" "testdata/warnings/unknown/qt_attribution_test.json" "testdata/warnings/unknown/expected.json" "testdata/warnings/unknown/expected.error" +target_compile_definitions(tst_qtattributionsscanner + PRIVATE QTTOOLS_LICENSES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../../../LICENSES" +) diff --git a/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json b/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json index 8035cefab..22eadd8cd 100644 --- a/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json +++ b/tests/auto/qtattributionsscanner/testdata/good/complete/qt_attribution_test.json @@ -1,22 +1,25 @@ { - "Id": "complete", - "Name": "Complete", - "QDocModule": "qtest", - "QtParts": ["examples"], + "Id": "complete", + "Name": "Complete", + "QDocModule": "qtest", + "QtParts": [ + "examples" + ], - "License": "License", - "Copyright": "Copyright", + "License": "License", + "Copyright": "Copyright", - "Description": "Multi + "Description": "Multi Line Description", - "QtUsage": "Multi + "QtUsage": "Multi Line Usage", - "Homepage": "www.qt.io", - "Version": "1.0", - "DownloadLocation": "www.qt.io/1.0", - "LicenseId": "xxx", - "LicenseFile": "LICENSE", - "PackageComment": "just a test package" + "Homepage": "www.qt.io", + "Version": "1.0", + "DownloadLocation": "www.qt.io/1.0", + "SecurityCritical": true, + "LicenseId": "xxx", + "LicenseFile": "../../../../../../LICENSES/BSD-3-Clause.txt", + "PackageComment": "just a test package" } diff --git a/tests/auto/qtattributionsscanner/testdata/good/expected.json b/tests/auto/qtattributionsscanner/testdata/good/expected.json index d910e6165..adde0d86b 100644 --- a/tests/auto/qtattributionsscanner/testdata/good/expected.json +++ b/tests/auto/qtattributionsscanner/testdata/good/expected.json @@ -18,6 +18,7 @@ "libs" ], "QtUsage": "Used in Qt WebEngine", + "SecurityCritical": false, "Version": "" }, { @@ -29,7 +30,7 @@ "Homepage": "www.qt.io", "Id": "complete", "License": "License", - "LicenseFile": "%{PWD}/complete/LICENSE", + "LicenseFile": "%{PWD}/complete/../../../../../../LICENSES/BSD-3-Clause.txt", "LicenseId": "xxx", "Name": "Complete", "PackageComment": "just a test package", @@ -39,6 +40,7 @@ "examples" ], "QtUsage": "Multi\nLine\nUsage", + "SecurityCritical": true, "Version": "1.0" }, { @@ -48,6 +50,28 @@ "DownloadLocation": "", "Files": "", "Homepage": "", + "Id": "licenses-dir", + "License": "BSD 3-Clause \"New\" or \"Revised\" License", + "LicenseFile": "%{LICENSES_DIR}/BSD-3-Clause.txt", + "LicenseId": "BSD-3-Clause", + "Name": "LicensesDir", + "PackageComment": "", + "Path": "%{PWD}/licenses-dir", + "QDocModule": "qtest", + "QtParts": [ + "libs" + ], + "QtUsage": "Usage", + "SecurityCritical": false, + "Version": "" + }, + { + "Copyright": "Copyright", + "CopyrightFile": "", + "Description": "", + "DownloadLocation": "", + "Files": "", + "Homepage": "", "Id": "minimal", "License": "License", "LicenseFile": "", @@ -60,6 +84,7 @@ "libs" ], "QtUsage": "Usage", + "SecurityCritical": false, "Version": "" }, { @@ -84,6 +109,7 @@ "libs" ], "QtUsage": "Usage", + "SecurityCritical": false, "Version": "" } ] diff --git a/tests/auto/qtattributionsscanner/testdata/good/licenses-dir/expected.error b/tests/auto/qtattributionsscanner/testdata/good/licenses-dir/expected.error new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/auto/qtattributionsscanner/testdata/good/licenses-dir/expected.error diff --git a/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json b/tests/auto/qtattributionsscanner/testdata/good/licenses-dir/expected.json index a87917eba..ab5c31309 100644 --- a/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json +++ b/tests/auto/qtattributionsscanner/testdata/good/licenses-dir/expected.json @@ -6,11 +6,11 @@ "DownloadLocation": "", "Files": "", "Homepage": "", - "Id": "unknown", - "License": "License", - "LicenseFile": "", - "LicenseId": "", - "Name": "Unknown", + "Id": "licenses-dir", + "License": "BSD 3-Clause \"New\" or \"Revised\" License", + "LicenseFile": "%{LICENSES_DIR}/BSD-3-Clause.txt", + "LicenseId": "BSD-3-Clause", + "Name": "LicensesDir", "PackageComment": "", "Path": "%{PWD}", "QDocModule": "qtest", @@ -18,6 +18,7 @@ "libs" ], "QtUsage": "Usage", + "SecurityCritical": false, "Version": "" } ] diff --git a/tests/auto/qtattributionsscanner/testdata/good/licenses-dir/qt_attribution_test.json b/tests/auto/qtattributionsscanner/testdata/good/licenses-dir/qt_attribution_test.json new file mode 100644 index 000000000..bf3f0658f --- /dev/null +++ b/tests/auto/qtattributionsscanner/testdata/good/licenses-dir/qt_attribution_test.json @@ -0,0 +1,9 @@ +{ + "Id": "licenses-dir", + "Name": "LicensesDir", + "QDocModule": "qtest", + "QtUsage": "Usage", + "License": "BSD 3-Clause \"New\" or \"Revised\" License", + "LicenseId": "BSD-3-Clause", + "Copyright": "Copyright" +} diff --git a/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json b/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json index fcde8f084..546830d3f 100644 --- a/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json +++ b/tests/auto/qtattributionsscanner/testdata/good/minimal/expected.json @@ -18,6 +18,7 @@ "libs" ], "QtUsage": "Usage", + "SecurityCritical": false, "Version": "" } ] diff --git a/tests/auto/qtattributionsscanner/testdata/good/variants/COPYRIGHT.txt b/tests/auto/qtattributionsscanner/testdata/good/variants/COPYRIGHT.txt new file mode 100644 index 000000000..923580113 --- /dev/null +++ b/tests/auto/qtattributionsscanner/testdata/good/variants/COPYRIGHT.txt @@ -0,0 +1 @@ +COPYRIGHT diff --git a/tests/auto/qtattributionsscanner/testdata/good/variants/expected.json b/tests/auto/qtattributionsscanner/testdata/good/variants/expected.json index 10a339175..f69f55726 100644 --- a/tests/auto/qtattributionsscanner/testdata/good/variants/expected.json +++ b/tests/auto/qtattributionsscanner/testdata/good/variants/expected.json @@ -21,6 +21,7 @@ "libs" ], "QtUsage": "Usage", + "SecurityCritical": false, "Version": "" } ] diff --git a/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json b/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json deleted file mode 100644 index 77b77b44c..000000000 --- a/tests/auto/qtattributionsscanner/testdata/warnings/incomplete/expected.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "Copyright": "", - "CopyrightFile": "", - "Description": "", - "DownloadLocation": "", - "Files": "", - "Homepage": "", - "Id": "", - "License": "", - "LicenseFile": "", - "LicenseId": "", - "Name": "", - "PackageComment": "", - "Path": "%{PWD}", - "QDocModule": "", - "QtParts": [ - "libs" - ], - "QtUsage": "", - "Version": "" - } -] diff --git a/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp b/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp index 34611c221..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> @@ -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; |