summaryrefslogtreecommitdiffstats
path: root/tests/auto/headers
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-08-18 06:34:18 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-08-18 06:34:18 (GMT)
commitfd6740b6ade6e7f8e51a9cc558b723e7fae15ccf (patch)
treeaa2ba4ce64d047d73c29ab0616e8a89d352c3abd /tests/auto/headers
parentd24029e3d4639f1300e7a68858936911df969f69 (diff)
parent572e165dcb8cc8fcdfaa4ab9bdab050f6a6cc173 (diff)
downloadQt-fd6740b6ade6e7f8e51a9cc558b723e7fae15ccf.zip
Qt-fd6740b6ade6e7f8e51a9cc558b723e7fae15ccf.tar.gz
Qt-fd6740b6ade6e7f8e51a9cc558b723e7fae15ccf.tar.bz2
Merge commit 'qt/master'
Conflicts: doc/src/examples.qdoc doc/src/plugins-howto.qdoc doc/src/topics.qdoc examples/phonon/musicplayer/mainwindow.cpp src/3rdparty/freetype/src/base/ftobjs.c src/corelib/global/qglobal.h src/corelib/tools/qalgorithms.h src/corelib/tools/qshareddata.cpp src/corelib/tools/qsharedpointer.cpp src/corelib/tools/tools.pri src/corelib/xml/qxmlstream.h src/gui/painting/painting.pri src/gui/widgets/qdatetimeedit.cpp tests/auto/qdesktopservices/qdesktopservices.pro tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp tests/auto/qtextcodec/test/test.pro
Diffstat (limited to 'tests/auto/headers')
-rw-r--r--tests/auto/headers/tst_headers.cpp84
1 files changed, 65 insertions, 19 deletions
diff --git a/tests/auto/headers/tst_headers.cpp b/tests/auto/headers/tst_headers.cpp
index 51e3a55..f5a11f4 100644
--- a/tests/auto/headers/tst_headers.cpp
+++ b/tests/auto/headers/tst_headers.cpp
@@ -50,7 +50,7 @@ public:
private slots:
void initTestCase();
- void licenseCheck_data() { allHeadersData(); }
+ void licenseCheck_data() { allSourceFilesData(); }
void licenseCheck();
void privateSlots_data() { allHeadersData(); }
@@ -60,11 +60,19 @@ private slots:
void macros();
private:
+ static QStringList getFiles(const QString &path,
+ const QStringList dirFilters,
+ const QRegExp &exclude);
+ static QStringList getHeaders(const QString &path);
+ static QStringList getSourceFiles(const QString &path);
+
+ void allSourceFilesData();
void allHeadersData();
QStringList headers;
const QRegExp copyrightPattern;
const QRegExp licensePattern;
const QRegExp moduleTest;
+ QString qtSrcDir;
};
tst_Headers::tst_Headers() :
@@ -74,29 +82,41 @@ tst_Headers::tst_Headers() :
{
}
-QStringList getHeaders(const QString &path)
+QStringList tst_Headers::getFiles(const QString &path,
+ const QStringList dirFilters,
+ const QRegExp &excludeReg)
{
- QStringList headers;
-
- QDir dir(path);
- QStringList dirs = dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
+ const QDir dir(path);
+ const QStringList dirs(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot));
+ QStringList result;
foreach (QString subdir, dirs)
- headers += getHeaders(path + "/" + subdir);
+ result += getFiles(path + "/" + subdir, dirFilters, excludeReg);
- QStringList entries = dir.entryList(QStringList("*.h"), QDir::Files);
- QRegExp reg("^(?!ui_)");
- entries = entries.filter(reg);
+ QStringList entries = dir.entryList(dirFilters, QDir::Files);
+ entries = entries.filter(excludeReg);
foreach (QString entry, entries)
- headers += path + "/" + entry;
+ result += path + "/" + entry;
- return headers;
+ return result;
+}
+
+QStringList tst_Headers::getHeaders(const QString &path)
+{
+ return getFiles(path, QStringList("*.h"), QRegExp("^(?!ui_)"));
+}
+
+QStringList tst_Headers::getSourceFiles(const QString &path)
+{
+ return getFiles(path, QStringList("*.cpp"), QRegExp("^(?!(moc_|qrc_))"));
}
void tst_Headers::initTestCase()
{
- QString qtSrcDir = QString::fromLocal8Bit(qgetenv("QTSRCDIR").isEmpty()
- ? qgetenv("QTDIR") : qgetenv("QTSRCDIR"));
+ qtSrcDir = QString::fromLocal8Bit(qgetenv("QTSRCDIR").isEmpty()
+ ? qgetenv("QTDIR")
+ : qgetenv("QTSRCDIR"));
+
headers = getHeaders(qtSrcDir + "/src");
#ifndef Q_OS_WINCE
@@ -108,6 +128,30 @@ void tst_Headers::initTestCase()
QVERIFY(licensePattern.isValid());
}
+void tst_Headers::allSourceFilesData()
+{
+ QTest::addColumn<QString>("sourceFile");
+
+ const QStringList sourceFiles(getSourceFiles(qtSrcDir));
+
+ foreach (QString sourceFile, sourceFiles) {
+ if (sourceFile.contains("/3rdparty/")
+ || sourceFile.contains("/config.tests/")
+ || sourceFile.contains("/snippets/")
+ || sourceFile.contains("linguist/lupdate/testdata")
+ || 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"))
+ continue;
+
+ QTest::newRow(qPrintable(sourceFile)) << sourceFile;
+ }
+}
+
void tst_Headers::allHeadersData()
{
QTest::addColumn<QString>("header");
@@ -125,12 +169,14 @@ void tst_Headers::allHeadersData()
void tst_Headers::licenseCheck()
{
- QFETCH(QString, header);
+ QFETCH(QString, sourceFile);
- if (header.endsWith("/qgifhandler.h") || header.endsWith("/qconfig.h"))
+ if (sourceFile.endsWith("/qgifhandler.h")
+ || sourceFile.endsWith("/qconfig.h")
+ || sourceFile.endsWith("/qconfig.cpp"))
return;
- QFile f(header);
+ QFile f(sourceFile);
QVERIFY(f.open(QIODevice::ReadOnly));
QByteArray data = f.readAll();
QStringList content = QString::fromLocal8Bit(data.replace('\r',"")).split("\n");
@@ -138,8 +184,8 @@ void tst_Headers::licenseCheck()
if (content.first().contains("generated"))
content.takeFirst();
- QVERIFY(licensePattern.exactMatch(content.at(7)) ||
- licensePattern.exactMatch(content.at(4)));
+ QVERIFY(licensePattern.exactMatch(content.value(7)) ||
+ licensePattern.exactMatch(content.value(4)));
QString licenseType = licensePattern.cap(1);
int i = 0;