File indexing completed on 2024-04-21 05:44:40
0001 /* 0002 * SPDX-FileCopyrightText: 2019 Andreas Cord-Landwehr <cordlandwehr@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #include "test_licensefilesavailable.h" 0008 #include "../licenseregistry.h" 0009 #include <QTest> 0010 #include <QDebug> 0011 #include <QDir> 0012 #include <QDirIterator> 0013 0014 0015 void TestLicenseFilesAvailable::checkAll() 0016 { 0017 LicenseRegistry registry; 0018 QVector<QString> expressions = registry.expressions(); 0019 0020 QSet<QString> identifiers; 0021 for (const auto &expression : expressions) { 0022 auto expressionSplit = expression.split('_'); 0023 for (const auto &identifier : expressionSplit) { 0024 // remove SPDX syntax attributes 0025 if (identifier == "OR" || identifier == "AND" || identifier == "WITH") { 0026 continue; 0027 } 0028 // remove special placeholders 0029 if (identifier == LicenseRegistry::UnknownLicense 0030 || identifier == LicenseRegistry::MissingLicense 0031 || identifier == LicenseRegistry::MissingLicenseForGeneratedFile 0032 || identifier == LicenseRegistry::AmbigiousLicense 0033 || identifier == "TO-CLARIFY") { 0034 continue; 0035 } 0036 identifiers.insert(identifier); 0037 } 0038 } 0039 qDebug() << "Checking for SPDX license texts:" << identifiers.values(); 0040 0041 // test missing 0042 QMap<LicenseRegistry::SpdxIdentifier, QString> licenseFiles = registry.licenseFiles(); 0043 for (const auto &identifier : identifiers) { 0044 QVERIFY2(licenseFiles.contains(identifier), qPrintable("Searching identifier: " + identifier)); 0045 } 0046 } 0047 0048 QTEST_GUILESS_MAIN(TestLicenseFilesAvailable);