summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJo Asplin <jo.asplin@nokia.com>2011-06-30 13:34:36 +0200
committerRohan McGovern <rohan.mcgovern@nokia.com>2011-07-26 14:19:46 +1000
commit4866d1ba8afbab61e102942d1ea93b81fea053d6 (patch)
treefe31f6c8bddb37c5aa93a5f41d1a3d0e1eb6fc48
parentdf1bd0745ac4dc45d150840f87e32a57829029cb (diff)
Add test case name and drop parentheses for -datatags option.
For completeness, the -datatags command-line option in QTestLib now prints the test case name at the start of each output line. NOTE: Although the file name is supposed to match the lower-case version of the test case name, this is currently not true in all cases (particularly not under tests/benchmarks). Even if there was a script to enforce this convention, the -datatags option now provides this information in a reliable way. This patch also drops the parentheses after the test function as these are always empty anyway. Data tags for each test function (f() in this case) are printed in four different ways depending on the presence of local and global data tags: Case 1: No tags: tst_MyTestCase f Case 2: Local tags only: tst_MyTestCase f local tag 1 tst_MyTestCase f local tag 2 ... Case 3: Global tags only: tst_MyTestCase f __global__ global tag 1 tst_MyTestCase f __global__ global tag 2 ... Case 4: Local and global tags: tst_MyTestCase f local tag 1 __global__ global tag 1 tst_MyTestCase f local tag 2 __global__ global tag 1 ... tst_MyTestCase f local tag 1 __global__ global tag 2 tst_MyTestCase f local tag 2 __global__ global tag 2 ... ... Change-Id: Id9273039a5d33527c32abf6eb1baef80193fa585 Reviewed-by: Rohan McGovern
-rw-r--r--src/testlib/qtestcase.cpp25
-rw-r--r--tests/auto/selftests/expected_printdatatags.txt12
-rw-r--r--tests/auto/selftests/expected_printdatatagswithglobaltags.txt24
-rw-r--r--tests/auto/selftests/printdatatags/tst_printdatatags.cpp14
-rw-r--r--tests/auto/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp18
5 files changed, 49 insertions, 44 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index efa0122fdd..d2ea988f69 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -1035,20 +1035,19 @@ static void qPrintDataTags()
invokeMethod(QTest::currentTestObject, "initTestCase_data()");
const QTestTable *gTable = QTestTable::globalTestTable();
+ const QMetaObject *currTestMetaObj = QTest::currentTestObject->metaObject();
+
// Process test functions:
- for (int i = 0; i < QTest::currentTestObject->metaObject()->methodCount(); ++i) {
- QMetaMethod tf = QTest::currentTestObject->metaObject()->method(i);
+ for (int i = 0; i < currTestMetaObj->methodCount(); ++i) {
+ QMetaMethod tf = currTestMetaObj->method(i);
if (isValidSlot(tf)) {
- const char *slotName = tf.signature();
-
// Retrieve local tags:
QStringList localTags;
QTestTable table;
char member[512];
- char *slot = qstrdup(slotName);
+ char *slot = qstrdup(tf.signature());
slot[strlen(slot) - 2] = '\0';
QTest::qt_snprintf(member, 512, "%s_data()", slot);
- delete[] slot;
invokeMethod(QTest::currentTestObject, member);
for (int j = 0; j < table.dataCount(); ++j)
localTags << QLatin1String(table.testData(j)->dataTag());
@@ -1057,27 +1056,33 @@ static void qPrintDataTags()
if (gTable->dataCount() == 0) {
if (localTags.count() == 0) {
// No tags at all, so just print the test function:
- printf("%s\n", slotName);
+ printf("%s %s\n", currTestMetaObj->className(), slot);
} else {
// Only local tags, so print each of them:
for (int k = 0; k < localTags.size(); ++k)
- printf("%s %s\n", slotName, localTags.at(k).toLatin1().data());
+ printf(
+ "%s %s %s\n",
+ currTestMetaObj->className(), slot, localTags.at(k).toLatin1().data());
}
} else {
for (int j = 0; j < gTable->dataCount(); ++j) {
if (localTags.count() == 0) {
// Only global tags, so print the current one:
- printf("%s __global__ %s\n", slotName, gTable->testData(j)->dataTag());
+ printf(
+ "%s %s __global__ %s\n",
+ currTestMetaObj->className(), slot, gTable->testData(j)->dataTag());
} else {
// Local and global tags, so print each of the local ones and
// the current global one:
for (int k = 0; k < localTags.size(); ++k)
printf(
- "%s %s __global__ %s\n", slotName,
+ "%s %s %s __global__ %s\n", currTestMetaObj->className(), slot,
localTags.at(k).toLatin1().data(), gTable->testData(j)->dataTag());
}
}
}
+
+ delete[] slot;
}
}
}
diff --git a/tests/auto/selftests/expected_printdatatags.txt b/tests/auto/selftests/expected_printdatatags.txt
index 02390dc7dd..ac22f231a4 100644
--- a/tests/auto/selftests/expected_printdatatags.txt
+++ b/tests/auto/selftests/expected_printdatatags.txt
@@ -1,6 +1,6 @@
-a() data tag a1
-a() data tag a2
-b()
-c() data tag c1
-c() data tag c2
-c() data tag c3
+tst_MyTestCase a data tag a1
+tst_MyTestCase a data tag a2
+tst_MyTestCase b
+tst_MyTestCase c data tag c1
+tst_MyTestCase c data tag c2
+tst_MyTestCase c data tag c3
diff --git a/tests/auto/selftests/expected_printdatatagswithglobaltags.txt b/tests/auto/selftests/expected_printdatatagswithglobaltags.txt
index a91e1b86d8..32feba4afb 100644
--- a/tests/auto/selftests/expected_printdatatagswithglobaltags.txt
+++ b/tests/auto/selftests/expected_printdatatagswithglobaltags.txt
@@ -1,12 +1,12 @@
-a() data tag a1 __global__ global data tag 1
-a() data tag a2 __global__ global data tag 1
-a() data tag a1 __global__ global data tag 2
-a() data tag a2 __global__ global data tag 2
-b() __global__ global data tag 1
-b() __global__ global data tag 2
-c() data tag c1 __global__ global data tag 1
-c() data tag c2 __global__ global data tag 1
-c() data tag c3 __global__ global data tag 1
-c() data tag c1 __global__ global data tag 2
-c() data tag c2 __global__ global data tag 2
-c() data tag c3 __global__ global data tag 2
+tst_MyTestCase a data tag a1 __global__ global data tag 1
+tst_MyTestCase a data tag a2 __global__ global data tag 1
+tst_MyTestCase a data tag a1 __global__ global data tag 2
+tst_MyTestCase a data tag a2 __global__ global data tag 2
+tst_MyTestCase b __global__ global data tag 1
+tst_MyTestCase b __global__ global data tag 2
+tst_MyTestCase c data tag c1 __global__ global data tag 1
+tst_MyTestCase c data tag c2 __global__ global data tag 1
+tst_MyTestCase c data tag c3 __global__ global data tag 1
+tst_MyTestCase c data tag c1 __global__ global data tag 2
+tst_MyTestCase c data tag c2 __global__ global data tag 2
+tst_MyTestCase c data tag c3 __global__ global data tag 2
diff --git a/tests/auto/selftests/printdatatags/tst_printdatatags.cpp b/tests/auto/selftests/printdatatags/tst_printdatatags.cpp
index 4b533b3283..79f889072f 100644
--- a/tests/auto/selftests/printdatatags/tst_printdatatags.cpp
+++ b/tests/auto/selftests/printdatatags/tst_printdatatags.cpp
@@ -42,7 +42,7 @@
#include <QtTest/QtTest>
-class tst_Foo: public QObject
+class tst_MyTestCase: public QObject
{
Q_OBJECT
private slots:
@@ -55,7 +55,7 @@ private slots:
void c() const;
};
-void tst_Foo::a_data() const
+void tst_MyTestCase::a_data() const
{
QTest::addColumn<int>("x");
QTest::addColumn<int>("y");
@@ -64,15 +64,15 @@ void tst_Foo::a_data() const
QTest::newRow("data tag a2") << 1 << 2;
}
-void tst_Foo::a() const
+void tst_MyTestCase::a() const
{
}
-void tst_Foo::b() const
+void tst_MyTestCase::b() const
{
}
-void tst_Foo::c_data() const
+void tst_MyTestCase::c_data() const
{
QTest::addColumn<int>("x");
@@ -81,10 +81,10 @@ void tst_Foo::c_data() const
QTest::newRow("data tag c3") << 1;
}
-void tst_Foo::c() const
+void tst_MyTestCase::c() const
{
}
-QTEST_MAIN(tst_Foo)
+QTEST_MAIN(tst_MyTestCase)
#include "tst_printdatatags.moc"
diff --git a/tests/auto/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp b/tests/auto/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp
index 931dc12372..6b0e61b7cd 100644
--- a/tests/auto/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp
+++ b/tests/auto/selftests/printdatatagswithglobaltags/tst_printdatatagswithglobaltags.cpp
@@ -42,7 +42,7 @@
#include <QtTest/QtTest>
-class tst_Foo: public QObject
+class tst_MyTestCase: public QObject
{
Q_OBJECT
private slots:
@@ -58,7 +58,7 @@ private slots:
void c() const;
};
-void tst_Foo::initTestCase_data() const
+void tst_MyTestCase::initTestCase_data() const
{
QTest::addColumn<int>("f");
QTest::addColumn<int>("g");
@@ -67,11 +67,11 @@ void tst_Foo::initTestCase_data() const
QTest::newRow("global data tag 2") << 1 << 2;
}
-void tst_Foo::initTestCase() const
+void tst_MyTestCase::initTestCase() const
{
}
-void tst_Foo::a_data() const
+void tst_MyTestCase::a_data() const
{
QTest::addColumn<int>("x");
QTest::addColumn<int>("y");
@@ -80,15 +80,15 @@ void tst_Foo::a_data() const
QTest::newRow("data tag a2") << 1 << 2;
}
-void tst_Foo::a() const
+void tst_MyTestCase::a() const
{
}
-void tst_Foo::b() const
+void tst_MyTestCase::b() const
{
}
-void tst_Foo::c_data() const
+void tst_MyTestCase::c_data() const
{
QTest::addColumn<int>("x");
@@ -97,10 +97,10 @@ void tst_Foo::c_data() const
QTest::newRow("data tag c3") << 1;
}
-void tst_Foo::c() const
+void tst_MyTestCase::c() const
{
}
-QTEST_MAIN(tst_Foo)
+QTEST_MAIN(tst_MyTestCase)
#include "tst_printdatatagswithglobaltags.moc"