|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the test suite of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include <QDir> |
|
43 #include <QFile> |
|
44 #include <QRegExp> |
|
45 #include <QStringList> |
|
46 #include <QTest> |
|
47 |
|
48 class tst_MakeTestSelfTest: public QObject |
|
49 { |
|
50 Q_OBJECT |
|
51 |
|
52 private slots: |
|
53 void tests_pro_files(); |
|
54 void tests_pro_files_data(); |
|
55 }; |
|
56 |
|
57 /* Verify that all tests are listed somewhere in one of the autotest .pro files */ |
|
58 void tst_MakeTestSelfTest::tests_pro_files() |
|
59 { |
|
60 static QStringList lines; |
|
61 |
|
62 if (lines.isEmpty()) { |
|
63 QDir dir(SRCDIR "/.."); |
|
64 QStringList proFiles = dir.entryList(QStringList() << "*.pro"); |
|
65 foreach (QString const& proFile, proFiles) { |
|
66 QString filename = QString("%1/../%2").arg(SRCDIR).arg(proFile); |
|
67 QFile file(filename); |
|
68 if (!file.open(QIODevice::ReadOnly)) { |
|
69 QFAIL(qPrintable(QString("open %1: %2").arg(filename).arg(file.errorString()))); |
|
70 } |
|
71 while (!file.atEnd()) { |
|
72 lines << file.readLine().trimmed(); |
|
73 } |
|
74 } |
|
75 } |
|
76 |
|
77 QFETCH(QString, subdir); |
|
78 QRegExp re(QString("( |=|^|#)%1( |\\\\|$)").arg(QRegExp::escape(subdir))); |
|
79 foreach (const QString& line, lines) { |
|
80 if (re.indexIn(line) != -1) { |
|
81 return; |
|
82 } |
|
83 } |
|
84 |
|
85 QFAIL(qPrintable(QString( |
|
86 "Subdir `%1' is missing from tests/auto/*.pro\n" |
|
87 "This means the test won't be compiled or run on any platform.\n" |
|
88 "If this is intentional, please put the test name in a comment in one of the .pro files.").arg(subdir)) |
|
89 ); |
|
90 |
|
91 } |
|
92 |
|
93 void tst_MakeTestSelfTest::tests_pro_files_data() |
|
94 { |
|
95 QTest::addColumn<QString>("subdir"); |
|
96 QDir dir(SRCDIR "/.."); |
|
97 QStringList subdirs = dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot); |
|
98 |
|
99 foreach (const QString& subdir, subdirs) { |
|
100 if (subdir == QString::fromLatin1("tmp") |
|
101 || subdir.startsWith(".")) |
|
102 { |
|
103 continue; |
|
104 } |
|
105 QTest::newRow(qPrintable(subdir)) << subdir; |
|
106 } |
|
107 } |
|
108 |
|
109 QTEST_MAIN(tst_MakeTestSelfTest) |
|
110 #include "tst_maketestselftest.moc" |