63 void tests_pro_files(); |
63 void tests_pro_files(); |
64 void tests_pro_files_data(); |
64 void tests_pro_files_data(); |
65 |
65 |
66 void naming_convention(); |
66 void naming_convention(); |
67 void naming_convention_data(); |
67 void naming_convention_data(); |
|
68 |
|
69 void make_check(); |
68 |
70 |
69 private: |
71 private: |
70 QStringList find_subdirs(QString const&, FindSubdirsMode, QString const& = QString()); |
72 QStringList find_subdirs(QString const&, FindSubdirsMode, QString const& = QString()); |
71 |
73 |
72 QSet<QString> all_test_classes; |
74 QSet<QString> all_test_classes; |
444 } |
446 } |
445 |
447 |
446 return out; |
448 return out; |
447 } |
449 } |
448 |
450 |
|
451 void tst_MakeTestSelfTest::make_check() |
|
452 { |
|
453 /* |
|
454 Run `make check' over the whole tests tree with a custom TESTRUNNER, |
|
455 to verify that the TESTRUNNER mechanism works right. |
|
456 */ |
|
457 QString testsDir(SRCDIR "/.."); |
|
458 QString checktest(SRCDIR "/checktest/checktest"); |
|
459 |
|
460 #if defined(Q_OS_WIN32) || defined(Q_OS_MAC) |
|
461 if (qgetenv("RUN_SLOW_TESTS").isEmpty()) { |
|
462 QSKIP("This test is too slow to run by default on this OS. Set RUN_SLOW_TESTS=1 to run it.", SkipAll); |
|
463 } |
|
464 #endif |
|
465 |
|
466 #ifdef Q_OS_WIN32 |
|
467 checktest.replace("/", "\\"); |
|
468 checktest += ".exe"; |
|
469 #endif |
|
470 |
|
471 QProcess make; |
|
472 make.setWorkingDirectory(testsDir); |
|
473 |
|
474 QStringList arguments; |
|
475 arguments << "-k"; |
|
476 arguments << "check"; |
|
477 arguments << QString("TESTRUNNER=%1").arg(checktest); |
|
478 |
|
479 // find the right make; from externaltests.cpp |
|
480 static const char makes[] = |
|
481 "nmake.exe\0" |
|
482 "mingw32-make.exe\0" |
|
483 "gmake\0" |
|
484 "make\0" |
|
485 ; |
|
486 |
|
487 bool ok = false; |
|
488 for (const char *p = makes; *p; p += strlen(p) + 1) { |
|
489 make.start(p, arguments); |
|
490 if (make.waitForStarted()) { |
|
491 ok = true; |
|
492 break; |
|
493 } |
|
494 } |
|
495 |
|
496 if (!ok) { |
|
497 QFAIL("Could not find the right make tool in PATH"); |
|
498 } |
|
499 |
|
500 QVERIFY(make.waitForFinished(1000 * 60 * 10)); |
|
501 QCOMPARE(make.exitStatus(), QProcess::NormalExit); |
|
502 |
|
503 int pass = 0; |
|
504 QList<QByteArray> out = make.readAllStandardOutput().split('\n'); |
|
505 QStringList fails; |
|
506 foreach (QByteArray line, out) { |
|
507 while (line.endsWith("\r")) { |
|
508 line.chop(1); |
|
509 } |
|
510 if (line.startsWith("CHECKTEST FAIL")) { |
|
511 fails << QString::fromLocal8Bit(line); |
|
512 } |
|
513 if (line.startsWith("CHECKTEST PASS")) { |
|
514 ++pass; |
|
515 } |
|
516 } |
|
517 |
|
518 // We can't check that the exit code of make is 0, because some tests |
|
519 // may have failed to compile, but that doesn't mean `make check' is broken. |
|
520 // We do assume there are at least this many unbroken tests, though. |
|
521 QVERIFY2(fails.count() == 0, |
|
522 qPrintable(QString("`make check' doesn't work for %1 tests:\n%2") |
|
523 .arg(fails.count()).arg(fails.join("\n"))) |
|
524 ); |
|
525 QVERIFY(pass > 50); |
|
526 } |
|
527 |
449 QStringList find_test_class(QString const& filename) |
528 QStringList find_test_class(QString const& filename) |
450 { |
529 { |
451 QStringList out; |
530 QStringList out; |
452 |
531 |
453 QFile file(filename); |
532 QFile file(filename); |