author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-13 04:51:21 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-04-13 04:52:03 (GMT) |
commit | 89cc9cfa72c1e571699caca7488d0c37dadb015d (patch) | |
tree | f902694330205db5db605f30ee3dfeb15cd623e1 /tests | |
parent | 79d0a9696af910a446cd535148880a9fb6cdf90f (diff) | |
download | Qt-89cc9cfa72c1e571699caca7488d0c37dadb015d.zip Qt-89cc9cfa72c1e571699caca7488d0c37dadb015d.tar.gz Qt-89cc9cfa72c1e571699caca7488d0c37dadb015d.tar.bz2 |
diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index 85d2a73..b316cb9 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle SOURCES += tst_examples.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 3d717bc..64734af 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -44,6 +44,13 @@ #include <QProcess> #include <QDebug> +#define CONCURRENT + +#ifdef CONCURRENT +#include <QFutureSynchronizer> +#include <QtConcurrentRun> +#endif + class tst_examples : public QObject { Q_OBJECT @@ -51,7 +58,9 @@ public: tst_examples(); private slots: +#ifndef CONCURRENT void examples_data(); +#endif void examples(); void namingConvention(); @@ -163,6 +172,8 @@ QStringList tst_examples::findQmlFiles(const QDir &d) return rv; } + + /* This test runs all the examples in the declarative UI source tree and ensures that they start and exit cleanly. @@ -170,6 +181,7 @@ that they start and exit cleanly. Examples are any .qml files under the examples/ or demos/ directory that start with a lower case letter. */ +#ifndef CONCURRENT void tst_examples::examples_data() { QTest::addColumn<QString>("file"); @@ -186,9 +198,91 @@ void tst_examples::examples_data() foreach (const QString &file, files) QTest::newRow(file.toLatin1().constData()) << file; } +#endif + +#ifdef CONCURRENT +#define THREADS 5 + +struct Example { +public: + Example() : result(Unknown) {} + + enum Result { Pass, Unknown, Fail }; + Result result; + QString file; + QString qmlruntime; + + void run(); +}; + +void Example::run() +{ + QFileInfo fi(file); + QFileInfo dir(fi.path()); + QString script = SRCDIR "/data/"+dir.baseName()+"/"+fi.baseName(); + QFileInfo testdata(script+".qml"); + QStringList arguments; + arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest")) + << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure" + << file; + QProcess p; + p.start(qmlruntime, arguments); + if (!p.waitForFinished()) { + result = Fail; + return; + } + + if (p.exitStatus() != QProcess::NormalExit || p.exitCode() != 0) + qWarning() << p.readAllStandardOutput() << p.readAllStandardError(); + + if (p.exitStatus() != QProcess::NormalExit || + p.exitCode() != 0) { + result = Fail; + return; + } else { + result = Pass; + return; + } +} +#endif void tst_examples::examples() { +#ifdef CONCURRENT + QThreadPool::globalInstance()->setMaxThreadCount(5); + + QString examples = QLibraryInfo::location(QLibraryInfo::ExamplesPath); + QString demos = QLibraryInfo::location(QLibraryInfo::DemosPath); + QString snippets = QLatin1String(SRCDIR) + "/../../../../doc/src/snippets/"; + + QStringList files; + files << findQmlFiles(QDir(examples)); + files << findQmlFiles(QDir(demos)); + files << findQmlFiles(QDir(snippets)); + + QList<Example> tests; + + for (int ii = 0; ii < files.count(); ++ii) { + Example e; + e.file = files.at(ii); + e.qmlruntime = qmlruntime; + tests << e; + } + + QFutureSynchronizer<void> sync; + + for (int ii = 0; ii < tests.count(); ++ii) { + QFuture<void> r = QtConcurrent::run(tests.at(ii), &Example::run); + sync.addFuture(r); + } + + sync.waitForFinished(); + + for (int ii = 0; ii < tests.count(); ++ii) + QVERIFY(tests.at(ii).result == Example::Pass); + +#else + QFETCH(QString, file); QFileInfo fi(file); @@ -210,6 +304,7 @@ void tst_examples::examples() qWarning() << p.readAllStandardOutput() << p.readAllStandardError(); QCOMPARE(p.exitStatus(), QProcess::NormalExit); QCOMPARE(p.exitCode(), 0); +#endif } QTEST_MAIN(tst_examples) diff --git a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro b/tests/auto/declarative/graphicswidgets/graphicswidgets.pro index 712c34c..b77b430 100644 --- a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro +++ b/tests/auto/declarative/graphicswidgets/graphicswidgets.pro @@ -6,3 +6,5 @@ SOURCES += tst_graphicswidgets.cpp # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test diff --git a/tests/auto/declarative/parserstress/parserstress.pro b/tests/auto/declarative/parserstress/parserstress.pro index 48f147a..8830511 100644 --- a/tests/auto/declarative/parserstress/parserstress.pro +++ b/tests/auto/declarative/parserstress/parserstress.pro @@ -5,3 +5,6 @@ macx:CONFIG -= app_bundle SOURCES += tst_parserstress.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro index ca2f68f..a2403f2 100644 --- a/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro +++ b/tests/auto/declarative/qdeclarativeanchors/qdeclarativeanchors.pro @@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativeanchors.cpp macx:CONFIG -= app_bundle DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro index 2904986..74f9be0 100644 --- a/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro +++ b/tests/auto/declarative/qdeclarativeanimatedimage/qdeclarativeanimatedimage.pro @@ -5,3 +5,6 @@ SOURCES += tst_qdeclarativeanimatedimage.cpp ../shared/testhttpserver.cpp macx:CONFIG -= app_bundle DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro index 8eac75f..ce38eeb 100644 --- a/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro +++ b/tests/auto/declarative/qdeclarativeanimations/qdeclarativeanimations.pro @@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativeanimations.cpp macx:CONFIG -= app_bundle DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro index a1dac32..c2781b8 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro +++ b/tests/auto/declarative/qdeclarativebehaviors/qdeclarativebehaviors.pro @@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativebehaviors.cpp macx:CONFIG -= app_bundle DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro index 7879976..04dd6f5 100644 --- a/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro +++ b/tests/auto/declarative/qdeclarativebinding/qdeclarativebinding.pro @@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativebinding.cpp # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro index 0574ddb..e754923 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro +++ b/tests/auto/declarative/qdeclarativeborderimage/qdeclarativeborderimage.pro @@ -7,3 +7,6 @@ SOURCES += tst_qdeclarativeborderimage.cpp ../shared/testhttpserver.cpp # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro index c7affb7..e58c798 100644 --- a/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro +++ b/tests/auto/declarative/qdeclarativecomponent/qdeclarativecomponent.pro @@ -6,3 +6,6 @@ macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativecomponent.cpp DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro index a6adfa4..959354d 100644 --- a/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro +++ b/tests/auto/declarative/qdeclarativeconnection/qdeclarativeconnection.pro @@ -6,3 +6,6 @@ SOURCES += tst_qdeclarativeconnection.cpp # Define SRCDIR equal to test's source directory DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro index adace70..5db9a9e 100644 --- a/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro +++ b/tests/auto/declarative/qdeclarativecontext/qdeclarativecontext.pro @@ -4,3 +4,6 @@ SOURCES += tst_qdeclarativecontext.cpp macx:CONFIG -= app_bundle DEFINES += SRCDIR=\\\"$$PWD\\\" + +CONFIG += parallel_test + diff --git a/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro b/tests/auto/declarative/qdeclarativedebug/qdeclarativedebug.pro |