summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/headers/tst_headers.cpp76
1 files changed, 52 insertions, 24 deletions
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index 1b28648..d4f2ff4 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -132,23 +132,36 @@ void tst_Headers::allSourceFilesData()
{
QTest::addColumn<QString>("sourceFile");
- const QStringList sourceFiles(getSourceFiles(qtSrcDir));
+ QStringList sourceFiles;
+ static char const * const subdirs[] = {
+ "/config.tests",
+ "/demos",
+ "/doc",
+ "/examples",
+ "/mkspecs",
+ "/qmake",
+ "/src",
+ "/tests",
+ "/tools",
+ "/util"
+ };
+
+ for (int i = 0; i < sizeof(subdirs) / sizeof(subdirs[0]); ++i) {
+ sourceFiles << getSourceFiles(qtSrcDir + subdirs[i]);
+ sourceFiles << getHeaders(qtSrcDir + subdirs[i]);
+ }
foreach (QString sourceFile, sourceFiles) {
if (sourceFile.contains("/3rdparty/")
- || sourceFile.contains("/config.tests/")
- || sourceFile.contains("/snippets/")
- || sourceFile.contains("linguist/lupdate/testdata")
- || sourceFile.contains("testdata/bundle-spaces/main.cpp")
- || sourceFile.contains("demos/embedded/fluidlauncher/pictureflow.cpp")
- || sourceFile.contains("tools/porting/src/")
- || sourceFile.contains("/fulltextsearch/"))
- continue;
-
- // This test is crude, but if a file contains this string, we skip it.
- QFile file(sourceFile);
- QVERIFY(file.open(QIODevice::ReadOnly));
- if (file.readAll().contains("This file was generated by"))
+ || sourceFile.contains("/tests/auto/qmake/testdata/bundle-spaces/main.cpp")
+ || sourceFile.contains("/demos/embedded/fluidlauncher/pictureflow.cpp")
+ || sourceFile.contains("/tools/porting/src/")
+ || sourceFile.contains("/tools/assistant/lib/fulltextsearch/")
+ || sourceFile.endsWith("_pch.h.cpp")
+ || sourceFile.endsWith(".ui.h")
+ || sourceFile.endsWith("/src/corelib/global/qconfig.h")
+ || sourceFile.endsWith("/src/corelib/global/qconfig.cpp")
+ || sourceFile.endsWith("/src/tools/uic/qclass_lib_map.h"))
continue;
QTest::newRow(qPrintable(sourceFile)) << sourceFile;
@@ -163,7 +176,7 @@ void tst_Headers::allHeadersData()
QSKIP("can't find any headers in your $QTDIR/src", SkipAll);
foreach (QString hdr, headers) {
- if (hdr.contains("/3rdparty/") || hdr.endsWith("/qclass_lib_map.h"))
+ if (hdr.contains("/3rdparty/") || hdr.endsWith("/src/tools/uic/qclass_lib_map.h"))
continue;
QTest::newRow(qPrintable(hdr)) << hdr;
@@ -174,18 +187,26 @@ void tst_Headers::licenseCheck()
{
QFETCH(QString, sourceFile);
- if (sourceFile.endsWith("/qgifhandler.h")
- || sourceFile.endsWith("/qconfig.h")
- || sourceFile.endsWith("/qconfig.cpp"))
- return;
-
QFile f(sourceFile);
QVERIFY(f.open(QIODevice::ReadOnly));
QByteArray data = f.readAll();
- QStringList content = QString::fromLocal8Bit(data.replace('\r',"")).split("\n");
+ data.replace("\r\n", "\n"); // Windows
+ data.replace('\r', '\n'); // Mac OS9
+ QStringList content = QString::fromLocal8Bit(data).split("\n");
- if (content.first().contains("generated"))
+ if (content.first().contains("generated")) {
content.takeFirst();
+ if (content.first().isEmpty())
+ content.takeFirst();
+ }
+
+ if (sourceFile.endsWith("/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp")
+ || sourceFile.endsWith("/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp"))
+ {
+ // These files are meant to start with empty lines.
+ while (content.first().isEmpty() || content.first().startsWith("//"))
+ content.takeFirst();
+ }
QVERIFY(licensePattern.exactMatch(content.value(8)) ||
licensePattern.exactMatch(content.value(5)));
@@ -196,8 +217,15 @@ void tst_Headers::licenseCheck()
QCOMPARE(content.at(i++), QString("/****************************************************************************"));
if (licenseType != "3RDPARTY") {
QCOMPARE(content.at(i++), QString("**"));
- // QVERIFY(copyrightPattern.exactMatch(content.at(i++)));
- i++;
+ if (sourceFile.endsWith("/tests/auto/qabstractitemmodel/dynamictreemodel.cpp")
+ || sourceFile.endsWith("/tests/auto/qabstractitemmodel/dynamictreemodel.h")
+ || sourceFile.endsWith("/src/network/kernel/qnetworkproxy_p.h"))
+ {
+ // These files are not copyrighted by Nokia.
+ ++i;
+ } else {
+ QVERIFY(copyrightPattern.exactMatch(content.at(i++)));
+ }
i++;
QCOMPARE(content.at(i++), QString("** Contact: Nokia Corporation (qt-info@nokia.com)"));
}