diff options
author | Jo Asplin <jo.asplin@nokia.com> | 2011-06-30 11:34:36 (GMT) |
---|---|---|
committer | Rohan McGovern <rohan.mcgovern@nokia.com> | 2011-07-26 04:19:46 (GMT) |
commit | 4866d1ba8afbab61e102942d1ea93b81fea053d6 (patch) | |
tree | fe31f6c8bddb37c5aa93a5f41d1a3d0e1eb6fc48 /src/testlib | |
parent | df1bd0745ac4dc45d150840f87e32a57829029cb (diff) | |
download | Qt-4866d1ba8afbab61e102942d1ea93b81fea053d6.zip Qt-4866d1ba8afbab61e102942d1ea93b81fea053d6.tar.gz Qt-4866d1ba8afbab61e102942d1ea93b81fea053d6.tar.bz2 |
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
Diffstat (limited to 'src/testlib')
-rw-r--r-- | src/testlib/qtestcase.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index efa0122..d2ea988 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; } } } |