summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-12-16 11:40:25 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-12-16 11:40:25 +1000
commitc5be97bce730a728930ceb2f6a4496ae4d67abcd (patch)
tree8f10f9657c69551511c6060ffcd49b7246b85925
parent2085b06b3fbedf08243c5ed1f3b5f9f7d8b347f1 (diff)
Print the available tests when -functions supplied
-rw-r--r--src/imports/testlib/TestCase.qml23
-rw-r--r--src/quicktestlib/quicktest.cpp8
2 files changed, 30 insertions, 1 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index f4ce323..b61a44d 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -367,6 +367,11 @@ Item {
}
function qtest_run() {
+ if (Qt.qtest_printAvailableFunctions) {
+ completed = true
+ return
+ }
+
if (TestLogger.log_start_test()) {
qtest_results.reset()
qtest_results.testCaseName = name
@@ -481,6 +486,24 @@ Item {
}
Component.onCompleted: {
+ if (Qt.qtest_printAvailableFunctions) {
+ var testList = []
+ for (var prop in testCase) {
+ if (prop.indexOf("test_") != 0 && prop.indexOf("benchmark_") != 0)
+ continue
+ var tail = prop.lastIndexOf("_data");
+ if (tail != -1 && tail == (prop.length - 5))
+ continue
+ if (name.length > 0)
+ testList.push(name + "::" + prop + "()")
+ else
+ testList.push(prop + "()")
+ }
+ testList.sort()
+ for (var index in testList)
+ console.log(testList[index])
+ return
+ }
qtest_testId = TestLogger.log_register_test(name)
if (optional)
TestLogger.log_optional_test(qtest_testId)
diff --git a/src/quicktestlib/quicktest.cpp b/src/quicktestlib/quicktest.cpp
index 826c90f..718c6e9 100644
--- a/src/quicktestlib/quicktest.cpp
+++ b/src/quicktestlib/quicktest.cpp
@@ -42,6 +42,7 @@
#include "quicktest.h"
#include "quicktestresult_p.h"
#include "qtestsystem.h"
+#include "qtestoptions_p.h"
#include <QApplication>
#include <QtDeclarative/qdeclarative.h>
#include <QtDeclarative/qdeclarativeview.h>
@@ -199,7 +200,10 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
QScriptValue qtObject
= engine->globalObject().property(QLatin1String("Qt"));
qtObject.setProperty
- (QLatin1String("qtest_wrapper"), engine->newVariant(true));
+ (QLatin1String("qtest_wrapper"), QScriptValue(true));
+ qtObject.setProperty
+ (QLatin1String("qtest_printAvailableFunctions"),
+ QScriptValue(QTest::printAvailableFunctions));
foreach (QString path, imports)
view.engine()->addImportPath(path);
QString path = fi.absoluteFilePath();
@@ -207,6 +211,8 @@ int quick_test_main(int argc, char **argv, const char *name, quick_test_viewport
view.setSource(QUrl(QLatin1String("qrc:") + path.mid(2)));
else
view.setSource(QUrl::fromLocalFile(path));
+ if (QTest::printAvailableFunctions)
+ continue;
if (view.status() == QDeclarativeView::Error) {
// Error compiling the test - flag failure in the log and continue.
QList<QDeclarativeError> errors = view.errors();