From fb52ca581e644a7b8699665f26248c33dac30cef Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 21 Sep 2009 13:45:07 +0200 Subject: Improved license header autotest. Check the license in .h files as well as .cpp files and check some files that were previously skipped. Instead of scanning through the whole Qt directory for .cpp and .h files, only search through a set of subdirectories. Accept '\r' as line break in addition to '\n' and "\r\n". Reenable the copyright check that was commented out. Reviewed-by: Frans Englich --- tests/auto/headers/tst_headers.cpp | 76 ++++++++++++++++++++++++++------------ 1 file 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("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)")); } -- cgit v0.12 From d8cf39e05f3a608c122f546dc4e677d4ce68cb36 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 21 Sep 2009 14:32:48 +0200 Subject: Fixed license headers in /util/qlalr. Reviewed-by: Trond --- util/qlalr/compress.h | 2 +- util/qlalr/cppgenerator.cpp | 2 +- util/qlalr/cppgenerator.h | 2 +- util/qlalr/dotgraph.h | 2 +- util/qlalr/grammar_p.h | 2 +- util/qlalr/lalr.h | 2 +- util/qlalr/parsetable.h | 2 +- util/qlalr/recognizer.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/util/qlalr/compress.h b/util/qlalr/compress.h index 5619afc..bf779cc 100644 --- a/util/qlalr/compress.h +++ b/util/qlalr/compress.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/cppgenerator.cpp b/util/qlalr/cppgenerator.cpp index dfe3ff2..dd5be57 100644 --- a/util/qlalr/cppgenerator.cpp +++ b/util/qlalr/cppgenerator.cpp @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/cppgenerator.h b/util/qlalr/cppgenerator.h index 64d1924..e36e8c0 100644 --- a/util/qlalr/cppgenerator.h +++ b/util/qlalr/cppgenerator.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/dotgraph.h b/util/qlalr/dotgraph.h index df4d216..9a71769 100644 --- a/util/qlalr/dotgraph.h +++ b/util/qlalr/dotgraph.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/grammar_p.h b/util/qlalr/grammar_p.h index 3f0c0d0..1794fe5 100644 --- a/util/qlalr/grammar_p.h +++ b/util/qlalr/grammar_p.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/lalr.h b/util/qlalr/lalr.h index 7d7c692..1dd843f 100644 --- a/util/qlalr/lalr.h +++ b/util/qlalr/lalr.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/parsetable.h b/util/qlalr/parsetable.h index f2cd264..6d5490a 100644 --- a/util/qlalr/parsetable.h +++ b/util/qlalr/parsetable.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage diff --git a/util/qlalr/recognizer.h b/util/qlalr/recognizer.h index fdc6448..667517e 100644 --- a/util/qlalr/recognizer.h +++ b/util/qlalr/recognizer.h @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the QLALR project on Qt Labs. +** This file is part of the utils of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:LGPL$ ** No Commercial Usage -- cgit v0.12