tests/auto/maketestselftest/tst_maketestselftest.cpp
branchRCL_3
changeset 7 3f74d0d4af4c
parent 5 d3bac044e0f0
equal deleted inserted replaced
6:dee5afe5301f 7:3f74d0d4af4c
    48 class tst_MakeTestSelfTest: public QObject
    48 class tst_MakeTestSelfTest: public QObject
    49 {
    49 {
    50     Q_OBJECT
    50     Q_OBJECT
    51 
    51 
    52 private slots:
    52 private slots:
    53     void auto_dot_pro();
    53     void tests_pro_files();
    54     void auto_dot_pro_data();
    54     void tests_pro_files_data();
    55 };
    55 };
    56 
    56 
    57 /* Verify that all tests are listed somewhere in auto.pro */
    57 /* Verify that all tests are listed somewhere in one of the autotest .pro files */
    58 void tst_MakeTestSelfTest::auto_dot_pro()
    58 void tst_MakeTestSelfTest::tests_pro_files()
    59 {
    59 {
    60     static QStringList lines;
    60     static QStringList lines;
    61 
    61 
    62     if (lines.isEmpty()) {
    62     if (lines.isEmpty()) {
    63         QString filename = QString::fromLatin1(SRCDIR "/../auto.pro");
    63         QDir dir(SRCDIR "/..");
    64         QFile file(filename);
    64         QStringList proFiles = dir.entryList(QStringList() << "*.pro");
    65         if (!file.open(QIODevice::ReadOnly)) {
    65         foreach (QString const& proFile, proFiles) {
    66             QFAIL(qPrintable(QString("open %1: %2").arg(filename).arg(file.errorString())));
    66             QString filename = QString("%1/../%2").arg(SRCDIR).arg(proFile);
    67         }
    67             QFile file(filename);
    68         while (!file.atEnd()) {
    68             if (!file.open(QIODevice::ReadOnly)) {
    69             lines << file.readLine().trimmed();
    69                 QFAIL(qPrintable(QString("open %1: %2").arg(filename).arg(file.errorString())));
       
    70             }
       
    71             while (!file.atEnd()) {
       
    72                 lines << file.readLine().trimmed();
       
    73             }
    70         }
    74         }
    71     }
    75     }
    72 
    76 
    73     QFETCH(QString, subdir);
    77     QFETCH(QString, subdir);
    74     QRegExp re(QString("( |=|^|#)%1( |\\\\|$)").arg(QRegExp::escape(subdir)));
    78     QRegExp re(QString("( |=|^|#)%1( |\\\\|$)").arg(QRegExp::escape(subdir)));
    77             return;
    81             return;
    78         }
    82         }
    79     }
    83     }
    80 
    84 
    81     QFAIL(qPrintable(QString(
    85     QFAIL(qPrintable(QString(
    82         "Subdir `%1' is missing from tests/auto/auto.pro\n"
    86         "Subdir `%1' is missing from tests/auto/*.pro\n"
    83         "This means the test won't be compiled or run on any platform.\n"
    87         "This means the test won't be compiled or run on any platform.\n"
    84         "If this is intentional, please put the test name in a comment in auto.pro.").arg(subdir))
    88         "If this is intentional, please put the test name in a comment in one of the .pro files.").arg(subdir))
    85     );
    89     );
       
    90 
    86 }
    91 }
    87 
    92 
    88 void tst_MakeTestSelfTest::auto_dot_pro_data()
    93 void tst_MakeTestSelfTest::tests_pro_files_data()
    89 {
    94 {
    90     QTest::addColumn<QString>("subdir");
    95     QTest::addColumn<QString>("subdir");
    91     QDir dir(SRCDIR "/..");
    96     QDir dir(SRCDIR "/..");
    92     QStringList subdirs = dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot);
    97     QStringList subdirs = dir.entryList(QDir::AllDirs|QDir::NoDotAndDotDot);
    93 
    98 
    94     foreach (const QString& subdir, subdirs) {
    99     foreach (const QString& subdir, subdirs) {
    95         if (subdir == QString::fromLatin1("tmp")) {
   100         if (subdir == QString::fromLatin1("tmp")
       
   101             || subdir.startsWith("."))
       
   102         {
    96             continue;
   103             continue;
    97         }
   104         }
    98         QTest::newRow(qPrintable(subdir)) << subdir;
   105         QTest::newRow(qPrintable(subdir)) << subdir;
    99     }
   106     }
   100 }
   107 }