Commit c8c79c40 authored by Christian Stenger's avatar Christian Stenger
Browse files

Make test result distinguishable more easily



This additionally fixes the output of the gtest related test cases.

Change-Id: Ia9e19604ffe387752b08db4a4ad9a9e255d210a3
Reviewed-by: default avatarNiels Weber <niels.weber@theqtcompany.com>
parent e0a05d47
......@@ -183,14 +183,14 @@ void TestOutputReader::processOutput()
if (currentTag == QStringLiteral("TestCase")) {
className = xmlReader.attributes().value(QStringLiteral("name")).toString();
QTC_ASSERT(!className.isEmpty(), continue);
auto testResult = new TestResult(className);
auto testResult = new QTestResult(className);
testResult->setResult(Result::MessageTestCaseStart);
testResult->setDescription(tr("Executing test case %1").arg(className));
testResultCreated(testResult);
} else if (currentTag == QStringLiteral("TestFunction")) {
testCase = xmlReader.attributes().value(QStringLiteral("name")).toString();
QTC_ASSERT(!testCase.isEmpty(), continue);
auto testResult = new TestResult();
auto testResult = new QTestResult();
testResult->setResult(Result::MessageCurrentTest);
testResult->setDescription(tr("Entering test function %1::%2").arg(className,
testCase));
......@@ -274,7 +274,7 @@ void TestOutputReader::processOutput()
const QStringRef currentTag = xmlReader.name();
if (currentTag == QStringLiteral("TestFunction")) {
if (!duration.isEmpty()) {
auto testResult = new TestResult(className);
auto testResult = new QTestResult(className);
testResult->setTestCase(testCase);
testResult->setResult(Result::MessageInternal);
testResult->setDescription(tr("Execution took %1 ms.").arg(duration));
......@@ -282,14 +282,14 @@ void TestOutputReader::processOutput()
}
emit increaseProgress();
} else if (currentTag == QStringLiteral("TestCase")) {
auto testResult = new TestResult(className);
auto testResult = new QTestResult(className);
testResult->setResult(Result::MessageTestCaseEnd);
testResult->setDescription(
duration.isEmpty() ? tr("Test finished.")
: tr("Test execution took %1 ms.").arg(duration));
testResultCreated(testResult);
} else if (validEndTags.contains(currentTag.toString())) {
auto testResult = new TestResult(className);
auto testResult = new QTestResult(className);
testResult->setTestCase(testCase);
testResult->setDataTag(dataTag);
testResult->setResult(result);
......@@ -337,13 +337,13 @@ void TestOutputReader::processGTestOutput()
if (!line.startsWith(QLatin1Char('['))) {
description.append(line).append(QLatin1Char('\n'));
if (line.startsWith(QStringLiteral("Note:"))) {
auto testResult = new TestResult();
auto testResult = new GTestResult();
testResult->setResult(Result::MessageInternal);
testResult->setDescription(line);
testResultCreated(testResult);
description.clear();
} else if (disabledTests.exactMatch(line)) {
auto testResult = new TestResult();
auto testResult = new GTestResult();
testResult->setResult(Result::MessageInternal);
int disabled = disabledTests.cap(1).toInt();
testResult->setDescription(tr("You have %n disabled test(s).", 0, disabled));
......@@ -354,7 +354,7 @@ void TestOutputReader::processGTestOutput()
}
if (testEnds.exactMatch(line)) {
auto testResult = new TestResult(currentTestName);
auto testResult = new GTestResult(currentTestName);
testResult->setTestCase(currentTestSet);
testResult->setResult(Result::MessageTestCaseEnd);
testResult->setDescription(tr("Test execution took %1").arg(testEnds.cap(2)));
......@@ -363,29 +363,29 @@ void TestOutputReader::processGTestOutput()
currentTestSet.clear();
} else if (newTestStarts.exactMatch(line)) {
currentTestName = newTestStarts.cap(1);
auto testResult = new TestResult(currentTestName);
auto testResult = new GTestResult(currentTestName);
testResult->setResult(Result::MessageTestCaseStart);
testResult->setDescription(tr("Executing test case %1").arg(currentTestName));
testResultCreated(testResult);
} else if (newTestSetStarts.exactMatch(line)) {
currentTestSet = newTestSetStarts.cap(1);
auto testResult = new TestResult();
auto testResult = new GTestResult();
testResult->setResult(Result::MessageCurrentTest);
testResult->setDescription(tr("Entering test set %1").arg(currentTestSet));
testResultCreated(testResult);
} else if (testSetSuccess.exactMatch(line)) {
auto testResult = new TestResult(currentTestName);
auto testResult = new GTestResult(currentTestName);
testResult->setTestCase(currentTestSet);
testResult->setResult(Result::Pass);
testResultCreated(testResult);
testResult = new TestResult(currentTestName);
testResult = new GTestResult(currentTestName);
testResult->setTestCase(currentTestSet);
testResult->setResult(Result::MessageInternal);
testResult->setDescription(tr("Execution took %1.").arg(testSetSuccess.cap(2)));
testResultCreated(testResult);
emit increaseProgress();
} else if (testSetFail.exactMatch(line)) {
auto testResult = new TestResult(currentTestName);
auto testResult = new GTestResult(currentTestName);
testResult->setTestCase(currentTestSet);
testResult->setResult(Result::Fail);
description.chop(1);
......@@ -402,7 +402,7 @@ void TestOutputReader::processGTestOutput()
}
testResultCreated(testResult);
description.clear();
testResult = new TestResult(currentTestName);
testResult = new GTestResult(currentTestName);
testResult->setTestCase(currentTestSet);
testResult->setResult(Result::MessageInternal);
testResult->setDescription(tr("Execution took %1.").arg(testSetFail.cap(2)));
......
......@@ -37,6 +37,7 @@ TestResult::TestResult(const QString &className)
: m_class(className)
, m_result(Result::Invalid)
, m_line(0)
, m_type(Qt)
{
}
......@@ -146,5 +147,16 @@ bool operator==(const TestResult &t1, const TestResult &t2)
&& t1.result() == t2.result();
}
QTestResult::QTestResult(const QString &className)
: TestResult(className)
{
}
GTestResult::GTestResult(const QString &className)
: TestResult(className)
{
setTestType(GTest);
}
} // namespace Internal
} // namespace Autotest
......@@ -57,6 +57,12 @@ enum Type {
class TestResult
{
public:
enum TestType
{
Qt,
GTest
};
TestResult();
TestResult(const QString &className);
......@@ -67,6 +73,7 @@ public:
QString description() const { return m_description; }
QString fileName() const { return m_file; }
int line() const { return m_line; }
TestType type() const { return m_type; }
void setDescription(const QString &description) { m_description = description; }
void setFileName(const QString &fileName) { m_file = fileName; }
......@@ -74,6 +81,7 @@ public:
void setResult(Result::Type type) { m_result = type; }
void setTestCase(const QString &testCase) { m_case = testCase; }
void setDataTag(const QString &dataTag) { m_dataTag = dataTag; }
void setTestType(TestType type) { m_type = type; }
static Result::Type resultFromString(const QString &resultString);
static Result::Type toResultType(int rt);
......@@ -88,6 +96,7 @@ private:
QString m_description;
QString m_file;
int m_line;
TestType m_type;
// environment?
};
......@@ -97,6 +106,18 @@ public:
FaultyTestResult(Result::Type result, const QString &description);
};
class QTestResult : public TestResult
{
public:
QTestResult(const QString &className = QString());
};
class GTestResult : public TestResult
{
public:
GTestResult(const QString &className = QString());
};
bool operator==(const TestResult &t1, const TestResult &t2);
} // namespace Internal
......
......@@ -48,7 +48,10 @@ QString TestResultDelegate::outputString(const TestResult &testResult, bool sele
case Result::UnexpectedPass:
case Result::BlacklistedFail:
case Result::BlacklistedPass:
output = testResult.className() + QLatin1String("::") + testResult.testCase();
if (testResult.type() == TestResult::Qt)
output = testResult.className() + QLatin1String("::") + testResult.testCase();
else // TestResult::GTest
output = testResult.testCase();
if (!testResult.dataTag().isEmpty())
output.append(QString::fromLatin1(" (%1)").arg(testResult.dataTag()));
if (selected && !desc.isEmpty()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment