summaryrefslogtreecommitdiffstats
path: root/src/testlib
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-13 22:56:02 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-13 22:56:03 +0100
commit9c055e8e47d9411a8f34abe6872e4bfd942cc372 (patch)
tree895e139477c88a064a993f035afec614de9dafc7 /src/testlib
parentd08e0e861acadf3a354d3833dd5623ef71fa7a4b (diff)
parent76010f4af8c9a59a20c489d70c7f99b802f9721f (diff)
Merge remote-tracking branch 'origin/5.11' into 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