diff options
author | Kai Köhne <kai.koehne@qt.io> | 2022-10-14 11:19:28 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2022-10-17 12:51:24 +0200 |
commit | 59a6e371be6f444f5c276f5f4abea9f739626726 (patch) | |
tree | 10e8727040692fdb80d4159c18a0f8c8fc2296c6 /tests | |
parent | 60b95cb63f867663ee324b139f9eeeeb9ad5dd8d (diff) | |
download | qttools-59a6e371be6f444f5c276f5f4abea9f739626726.tar.gz |
qtattributionsscanner: Exit with error for qt_attribution.json warnings
So far qtattributionsscanner did print warnings for erroneous or
incomplete qt_attribution.json files, but still generated output and
returned normally. Let's be more strict, and actually fail in these
cases.
This also required moving the resolution of referenced copyright
and license files from the generation to the scanning phase.
Do be more lenient with Chromium attribution files though, because
we don't really control them.
With this in place, make docs for Qt modules should fail if incorrect
qt_attribution.json files are found.
Pick-to: 6.4
Fixes: QTBUG-107106
Change-Id: I3d0192dfb966b4422410d0b1fb4ba4652a5303cf
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'tests')
6 files changed, 35 insertions, 79 deletions
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..dbdcefab8 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,24 @@ { - "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", + "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..24bcdaa0f 100644 --- a/tests/auto/qtattributionsscanner/testdata/good/expected.json +++ b/tests/auto/qtattributionsscanner/testdata/good/expected.json @@ -29,7 +29,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", 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/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/testdata/warnings/unknown/expected.json b/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json deleted file mode 100644 index a87917eba..000000000 --- a/tests/auto/qtattributionsscanner/testdata/warnings/unknown/expected.json +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "Copyright": "Copyright", - "CopyrightFile": "", - "Description": "", - "DownloadLocation": "", - "Files": "", - "Homepage": "", - "Id": "unknown", - "License": "License", - "LicenseFile": "", - "LicenseId": "", - "Name": "Unknown", - "PackageComment": "", - "Path": "%{PWD}", - "QDocModule": "qtest", - "QtParts": [ - "libs" - ], - "QtUsage": "Usage", - "Version": "" - } -] diff --git a/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp b/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp index cf0c11cad..7fafc93d1 100644 --- a/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp +++ b/tests/auto/qtattributionsscanner/tst_qtattributionsscanner.cpp @@ -40,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"); } @@ -75,6 +72,7 @@ void tst_qtattributionsscanner::readExpectedFile(const QString &baseDir, const Q void tst_qtattributionsscanner::test() { QFETCH(QString, input); + QFETCH(bool, success); QFETCH(QString, stdout_file); QFETCH(QString, stderr_file); @@ -95,9 +93,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(); @@ -109,7 +107,8 @@ void tst_qtattributionsscanner::test() QCOMPARE(stdErr, expectedErrorOutput); } - { // compare json output + if (proc.exitCode() == 0) { + // compare json output QByteArray stdOut = proc.readAllStandardOutput(); QJsonParseError jsonError; |