summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-14 08:09:31 +0000
committerThe Qt Project <gerrit-noreply@qt-project.org>2018-02-14 08:31:10 +0000
commit318f728283c08ffb93c7469f671b43a010c57e0d (patch)
tree97263966156bab079aaa8b74885a1657e3a960e8 /src/testlib
parenta3447586402a1ca6f40cb6676272f956e5d64431 (diff)
parent9c055e8e47d9411a8f34abe6872e4bfd942cc372 (diff)
Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev
Diffstat (limited to 'src/testlib')
-rw-r--r--src/testlib/qplaintestlogger.cpp47
-rw-r--r--src/testlib/qtestcase.qdoc2
2 files changed, 29 insertions, 20 deletions
diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp
index 77959341cf..25c9655691 100644
--- a/src/testlib/qplaintestlogger.cpp
+++ b/src/testlib/qplaintestlogger.cpp
@@ -223,38 +223,47 @@ void QPlainTestLogger::outputMessage(const char *str)
outputString(str);
}
+static QTestCharBuffer testIdentifier()
+{
+ QTestCharBuffer identifier;
+
+ const char *testObject = QTestResult::currentTestObjectName();
+ const char *testFunction = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction() : "UnknownTestFunc";
+
+ const char *dataTag = QTestResult::currentDataTag() ? QTestResult::currentDataTag() : "";
+ const char *globalDataTag = QTestResult::currentGlobalDataTag() ? QTestResult::currentGlobalDataTag() : "";
+ const char *tagFiller = (dataTag[0] && globalDataTag[0]) ? ":" : "";
+
+ QTest::qt_asprintf(&identifier, "%s::%s(%s%s%s)", testObject, testFunction, globalDataTag, tagFiller, dataTag);
+ return identifier;
+}
+
void QPlainTestLogger::printMessage(const char *type, const char *msg, const char *file, int line)
{
QTEST_ASSERT(type);
QTEST_ASSERT(msg);
- QTestCharBuffer buf;
+ QTestCharBuffer messagePrefix;
- const char *fn = QTestResult::currentTestFunction() ? QTestResult::currentTestFunction()
- : "UnknownTestFunc";
- const char *tag = QTestResult::currentDataTag() ? QTestResult::currentDataTag() : "";
- const char *gtag = QTestResult::currentGlobalDataTag()
- ? QTestResult::currentGlobalDataTag()
- : "";
- const char *filler = (tag[0] && gtag[0]) ? ":" : "";
+ QTestCharBuffer failureLocation;
if (file) {
- QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n"
#ifdef Q_OS_WIN
- "%s(%d) : failure location\n"
+#define FAILURE_LOCATION_STR "\n%s(%d) : failure location"
#else
- " Loc: [%s(%d)]\n"
+#define FAILURE_LOCATION_STR "\n Loc: [%s(%d)]"
#endif
- , type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
- msg[0] ? " " : "", msg, file, line);
- } else {
- QTest::qt_asprintf(&buf, "%s: %s::%s(%s%s%s)%s%s\n",
- type, QTestResult::currentTestObjectName(), fn, gtag, filler, tag,
- msg[0] ? " " : "", msg);
+ QTest::qt_asprintf(&failureLocation, FAILURE_LOCATION_STR, file, line);
}
+
+ const char *msgFiller = msg[0] ? " " : "";
+ QTest::qt_asprintf(&messagePrefix, "%s: %s%s%s%s\n",
+ type, testIdentifier().data(), msgFiller, msg, failureLocation.data());
+
// In colored mode, printf above stripped our nonprintable control characters.
// Put them back.
- memcpy(buf.data(), type, strlen(type));
- outputMessage(buf.data());
+ memcpy(messagePrefix.data(), type, strlen(type));
+
+ outputMessage(messagePrefix.data());
}
void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result)
diff --git a/src/testlib/qtestcase.qdoc b/src/testlib/qtestcase.qdoc
index 0fb1cc6a8a..9a3c770e31 100644
--- a/src/testlib/qtestcase.qdoc
+++ b/src/testlib/qtestcase.qdoc
@@ -103,7 +103,7 @@
to catch an exception thrown from the \a expression. If the \a expression
throws an exception and its type is the same as \a exceptiontype
or \a exceptiontype is substitutable with the type of thrown exception
- (i.e. usually the type of thrown exception is publically derived
+ (i.e. usually the type of thrown exception is publicly derived
from \a exceptiontype) then execution will be continued. If not-substitutable
type of exception is thrown or the \a expression doesn't throw an exception
at all, then a failure will be recorded in the test log and