forked from qt-creator/qt-creator
AutoTest: generalize create default result
Add a pure virtual function to TestOutputReader returning a pointer to a default constructed result. Change-Id: Icd8090346f2c5115a7c548da7ba69ea54fe39fc4 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -92,15 +92,15 @@ void GTestOutputReader::processOutput(const QByteArray &outputLine)
|
||||
}
|
||||
|
||||
if (testEnds.exactMatch(line)) {
|
||||
GTestResult *testResult = createDefaultResult();
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageTestCaseEnd);
|
||||
testResult->setDescription(tr("Test execution took %1").arg(testEnds.cap(2)));
|
||||
reportResult(TestResultPtr(testResult));
|
||||
reportResult(testResult);
|
||||
m_currentTestName.clear();
|
||||
m_currentTestSet.clear();
|
||||
} else if (newTestStarts.exactMatch(line)) {
|
||||
setCurrentTestName(newTestStarts.cap(1));
|
||||
TestResultPtr testResult = TestResultPtr(createDefaultResult());
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageTestCaseStart);
|
||||
if (m_iteration > 1) {
|
||||
testResult->setDescription(tr("Repeating test case %1 (iteration %2)")
|
||||
@@ -117,18 +117,18 @@ void GTestOutputReader::processOutput(const QByteArray &outputLine)
|
||||
reportResult(testResult);
|
||||
m_description.clear();
|
||||
} else if (testSetSuccess.exactMatch(line)) {
|
||||
GTestResult *testResult = createDefaultResult();
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(Result::Pass);
|
||||
testResult->setDescription(m_description);
|
||||
reportResult(TestResultPtr(testResult));
|
||||
reportResult(testResult);
|
||||
m_description.clear();
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageInternal);
|
||||
testResult->setDescription(tr("Execution took %1.").arg(testSetSuccess.cap(2)));
|
||||
reportResult(TestResultPtr(testResult));
|
||||
reportResult(testResult);
|
||||
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
|
||||
} else if (testSetFail.exactMatch(line)) {
|
||||
GTestResult *testResult = createDefaultResult();
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(Result::Fail);
|
||||
m_description.chop(1);
|
||||
testResult->setDescription(m_description);
|
||||
@@ -149,27 +149,17 @@ void GTestOutputReader::processOutput(const QByteArray &outputLine)
|
||||
}
|
||||
}
|
||||
}
|
||||
reportResult(TestResultPtr(testResult));
|
||||
reportResult(testResult);
|
||||
m_description.clear();
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(Result::MessageInternal);
|
||||
testResult->setDescription(tr("Execution took %1.").arg(testSetFail.cap(2)));
|
||||
reportResult(TestResultPtr(testResult));
|
||||
reportResult(testResult);
|
||||
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void GTestOutputReader::setCurrentTestSet(const QString &testSet)
|
||||
{
|
||||
m_currentTestSet = testSet;
|
||||
}
|
||||
|
||||
void GTestOutputReader::setCurrentTestName(const QString &testName)
|
||||
{
|
||||
m_currentTestName = testName;
|
||||
}
|
||||
|
||||
GTestResult *GTestOutputReader::createDefaultResult() const
|
||||
TestResultPtr GTestOutputReader::createDefaultResult() const
|
||||
{
|
||||
GTestResult *result = new GTestResult(m_executable, m_projectFile, m_currentTestName);
|
||||
result->setTestSetName(m_currentTestSet);
|
||||
@@ -182,7 +172,17 @@ GTestResult *GTestOutputReader::createDefaultResult() const
|
||||
result->setLine(static_cast<int>(testItem->line()));
|
||||
}
|
||||
|
||||
return result;
|
||||
return TestResultPtr(result);
|
||||
}
|
||||
|
||||
void GTestOutputReader::setCurrentTestSet(const QString &testSet)
|
||||
{
|
||||
m_currentTestSet = testSet;
|
||||
}
|
||||
|
||||
void GTestOutputReader::setCurrentTestName(const QString &testName)
|
||||
{
|
||||
m_currentTestName = testName;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user