AutoTest: Fix handling of data tags in test results

Avoid adding test functions again and put further data tags
directly below the respective test function.

Change-Id: I29775b836cc4584358ee67b5f07744986c6a6591
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2017-01-19 12:15:59 +01:00
parent e2b909c6b6
commit ae2c068e68
6 changed files with 15 additions and 3 deletions

View File

@@ -169,6 +169,8 @@ void QtTestOutputReader::processOutput(const QByteArray &outputLine)
} else if (currentTag == QStringLiteral("TestFunction")) { } else if (currentTag == QStringLiteral("TestFunction")) {
m_testCase = m_xmlReader.attributes().value(QStringLiteral("name")).toString(); m_testCase = m_xmlReader.attributes().value(QStringLiteral("name")).toString();
QTC_ASSERT(!m_testCase.isEmpty(), continue); QTC_ASSERT(!m_testCase.isEmpty(), continue);
if (m_testCase == m_formerTestCase) // don't report "Executing..." more than once
continue;
TestResultPtr testResult = TestResultPtr(createDefaultResult()); TestResultPtr testResult = TestResultPtr(createDefaultResult());
testResult->setResult(Result::MessageTestCaseStart); testResult->setResult(Result::MessageTestCaseStart);
testResult->setDescription(tr("Executing test function %1").arg(m_testCase)); testResult->setDescription(tr("Executing test function %1").arg(m_testCase));
@@ -261,6 +263,7 @@ void QtTestOutputReader::processOutput(const QByteArray &outputLine)
m_futureInterface.reportResult(TestResultPtr(testResult)); m_futureInterface.reportResult(TestResultPtr(testResult));
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1); m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
m_dataTag.clear(); m_dataTag.clear();
m_formerTestCase = m_testCase;
m_testCase.clear(); m_testCase.clear();
} else if (currentTag == QStringLiteral("TestCase")) { } else if (currentTag == QStringLiteral("TestCase")) {
QtTestResult *testResult = createDefaultResult(); QtTestResult *testResult = createDefaultResult();

View File

@@ -62,6 +62,7 @@ private:
CDATAMode m_cdataMode = None; CDATAMode m_cdataMode = None;
QString m_className; QString m_className;
QString m_testCase; QString m_testCase;
QString m_formerTestCase;
QString m_dataTag; QString m_dataTag;
Result::Type m_result = Result::Invalid; Result::Type m_result = Result::Invalid;
QString m_description; QString m_description;

View File

@@ -78,7 +78,8 @@ bool QtTestResult::isDirectParentOf(const TestResult *other, bool *needsIntermed
if (!TestResult::isDirectParentOf(other, needsIntermediate)) if (!TestResult::isDirectParentOf(other, needsIntermediate))
return false; return false;
const QtTestResult *qtOther = static_cast<const QtTestResult *>(other); const QtTestResult *qtOther = static_cast<const QtTestResult *>(other);
if (result() == Result::MessageTestCaseStart || result() == Result::MessageIntermediate) {
if (TestResult::isMessageCaseStart(result())) {
if (qtOther->isDataTag()) { if (qtOther->isDataTag()) {
if (qtOther->m_function == m_function) { if (qtOther->m_function == m_function) {
if (m_dataTag.isEmpty()) { if (m_dataTag.isEmpty()) {

View File

@@ -161,6 +161,13 @@ QColor TestResult::colorForType(const Result::Type type)
} }
} }
bool TestResult::isMessageCaseStart(const Result::Type type)
{
return type == Result::MessageTestCaseStart || type == Result::MessageTestCaseSuccess
|| type == Result::MessageTestCaseFail || type == Result::MessageTestCaseWarn
|| type == Result::MessageIntermediate;
}
bool TestResult::isDirectParentOf(const TestResult *other, bool * /*needsIntermediate*/) const bool TestResult::isDirectParentOf(const TestResult *other, bool * /*needsIntermediate*/) const
{ {
QTC_ASSERT(other, return false); QTC_ASSERT(other, return false);

View File

@@ -90,6 +90,7 @@ public:
static Result::Type toResultType(int rt); static Result::Type toResultType(int rt);
static QString resultToString(const Result::Type type); static QString resultToString(const Result::Type type);
static QColor colorForType(const Result::Type type); static QColor colorForType(const Result::Type type);
static bool isMessageCaseStart(const Result::Type type);
virtual bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const; virtual bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const;
virtual bool isIntermediateFor(const TestResult *other) const; virtual bool isIntermediateFor(const TestResult *other) const;

View File

@@ -99,8 +99,7 @@ void TestResultItem::updateDescription(const QString &description)
void TestResultItem::updateResult() void TestResultItem::updateResult()
{ {
if (m_testResult->result() != Result::MessageTestCaseStart if (!TestResult::isMessageCaseStart(m_testResult->result()))
&& m_testResult->result() != Result::MessageIntermediate)
return; return;
Result::Type newResult = Result::MessageTestCaseSuccess; Result::Type newResult = Result::MessageTestCaseSuccess;