forked from qt-creator/qt-creator
AutoTest: Use TestResult as value type
Don't construct it on heap and don't use shared pointer for it. Change-Id: I51c9da405ed14d24b5f20242b4d049f9e2958f09 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -17,7 +17,7 @@ namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
TestOutputReader *BoostTestConfiguration::createOutputReader(
|
||||
const QFutureInterface<TestResultPtr> &fi, Utils::QtcProcess *app) const
|
||||
const QFutureInterface<TestResult> &fi, Utils::QtcProcess *app) const
|
||||
{
|
||||
auto settings = static_cast<BoostTestSettings *>(framework()->testSettings());
|
||||
return new BoostTestOutputReader(fi, app, buildDirectory(), projectFile(),
|
||||
|
@@ -13,7 +13,7 @@ class BoostTestConfiguration : public DebuggableTestConfiguration
|
||||
public:
|
||||
explicit BoostTestConfiguration(ITestFramework *framework)
|
||||
: DebuggableTestConfiguration(framework) {}
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
Utils::Environment filteredEnvironment(const Utils::Environment &original) const override;
|
||||
|
@@ -18,10 +18,7 @@ ITestParser *BoostTestFramework::createTestParser()
|
||||
|
||||
ITestTreeItem *BoostTestFramework::createRootNode()
|
||||
{
|
||||
return new BoostTestTreeItem(
|
||||
this,
|
||||
displayName(),
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
return new BoostTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *BoostTestFramework::name() const
|
||||
|
@@ -19,7 +19,7 @@ namespace Internal {
|
||||
|
||||
static Q_LOGGING_CATEGORY(orLog, "qtc.autotest.boost.outputreader", QtWarningMsg)
|
||||
|
||||
BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
BoostTestOutputReader::BoostTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile,
|
||||
@@ -42,23 +42,23 @@ static QString caseFromContent(const QString &content)
|
||||
if (index != 17 || length <= 18) {
|
||||
qCDebug(orLog) << "double quote position" << index << " or content length" << length
|
||||
<< "wrong on content" << content;
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
index = content.indexOf('"', 18);
|
||||
if (index == -1) {
|
||||
qCDebug(orLog) << "no closing double quote" << content;
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
return content.mid(18, index - 1);
|
||||
}
|
||||
|
||||
int index = content.indexOf(": in ");
|
||||
if (index == -1) // "info: check true has passed"
|
||||
return QString();
|
||||
return {};
|
||||
|
||||
if (index <= 4 || length < index + 4) {
|
||||
qCDebug(orLog) << "unexpected position" << index << "for info" << content;
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
QString result = content.mid(index + 5);
|
||||
@@ -66,7 +66,7 @@ static QString caseFromContent(const QString &content)
|
||||
const QRegularExpressionMatch matcher = functionName.match(result);
|
||||
if (!matcher.hasMatch()) {
|
||||
qCDebug(orLog) << "got no match";
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
return matcher.captured(1);
|
||||
}
|
||||
@@ -74,19 +74,18 @@ static QString caseFromContent(const QString &content)
|
||||
void BoostTestOutputReader::sendCompleteInformation()
|
||||
{
|
||||
QTC_ASSERT(m_result != ResultType::Invalid, return);
|
||||
BoostTestResult *result = new BoostTestResult(id(), m_currentModule, m_projectFile,
|
||||
m_currentTest, m_currentSuite);
|
||||
BoostTestResult result(id(), m_currentModule, m_projectFile, m_currentTest, m_currentSuite);
|
||||
if (m_lineNumber) {
|
||||
result->setLine(m_lineNumber);
|
||||
result->setFileName(m_fileName);
|
||||
} else if (const ITestTreeItem *it = result->findTestTreeItem()) {
|
||||
result->setLine(it->line());
|
||||
result->setFileName(it->filePath());
|
||||
result.setLine(m_lineNumber);
|
||||
result.setFileName(m_fileName);
|
||||
} else if (const ITestTreeItem *it = result.findTestTreeItem()) {
|
||||
result.setLine(it->line());
|
||||
result.setFileName(it->filePath());
|
||||
}
|
||||
|
||||
result->setDescription(m_description);
|
||||
result->setResult(m_result);
|
||||
reportResult(TestResultPtr(result));
|
||||
result.setDescription(m_description);
|
||||
result.setResult(m_result);
|
||||
reportResult(result);
|
||||
m_result = ResultType::Invalid;
|
||||
}
|
||||
|
||||
@@ -212,10 +211,10 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
if (match.hasMatch()) {
|
||||
if (m_result != ResultType::Invalid)
|
||||
sendCompleteInformation();
|
||||
BoostTestResult *result = new BoostTestResult(id(), m_currentModule, m_projectFile);
|
||||
result->setDescription(match.captured(0));
|
||||
result->setResult(ResultType::MessageInfo);
|
||||
reportResult(TestResultPtr(result));
|
||||
BoostTestResult result(id(), m_currentModule, m_projectFile);
|
||||
result.setDescription(match.captured(0));
|
||||
result.setResult(ResultType::MessageInfo);
|
||||
reportResult(result);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -234,17 +233,17 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
sendCompleteInformation();
|
||||
if (match.captured(1).startsWith("Entering")) {
|
||||
m_currentModule = match.captured(2);
|
||||
BoostTestResult *result = new BoostTestResult(id(), m_currentModule, m_projectFile);
|
||||
result->setDescription(Tr::tr("Executing test module %1").arg(m_currentModule));
|
||||
result->setResult(ResultType::TestStart);
|
||||
reportResult(TestResultPtr(result));
|
||||
BoostTestResult result(id(), m_currentModule, m_projectFile);
|
||||
result.setDescription(Tr::tr("Executing test module %1").arg(m_currentModule));
|
||||
result.setResult(ResultType::TestStart);
|
||||
reportResult(result);
|
||||
m_description.clear();
|
||||
} else {
|
||||
QTC_CHECK(m_currentModule == match.captured(3));
|
||||
BoostTestResult *result = new BoostTestResult(id(), m_currentModule, m_projectFile);
|
||||
result->setDescription(Tr::tr("Test module execution took %1").arg(match.captured(4)));
|
||||
result->setResult(ResultType::TestEnd);
|
||||
reportResult(TestResultPtr(result));
|
||||
BoostTestResult result(id(), m_currentModule, m_projectFile);
|
||||
result.setDescription(Tr::tr("Test module execution took %1").arg(match.captured(4)));
|
||||
result.setResult(ResultType::TestEnd);
|
||||
reportResult(result);
|
||||
|
||||
m_currentTest.clear();
|
||||
m_currentSuite.clear();
|
||||
@@ -325,16 +324,16 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
if (match.hasMatch()) {
|
||||
if (m_result != ResultType::Invalid)
|
||||
sendCompleteInformation();
|
||||
BoostTestResult *result = new BoostTestResult(id(), {}, m_projectFile);
|
||||
int failed = match.captured(1).toInt();
|
||||
int fatals = m_summary.value(ResultType::MessageFatal);
|
||||
BoostTestResult result(id(), {}, m_projectFile);
|
||||
const int failed = match.captured(1).toInt();
|
||||
const int fatals = m_summary.value(ResultType::MessageFatal);
|
||||
QString txt = Tr::tr("%1 failures detected in %2.").arg(failed).arg(match.captured(3));
|
||||
int passed = qMax(0, m_testCaseCount - failed);
|
||||
const int passed = qMax(0, m_testCaseCount - failed);
|
||||
if (m_testCaseCount != -1)
|
||||
txt.append(' ').append(Tr::tr("%1 tests passed.").arg(passed));
|
||||
result->setDescription(txt);
|
||||
result->setResult(ResultType::MessageInfo);
|
||||
reportResult(TestResultPtr(result));
|
||||
result.setDescription(txt);
|
||||
result.setResult(ResultType::MessageInfo);
|
||||
reportResult(result);
|
||||
if (m_reportLevel == ReportLevel::Confirm) { // for the final summary
|
||||
m_summary[ResultType::Pass] += passed;
|
||||
m_summary[ResultType::Fail] += failed - fatals;
|
||||
@@ -346,13 +345,13 @@ void BoostTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
if (line == noErrors) {
|
||||
if (m_result != ResultType::Invalid)
|
||||
sendCompleteInformation();
|
||||
BoostTestResult *result = new BoostTestResult(id(), {}, m_projectFile);
|
||||
BoostTestResult result(id(), {}, m_projectFile);
|
||||
QString txt = Tr::tr("No errors detected.");
|
||||
if (m_testCaseCount != -1)
|
||||
txt.append(' ').append(Tr::tr("%1 tests passed.").arg(m_testCaseCount));
|
||||
result->setDescription(txt);
|
||||
result->setResult(ResultType::MessageInfo);
|
||||
reportResult(TestResultPtr(result));
|
||||
result.setDescription(txt);
|
||||
result.setResult(ResultType::MessageInfo);
|
||||
reportResult(result);
|
||||
if (m_reportLevel == ReportLevel::Confirm) // for the final summary
|
||||
m_summary.insert(ResultType::Pass, m_testCaseCount);
|
||||
return;
|
||||
@@ -372,10 +371,9 @@ void BoostTestOutputReader::processStdError(const QByteArray &outputLine)
|
||||
emit newOutputLineAvailable(outputLine, OutputChannel::StdErr);
|
||||
}
|
||||
|
||||
TestResultPtr BoostTestOutputReader::createDefaultResult() const
|
||||
TestResult BoostTestOutputReader::createDefaultResult() const
|
||||
{
|
||||
return TestResultPtr(new BoostTestResult(id(), m_currentModule, m_projectFile,
|
||||
m_currentTest, m_currentSuite));
|
||||
return BoostTestResult(id(), m_currentModule, m_projectFile, m_currentTest, m_currentSuite);
|
||||
}
|
||||
|
||||
void BoostTestOutputReader::onDone() {
|
||||
@@ -416,11 +414,11 @@ void BoostTestOutputReader::onDone() {
|
||||
|
||||
void BoostTestOutputReader::reportNoOutputFinish(const QString &description, ResultType type)
|
||||
{
|
||||
BoostTestResult *result = new BoostTestResult(id(), m_currentModule, m_projectFile,
|
||||
Tr::tr("Running tests without output."));
|
||||
result->setDescription(description);
|
||||
result->setResult(type);
|
||||
reportResult(TestResultPtr(result));
|
||||
BoostTestResult result(id(), m_currentModule, m_projectFile,
|
||||
Tr::tr("Running tests without output."));
|
||||
result.setDescription(description);
|
||||
result.setResult(type);
|
||||
reportResult(result);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -15,13 +15,13 @@ class BoostTestOutputReader : public TestOutputReader
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BoostTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
BoostTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile, LogLevel log, ReportLevel report);
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLine) override;
|
||||
void processStdError(const QByteArray &outputLine) override;
|
||||
TestResultPtr createDefaultResult() const override;
|
||||
TestResult createDefaultResult() const override;
|
||||
|
||||
private:
|
||||
void onDone();
|
||||
|
@@ -120,7 +120,7 @@ QString BoostTestSettings::logLevelToOption(const LogLevel logLevel)
|
||||
case LogLevel::Nothing: return QString("nothing");
|
||||
case LogLevel::Warning: return QString("warning");
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
QString BoostTestSettings::reportLevelToOption(const ReportLevel reportLevel)
|
||||
@@ -131,7 +131,7 @@ QString BoostTestSettings::reportLevelToOption(const ReportLevel reportLevel)
|
||||
case ReportLevel::Detailed: return QString("detailed");
|
||||
case ReportLevel::No: return QString("no");
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -27,8 +27,8 @@ public:
|
||||
Q_DECLARE_FLAGS(TestStates, TestState)
|
||||
|
||||
explicit BoostTestTreeItem(ITestFramework *framework,
|
||||
const QString &name = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
const QString &name = {},
|
||||
const Utils::FilePath &filePath = {},
|
||||
Type type = Root)
|
||||
: TestTreeItem(framework, name, filePath, type)
|
||||
{}
|
||||
|
@@ -14,7 +14,7 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
TestOutputReader *CatchConfiguration::createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *CatchConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const
|
||||
{
|
||||
return new CatchOutputReader(fi, app, buildDirectory(), projectFile());
|
||||
|
@@ -12,7 +12,7 @@ class CatchConfiguration : public DebuggableTestConfiguration
|
||||
{
|
||||
public:
|
||||
CatchConfiguration(ITestFramework *framework) : DebuggableTestConfiguration(framework) {}
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
Utils::Environment filteredEnvironment(const Utils::Environment &original) const override;
|
||||
|
@@ -32,9 +32,7 @@ ITestParser *CatchFramework::createTestParser()
|
||||
|
||||
ITestTreeItem *CatchFramework::createRootNode()
|
||||
{
|
||||
return new CatchTreeItem(this,
|
||||
displayName(),
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
return new CatchTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -29,7 +29,7 @@ namespace CatchXml {
|
||||
const char TestCaseResultElement[] = "OverallResult";
|
||||
}
|
||||
|
||||
CatchOutputReader::CatchOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
CatchOutputReader::CatchOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile)
|
||||
@@ -169,22 +169,17 @@ void CatchOutputReader::processOutputLine(const QByteArray &outputLineWithNewLin
|
||||
}
|
||||
}
|
||||
|
||||
TestResultPtr CatchOutputReader::createDefaultResult() const
|
||||
TestResult CatchOutputReader::createDefaultResult() const
|
||||
{
|
||||
CatchResult *result = nullptr;
|
||||
if (m_testCaseInfo.size() > 0) {
|
||||
result = new CatchResult(id(), m_testCaseInfo.first().name, m_sectionDepth);
|
||||
result->setDescription(m_testCaseInfo.last().name);
|
||||
result->setLine(m_testCaseInfo.last().line);
|
||||
const QString givenPath = m_testCaseInfo.last().filename;
|
||||
if (!givenPath.isEmpty()) {
|
||||
result->setFileName(constructSourceFilePath(m_buildDir, givenPath));
|
||||
}
|
||||
} else {
|
||||
result = new CatchResult(id(), {}, m_sectionDepth);
|
||||
}
|
||||
|
||||
return TestResultPtr(result);
|
||||
if (m_testCaseInfo.size() == 0)
|
||||
return CatchResult(id(), {}, m_sectionDepth);
|
||||
CatchResult result = CatchResult(id(), m_testCaseInfo.first().name, m_sectionDepth);
|
||||
result.setDescription(m_testCaseInfo.last().name);
|
||||
result.setLine(m_testCaseInfo.last().line);
|
||||
const QString givenPath = m_testCaseInfo.last().filename;
|
||||
if (!givenPath.isEmpty())
|
||||
result.setFileName(constructSourceFilePath(m_buildDir, givenPath));
|
||||
return result;
|
||||
}
|
||||
|
||||
void CatchOutputReader::recordTestInformation(const QXmlStreamAttributes &attributes)
|
||||
@@ -242,37 +237,38 @@ void CatchOutputReader::recordBenchmarkDetails(
|
||||
|
||||
void CatchOutputReader::sendResult(const ResultType result)
|
||||
{
|
||||
TestResultPtr catchResult = createDefaultResult();
|
||||
catchResult->setResult(result);
|
||||
TestResult catchResult = createDefaultResult();
|
||||
catchResult.setResult(result);
|
||||
|
||||
if (result == ResultType::TestStart && m_testCaseInfo.size() > 0) {
|
||||
catchResult->setDescription(Tr::tr("Executing %1 \"%2\"").arg(testOutputNodeToString().toLower())
|
||||
.arg(catchResult->description()));
|
||||
catchResult.setDescription(Tr::tr("Executing %1 \"%2\"")
|
||||
.arg(testOutputNodeToString().toLower(), catchResult.description()));
|
||||
} else if (result == ResultType::Pass || result == ResultType::UnexpectedPass) {
|
||||
if (result == ResultType::UnexpectedPass)
|
||||
++m_xpassCount;
|
||||
|
||||
if (m_currentExpression.isEmpty()) {
|
||||
catchResult->setDescription(Tr::tr("%1 \"%2\" passed").arg(testOutputNodeToString())
|
||||
.arg(catchResult->description()));
|
||||
catchResult.setDescription(Tr::tr("%1 \"%2\" passed")
|
||||
.arg(testOutputNodeToString(), catchResult.description()));
|
||||
} else {
|
||||
catchResult->setDescription(Tr::tr("Expression passed")
|
||||
catchResult.setDescription(Tr::tr("Expression passed")
|
||||
.append('\n').append(m_currentExpression));
|
||||
}
|
||||
m_reportedSectionResult = true;
|
||||
m_reportedResult = true;
|
||||
} else if (result == ResultType::Fail || result == ResultType::ExpectedFail) {
|
||||
catchResult->setDescription(Tr::tr("Expression failed: %1").arg(m_currentExpression.trimmed()));
|
||||
catchResult.setDescription(Tr::tr("Expression failed: %1")
|
||||
.arg(m_currentExpression.trimmed()));
|
||||
if (!m_reportedSectionResult)
|
||||
m_reportedSectionResult = true;
|
||||
m_reportedResult = true;
|
||||
} else if (result == ResultType::TestEnd) {
|
||||
catchResult->setDescription(Tr::tr("Finished executing %1 \"%2\"").arg(testOutputNodeToString().toLower())
|
||||
.arg(catchResult->description()));
|
||||
catchResult.setDescription(Tr::tr("Finished executing %1 \"%2\"")
|
||||
.arg(testOutputNodeToString().toLower(), catchResult.description()));
|
||||
} else if (result == ResultType::Benchmark || result == ResultType::MessageFatal) {
|
||||
catchResult->setDescription(m_currentExpression);
|
||||
catchResult.setDescription(m_currentExpression);
|
||||
} else if (result == ResultType::MessageWarn || result == ResultType::MessageInfo) {
|
||||
catchResult->setDescription(m_currentExpression.trimmed());
|
||||
catchResult.setDescription(m_currentExpression.trimmed());
|
||||
}
|
||||
|
||||
reportResult(catchResult);
|
||||
@@ -319,8 +315,7 @@ QString CatchOutputReader::testOutputNodeToString() const
|
||||
case SectionNode:
|
||||
return QStringLiteral("Section");
|
||||
}
|
||||
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -14,13 +14,13 @@ namespace Internal {
|
||||
class CatchOutputReader : public TestOutputReader
|
||||
{
|
||||
public:
|
||||
CatchOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
CatchOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile);
|
||||
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLineWithNewLine) override;
|
||||
TestResultPtr createDefaultResult() const override;
|
||||
TestResult createDefaultResult() const override;
|
||||
|
||||
private:
|
||||
enum TestOutputNodeType {
|
||||
|
@@ -20,8 +20,8 @@ public:
|
||||
Q_FLAGS(TestState)
|
||||
Q_DECLARE_FLAGS(TestStates, TestState)
|
||||
|
||||
explicit CatchTreeItem(ITestFramework *testFramework, const QString &name = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root)
|
||||
explicit CatchTreeItem(ITestFramework *testFramework, const QString &name = {},
|
||||
const Utils::FilePath &filePath = {}, Type type = Root)
|
||||
: TestTreeItem(testFramework, name, filePath, type) {}
|
||||
|
||||
void setStates(CatchTreeItem::TestStates state) { m_state = state; }
|
||||
|
@@ -13,7 +13,7 @@ CTestConfiguration::CTestConfiguration(ITestBase *testBase)
|
||||
setDisplayName("CTest");
|
||||
}
|
||||
|
||||
TestOutputReader *CTestConfiguration::createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *CTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const
|
||||
{
|
||||
return new CTestOutputReader(fi, app, workingDirectory());
|
||||
|
@@ -13,7 +13,7 @@ class CTestConfiguration final : public Autotest::TestToolConfiguration
|
||||
public:
|
||||
explicit CTestConfiguration(ITestBase *testBase);
|
||||
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const final;
|
||||
};
|
||||
|
||||
|
@@ -52,7 +52,7 @@ public:
|
||||
{}
|
||||
};
|
||||
|
||||
CTestOutputReader::CTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
CTestOutputReader::CTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory)
|
||||
: TestOutputReader(futureInterface, testApplication, buildDirectory)
|
||||
@@ -91,9 +91,9 @@ void CTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
if (!m_testName.isEmpty()) // possible?
|
||||
sendCompleteInformation();
|
||||
m_project = match.captured(1);
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::TestStart);
|
||||
testResult->setDescription(Tr::tr("Running tests for %1").arg(m_project));
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(ResultType::TestStart);
|
||||
testResult.setDescription(Tr::tr("Running tests for %1").arg(m_project));
|
||||
reportResult(testResult);
|
||||
} else if (ExactMatch match = testCase1.match(line)) {
|
||||
int current = match.captured("current").toInt();
|
||||
@@ -125,9 +125,9 @@ void CTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
} else if (ExactMatch match = summary.match(line)) {
|
||||
if (!m_testName.isEmpty())
|
||||
sendCompleteInformation();
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageInfo);
|
||||
testResult->setDescription(match.captured());
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(ResultType::MessageInfo);
|
||||
testResult.setDescription(match.captured());
|
||||
reportResult(testResult);
|
||||
int failed = match.captured(1).toInt();
|
||||
int testCount = match.captured(2).toInt();
|
||||
@@ -136,9 +136,9 @@ void CTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
} else if (ExactMatch match = summaryTime.match(line)) {
|
||||
if (!m_testName.isEmpty()) // possible?
|
||||
sendCompleteInformation();
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::TestEnd);
|
||||
testResult->setDescription(match.captured());
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(ResultType::TestEnd);
|
||||
testResult.setDescription(match.captured());
|
||||
reportResult(testResult);
|
||||
} else if (ExactMatch match = testCrash.match(line)) {
|
||||
m_description = match.captured();
|
||||
@@ -156,9 +156,9 @@ void CTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
}
|
||||
}
|
||||
|
||||
TestResultPtr CTestOutputReader::createDefaultResult() const
|
||||
TestResult CTestOutputReader::createDefaultResult() const
|
||||
{
|
||||
return TestResultPtr(new CTestResult(id(), m_project, m_testName));
|
||||
return CTestResult(id(), m_project, m_testName);
|
||||
}
|
||||
|
||||
void CTestOutputReader::sendCompleteInformation()
|
||||
@@ -168,10 +168,9 @@ void CTestOutputReader::sendCompleteInformation()
|
||||
QTC_CHECK(m_currentTestNo == -1 && m_testName.isEmpty());
|
||||
return;
|
||||
}
|
||||
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(m_result);
|
||||
testResult->setDescription(m_description);
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(m_result);
|
||||
testResult.setDescription(m_description);
|
||||
reportResult(testResult);
|
||||
m_testName.clear();
|
||||
m_description.clear();
|
||||
|
@@ -13,12 +13,12 @@ namespace Internal {
|
||||
class CTestOutputReader final : public Autotest::TestOutputReader
|
||||
{
|
||||
public:
|
||||
CTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
CTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication, const Utils::FilePath &buildDirectory);
|
||||
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLineWithNewLine) final;
|
||||
TestResultPtr createDefaultResult() const final;
|
||||
TestResult createDefaultResult() const final;
|
||||
private:
|
||||
void sendCompleteInformation();
|
||||
int m_currentTestNo = -1;
|
||||
|
@@ -36,9 +36,7 @@ QString CTestTool::displayName() const
|
||||
|
||||
ITestTreeItem *CTestTool::createRootNode()
|
||||
{
|
||||
return new CTestTreeItem(this,
|
||||
displayName(),
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
return new CTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -15,7 +15,7 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
TestOutputReader *GTestConfiguration::createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *GTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const
|
||||
{
|
||||
return new GTestOutputReader(fi, app, buildDirectory(), projectFile());
|
||||
|
@@ -14,7 +14,7 @@ public:
|
||||
explicit GTestConfiguration(ITestFramework *framework)
|
||||
: DebuggableTestConfiguration(framework) {}
|
||||
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
Utils::Environment filteredEnvironment(const Utils::Environment &original) const override;
|
||||
|
@@ -25,10 +25,7 @@ ITestParser *GTestFramework::createTestParser()
|
||||
|
||||
ITestTreeItem *GTestFramework::createRootNode()
|
||||
{
|
||||
return new GTestTreeItem(
|
||||
this,
|
||||
displayName(),
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
return new GTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *GTestFramework::name() const
|
||||
|
@@ -15,7 +15,7 @@
|
||||
namespace Autotest {
|
||||
namespace Internal {
|
||||
|
||||
GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
GTestOutputReader::GTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile)
|
||||
@@ -70,9 +70,9 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
m_description = line;
|
||||
if (m_iteration > 1)
|
||||
m_description.append(' ' + Tr::tr("(iteration %1)").arg(m_iteration));
|
||||
TestResultPtr testResult = TestResultPtr(new GTestResult(id(), {}, m_projectFile));
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(m_description);
|
||||
GTestResult testResult(id(), {}, m_projectFile);
|
||||
testResult.setResult(ResultType::MessageInternal);
|
||||
testResult.setDescription(m_description);
|
||||
reportResult(testResult);
|
||||
m_description.clear();
|
||||
} else if (ExactMatch match = disabledTests.match(line)) {
|
||||
@@ -83,66 +83,66 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
}
|
||||
|
||||
if (ExactMatch match = testEnds.match(line)) {
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::TestEnd);
|
||||
testResult->setDescription(Tr::tr("Test execution took %1").arg(match.captured(2)));
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(ResultType::TestEnd);
|
||||
testResult.setDescription(Tr::tr("Test execution took %1").arg(match.captured(2)));
|
||||
reportResult(testResult);
|
||||
m_currentTestSuite.clear();
|
||||
m_currentTestCase.clear();
|
||||
} else if (ExactMatch match = newTestStarts.match(line)) {
|
||||
setCurrentTestSuite(match.captured(1));
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::TestStart);
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(ResultType::TestStart);
|
||||
if (m_iteration > 1) {
|
||||
testResult->setDescription(Tr::tr("Repeating test suite %1 (iteration %2)")
|
||||
testResult.setDescription(Tr::tr("Repeating test suite %1 (iteration %2)")
|
||||
.arg(m_currentTestSuite).arg(m_iteration));
|
||||
} else {
|
||||
testResult->setDescription(Tr::tr("Executing test suite %1").arg(m_currentTestSuite));
|
||||
testResult.setDescription(Tr::tr("Executing test suite %1").arg(m_currentTestSuite));
|
||||
}
|
||||
reportResult(testResult);
|
||||
} else if (ExactMatch match = newTestSetStarts.match(line)) {
|
||||
m_testSetStarted = true;
|
||||
setCurrentTestCase(match.captured(1));
|
||||
TestResultPtr testResult = TestResultPtr(new GTestResult({}, {}, m_projectFile));
|
||||
testResult->setResult(ResultType::MessageCurrentTest);
|
||||
testResult->setDescription(Tr::tr("Entering test case %1").arg(m_currentTestCase));
|
||||
GTestResult testResult("internal", {}, m_projectFile);
|
||||
testResult.setResult(ResultType::MessageCurrentTest);
|
||||
testResult.setDescription(Tr::tr("Entering test case %1").arg(m_currentTestCase));
|
||||
reportResult(testResult);
|
||||
m_description.clear();
|
||||
} else if (ExactMatch match = testSetSuccess.match(line)) {
|
||||
m_testSetStarted = false;
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::Pass);
|
||||
testResult->setDescription(m_description);
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(ResultType::Pass);
|
||||
testResult.setDescription(m_description);
|
||||
reportResult(testResult);
|
||||
m_description.clear();
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(Tr::tr("Execution took %1.").arg(match.captured(2)));
|
||||
testResult.setResult(ResultType::MessageInternal);
|
||||
testResult.setDescription(Tr::tr("Execution took %1.").arg(match.captured(2)));
|
||||
reportResult(testResult);
|
||||
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
|
||||
} else if (ExactMatch match = testSetFail.match(line)) {
|
||||
m_testSetStarted = false;
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::Fail);
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(ResultType::Fail);
|
||||
m_description.chop(1);
|
||||
handleDescriptionAndReportResult(testResult);
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(Tr::tr("Execution took %1.").arg(match.captured(2)));
|
||||
testResult.setResult(ResultType::MessageInternal);
|
||||
testResult.setDescription(Tr::tr("Execution took %1.").arg(match.captured(2)));
|
||||
reportResult(testResult);
|
||||
m_futureInterface.setProgressValue(m_futureInterface.progressValue() + 1);
|
||||
} else if (ExactMatch match = testSetSkipped.match(line)) {
|
||||
if (!m_testSetStarted) // ignore SKIPPED at summary
|
||||
return;
|
||||
m_testSetStarted = false;
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::Skip);
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(ResultType::Skip);
|
||||
m_description.chop(1);
|
||||
m_description.prepend(match.captured(1) + '\n');
|
||||
handleDescriptionAndReportResult(testResult);
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(Tr::tr("Execution took %1.").arg(match.captured(2)));
|
||||
testResult.setResult(ResultType::MessageInternal);
|
||||
testResult.setDescription(Tr::tr("Execution took %1.").arg(match.captured(2)));
|
||||
reportResult(testResult);
|
||||
} else if (ExactMatch match = logging.match(line)) {
|
||||
const QString severity = match.captured(1).trimmed();
|
||||
@@ -153,13 +153,13 @@ void GTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
case 'E': type = ResultType::MessageError; break; // ERROR
|
||||
case 'F': type = ResultType::MessageFatal; break; // FATAL
|
||||
}
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(type);
|
||||
testResult->setLine(match.captured(3).toInt());
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(type);
|
||||
testResult.setLine(match.captured(3).toInt());
|
||||
const Utils::FilePath file = constructSourceFilePath(m_buildDir, match.captured(2));
|
||||
if (file.exists())
|
||||
testResult->setFileName(file);
|
||||
testResult->setDescription(match.captured(4));
|
||||
testResult.setFileName(file);
|
||||
testResult.setDescription(match.captured(4));
|
||||
reportResult(testResult);
|
||||
} else if (ExactMatch match = testDeath.match(line)) {
|
||||
m_description.append(line);
|
||||
@@ -175,19 +175,15 @@ void GTestOutputReader::processStdError(const QByteArray &outputLine)
|
||||
emit newOutputLineAvailable(outputLine, OutputChannel::StdErr);
|
||||
}
|
||||
|
||||
TestResultPtr GTestOutputReader::createDefaultResult() const
|
||||
TestResult GTestOutputReader::createDefaultResult() const
|
||||
{
|
||||
GTestResult *result = new GTestResult(id(), m_currentTestSuite, m_projectFile,
|
||||
m_currentTestCase, m_iteration);
|
||||
|
||||
const ITestTreeItem *testItem = result->findTestTreeItem();
|
||||
|
||||
GTestResult result(id(), m_currentTestSuite, m_projectFile, m_currentTestCase, m_iteration);
|
||||
const ITestTreeItem *testItem = result.findTestTreeItem();
|
||||
if (testItem && testItem->line()) {
|
||||
result->setFileName(testItem->filePath());
|
||||
result->setLine(testItem->line());
|
||||
result.setFileName(testItem->filePath());
|
||||
result.setLine(testItem->line());
|
||||
}
|
||||
|
||||
return TestResultPtr(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
void GTestOutputReader::setCurrentTestCase(const QString &testCase)
|
||||
@@ -200,13 +196,13 @@ void GTestOutputReader::setCurrentTestSuite(const QString &testSuite)
|
||||
m_currentTestSuite = testSuite;
|
||||
}
|
||||
|
||||
void GTestOutputReader::handleDescriptionAndReportResult(TestResultPtr testResult)
|
||||
void GTestOutputReader::handleDescriptionAndReportResult(const TestResult &testResult)
|
||||
{
|
||||
static const QRegularExpression failureLocation("^(.*):(\\d+): Failure$");
|
||||
static const QRegularExpression skipOrErrorLocation("^(.*)\\((\\d+)\\): (Skipped|error:.*)$");
|
||||
|
||||
QStringList resultDescription;
|
||||
|
||||
TestResult result = testResult;
|
||||
for (const QString &output : m_description.split('\n')) {
|
||||
QRegularExpressionMatch innerMatch = failureLocation.match(output);
|
||||
if (!innerMatch.hasMatch()) {
|
||||
@@ -216,20 +212,20 @@ void GTestOutputReader::handleDescriptionAndReportResult(TestResultPtr testResul
|
||||
continue;
|
||||
}
|
||||
}
|
||||
testResult->setDescription(resultDescription.join('\n'));
|
||||
result.setDescription(resultDescription.join('\n'));
|
||||
reportResult(testResult);
|
||||
resultDescription.clear();
|
||||
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageLocation);
|
||||
testResult->setLine(innerMatch.captured(2).toInt());
|
||||
result = createDefaultResult();
|
||||
result.setResult(ResultType::MessageLocation);
|
||||
result.setLine(innerMatch.captured(2).toInt());
|
||||
const Utils::FilePath file = constructSourceFilePath(m_buildDir, innerMatch.captured(1));
|
||||
if (file.exists())
|
||||
testResult->setFileName(file);
|
||||
result.setFileName(file);
|
||||
resultDescription << output;
|
||||
}
|
||||
testResult->setDescription(resultDescription.join('\n'));
|
||||
reportResult(testResult);
|
||||
result.setDescription(resultDescription.join('\n'));
|
||||
reportResult(result);
|
||||
m_description.clear();
|
||||
}
|
||||
|
||||
|
@@ -11,18 +11,18 @@ namespace Internal {
|
||||
class GTestOutputReader : public TestOutputReader
|
||||
{
|
||||
public:
|
||||
GTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
GTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile);
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLine) override;
|
||||
void processStdError(const QByteArray &outputLine) override;
|
||||
TestResultPtr createDefaultResult() const override;
|
||||
TestResult createDefaultResult() const override;
|
||||
|
||||
private:
|
||||
void setCurrentTestCase(const QString &testCase);
|
||||
void setCurrentTestSuite(const QString &testSuite);
|
||||
void handleDescriptionAndReportResult(TestResultPtr testResult);
|
||||
void handleDescriptionAndReportResult(const TestResult &testResult);
|
||||
|
||||
Utils::FilePath m_projectFile;
|
||||
QString m_currentTestSuite;
|
||||
|
@@ -30,7 +30,7 @@ GTestSettings::GTestSettings()
|
||||
|
||||
registerAspect(&seed);
|
||||
seed.setSettingsKey("Seed");
|
||||
seed.setSpecialValueText(QString());
|
||||
seed.setSpecialValueText({});
|
||||
seed.setEnabled(false);
|
||||
seed.setLabelText(Tr::tr("Seed:"));
|
||||
seed.setToolTip(Tr::tr("A seed of 0 generates a seed based on the current timestamp."));
|
||||
|
@@ -24,10 +24,8 @@ public:
|
||||
Q_FLAGS(TestState)
|
||||
Q_DECLARE_FLAGS(TestStates, TestState)
|
||||
|
||||
explicit GTestTreeItem(ITestFramework *testFramework,
|
||||
const QString &name = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
Type type = Root)
|
||||
explicit GTestTreeItem(ITestFramework *testFramework, const QString &name = {},
|
||||
const Utils::FilePath &filePath = {}, Type type = Root)
|
||||
: TestTreeItem(testFramework, name, filePath, type), m_state(Enabled)
|
||||
{}
|
||||
|
||||
|
@@ -72,7 +72,7 @@ public:
|
||||
bool grouping() const { return m_grouping; }
|
||||
void setGrouping(bool group) { m_grouping = group; }
|
||||
// framework specific tool tip to be displayed on the general settings page
|
||||
virtual QString groupingToolTip() const { return QString(); }
|
||||
virtual QString groupingToolTip() const { return {}; }
|
||||
|
||||
ITestFramework *asFramework() final { return this; }
|
||||
|
||||
|
@@ -26,7 +26,7 @@ static QStringList quoteIfNeeded(const QStringList &testCases, bool debugMode)
|
||||
});
|
||||
}
|
||||
|
||||
TestOutputReader *QtTestConfiguration::createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *QtTestConfiguration::createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const
|
||||
{
|
||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||
|
@@ -13,7 +13,7 @@ class QtTestConfiguration : public DebuggableTestConfiguration
|
||||
public:
|
||||
explicit QtTestConfiguration(ITestFramework *framework)
|
||||
: DebuggableTestConfiguration(framework) {}
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
Utils::Environment filteredEnvironment(const Utils::Environment &original) const override;
|
||||
|
@@ -18,10 +18,7 @@ ITestParser *QtTestFramework::createTestParser()
|
||||
|
||||
ITestTreeItem *QtTestFramework::createRootNode()
|
||||
{
|
||||
return new QtTestTreeItem(
|
||||
this,
|
||||
displayName(),
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
return new QtTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *QtTestFramework::name() const
|
||||
|
@@ -103,7 +103,7 @@ static QString constructBenchmarkInformation(const QString &metric, double value
|
||||
.arg(iterations);
|
||||
}
|
||||
|
||||
QtTestOutputReader::QtTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QtTestOutputReader::QtTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile,
|
||||
@@ -130,11 +130,9 @@ void QtTestOutputReader::processOutputLine(const QByteArray &outputLine)
|
||||
}
|
||||
}
|
||||
|
||||
TestResultPtr QtTestOutputReader::createDefaultResult() const
|
||||
TestResult QtTestOutputReader::createDefaultResult() const
|
||||
{
|
||||
QtTestResult *result = new QtTestResult(id(), m_className, m_projectFile, m_testType,
|
||||
m_testCase, m_dataTag);
|
||||
return TestResultPtr(result);
|
||||
return QtTestResult(id(), m_className, m_projectFile, m_testType, m_testCase, m_dataTag);
|
||||
}
|
||||
|
||||
static QString trQtVersion(const QString &version)
|
||||
@@ -455,73 +453,75 @@ void QtTestOutputReader::processSummaryFinishOutput()
|
||||
|
||||
void QtTestOutputReader::sendCompleteInformation()
|
||||
{
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(m_result);
|
||||
TestResult testResult = createDefaultResult();
|
||||
testResult.setResult(m_result);
|
||||
|
||||
if (m_lineNumber) {
|
||||
testResult->setFileName(m_file);
|
||||
testResult->setLine(m_lineNumber);
|
||||
testResult.setFileName(m_file);
|
||||
testResult.setLine(m_lineNumber);
|
||||
} else {
|
||||
const ITestTreeItem *testItem = testResult->findTestTreeItem();
|
||||
const ITestTreeItem *testItem = testResult.findTestTreeItem();
|
||||
if (testItem && testItem->line()) {
|
||||
testResult->setFileName(testItem->filePath());
|
||||
testResult->setLine(testItem->line());
|
||||
testResult.setFileName(testItem->filePath());
|
||||
testResult.setLine(testItem->line());
|
||||
}
|
||||
}
|
||||
testResult->setDescription(m_description);
|
||||
testResult.setDescription(m_description);
|
||||
reportResult(testResult);
|
||||
}
|
||||
|
||||
void QtTestOutputReader::sendMessageCurrentTest()
|
||||
{
|
||||
QtTestResult *testResult = new QtTestResult({}, {}, m_projectFile, m_testType);
|
||||
testResult->setResult(ResultType::MessageCurrentTest);
|
||||
testResult->setDescription(Tr::tr("Entering test function %1::%2").arg(m_className, m_testCase));
|
||||
reportResult(TestResultPtr(testResult));
|
||||
QtTestResult result("internal", {}, m_projectFile, m_testType);
|
||||
result.setResult(ResultType::MessageCurrentTest);
|
||||
result.setDescription(Tr::tr("Entering test function %1::%2").arg(m_className, m_testCase));
|
||||
reportResult(result);
|
||||
}
|
||||
|
||||
void QtTestOutputReader::sendStartMessage(bool isFunction)
|
||||
{
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::TestStart);
|
||||
testResult->setDescription(isFunction ? Tr::tr("Executing test function %1").arg(m_testCase)
|
||||
: Tr::tr("Executing test case %1").arg(m_className));
|
||||
const ITestTreeItem *testItem = testResult->findTestTreeItem();
|
||||
TestResult result = createDefaultResult();
|
||||
result.setResult(ResultType::TestStart);
|
||||
result.setDescription(isFunction ? Tr::tr("Executing test function %1").arg(m_testCase)
|
||||
: Tr::tr("Executing test case %1").arg(m_className));
|
||||
const ITestTreeItem *testItem = result.findTestTreeItem();
|
||||
if (testItem && testItem->line()) {
|
||||
testResult->setFileName(testItem->filePath());
|
||||
testResult->setLine(testItem->line());
|
||||
result.setFileName(testItem->filePath());
|
||||
result.setLine(testItem->line());
|
||||
}
|
||||
reportResult(testResult);
|
||||
reportResult(result);
|
||||
}
|
||||
|
||||
void QtTestOutputReader::sendFinishMessage(bool isFunction)
|
||||
{
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::TestEnd);
|
||||
TestResult result = createDefaultResult();
|
||||
result.setResult(ResultType::TestEnd);
|
||||
if (!m_duration.isEmpty()) {
|
||||
testResult->setDescription(isFunction ? Tr::tr("Execution took %1 ms.").arg(m_duration)
|
||||
: Tr::tr("Test execution took %1 ms.").arg(m_duration));
|
||||
result.setDescription(isFunction ? Tr::tr("Execution took %1 ms.").arg(m_duration)
|
||||
: Tr::tr("Test execution took %1 ms.").arg(m_duration));
|
||||
} else {
|
||||
testResult->setDescription(isFunction ? Tr::tr("Test function finished.")
|
||||
: Tr::tr("Test finished."));
|
||||
result.setDescription(isFunction ? Tr::tr("Test function finished.")
|
||||
: Tr::tr("Test finished."));
|
||||
}
|
||||
reportResult(testResult);
|
||||
reportResult(result);
|
||||
}
|
||||
|
||||
void QtTestOutputReader::handleAndSendConfigMessage(const QRegularExpressionMatch &config)
|
||||
{
|
||||
TestResultPtr testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(trQtVersion(config.captured(3)));
|
||||
reportResult(testResult);
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(trQtBuild(config.captured(2)));
|
||||
reportResult(testResult);
|
||||
testResult = createDefaultResult();
|
||||
testResult->setResult(ResultType::MessageInternal);
|
||||
testResult->setDescription(trQtestVersion(config.captured(1)));
|
||||
reportResult(testResult);
|
||||
TestResult result = createDefaultResult();
|
||||
result.setResult(ResultType::MessageInternal);
|
||||
result.setDescription(trQtVersion(config.captured(3)));
|
||||
reportResult(result);
|
||||
|
||||
result = createDefaultResult();
|
||||
result.setResult(ResultType::MessageInternal);
|
||||
result.setDescription(trQtBuild(config.captured(2)));
|
||||
reportResult(result);
|
||||
|
||||
result = createDefaultResult();
|
||||
result.setResult(ResultType::MessageInternal);
|
||||
result.setDescription(trQtestVersion(config.captured(1)));
|
||||
reportResult(result);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
@@ -22,12 +22,12 @@ public:
|
||||
PlainText
|
||||
};
|
||||
|
||||
QtTestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
QtTestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication, const Utils::FilePath &buildDirectory,
|
||||
const Utils::FilePath &projectFile, OutputMode mode, TestType type);
|
||||
protected:
|
||||
void processOutputLine(const QByteArray &outputLine) override;
|
||||
TestResultPtr createDefaultResult() const override;
|
||||
TestResult createDefaultResult() const override;
|
||||
|
||||
private:
|
||||
void processXMLOutput(const QByteArray &outputLine);
|
||||
|
@@ -86,7 +86,7 @@ QString QtTestSettings::metricsTypeToOption(const MetricsType type)
|
||||
{
|
||||
switch (type) {
|
||||
case MetricsType::Walltime:
|
||||
return QString();
|
||||
return {};
|
||||
case MetricsType::TickCounter:
|
||||
return QString("-tickcounter");
|
||||
case MetricsType::EventCounter:
|
||||
@@ -96,7 +96,7 @@ QString QtTestSettings::metricsTypeToOption(const MetricsType type)
|
||||
case MetricsType::Perf:
|
||||
return QString("-perf");
|
||||
}
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
|
||||
QtTestSettingsPage::QtTestSettingsPage(QtTestSettings *settings, Id settingsId)
|
||||
|
@@ -11,8 +11,8 @@ namespace Internal {
|
||||
class QtTestTreeItem : public TestTreeItem
|
||||
{
|
||||
public:
|
||||
explicit QtTestTreeItem(ITestFramework *framework, const QString &name = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(), Type type = Root);
|
||||
explicit QtTestTreeItem(ITestFramework *framework, const QString &name = {},
|
||||
const Utils::FilePath &filePath = {}, Type type = Root);
|
||||
|
||||
TestTreeItem *copyWithoutChildren() override;
|
||||
QVariant data(int column, int role) const override;
|
||||
|
@@ -189,7 +189,7 @@ QString TestDataFunctionVisitor::extractNameFromAST(StringLiteralAST *ast, bool
|
||||
auto token = m_currentDoc->translationUnit()->tokenAt(ast->literal_token);
|
||||
if (!token.isStringLiteral()) {
|
||||
*ok = false;
|
||||
return QString();
|
||||
return {};
|
||||
}
|
||||
*ok = true;
|
||||
QString name = QString::fromUtf8(token.spell());
|
||||
|
@@ -22,7 +22,7 @@ QuickTestConfiguration::QuickTestConfiguration(ITestFramework *framework)
|
||||
}
|
||||
|
||||
TestOutputReader *QuickTestConfiguration::createOutputReader(
|
||||
const QFutureInterface<TestResultPtr> &fi, Utils::QtcProcess *app) const
|
||||
const QFutureInterface<TestResult> &fi, Utils::QtcProcess *app) const
|
||||
{
|
||||
auto qtSettings = static_cast<QtTestSettings *>(framework()->testSettings());
|
||||
const QtTestOutputReader::OutputMode mode = qtSettings && qtSettings->useXMLOutput.value()
|
||||
|
@@ -12,7 +12,7 @@ class QuickTestConfiguration : public DebuggableTestConfiguration
|
||||
{
|
||||
public:
|
||||
explicit QuickTestConfiguration(ITestFramework *framework);
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
TestOutputReader *createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const override;
|
||||
QStringList argumentsForTestRunner(QStringList *omitted = nullptr) const override;
|
||||
Utils::Environment filteredEnvironment(const Utils::Environment &original) const override;
|
||||
|
@@ -20,8 +20,7 @@ ITestParser *QuickTestFramework::createTestParser()
|
||||
|
||||
ITestTreeItem *QuickTestFramework::createRootNode()
|
||||
{
|
||||
return new QuickTestTreeItem(this, displayName(),
|
||||
Utils::FilePath(), ITestTreeItem::Root);
|
||||
return new QuickTestTreeItem(this, displayName(), {}, ITestTreeItem::Root);
|
||||
}
|
||||
|
||||
const char *QuickTestFramework::name() const
|
||||
|
@@ -121,7 +121,7 @@ QString QuickTestParser::quickTestName(const CPlusPlus::Document::Ptr &doc) cons
|
||||
// check for using quick_test_main() directly
|
||||
CPlusPlus::Document::Ptr document = m_cppSnapshot.preprocessedDocument(fileContent, filePath);
|
||||
if (document.isNull())
|
||||
return QString();
|
||||
return {};
|
||||
document->check();
|
||||
CPlusPlus::AST *ast = document->translationUnit()->ast();
|
||||
QuickTestAstVisitor astVisitor(document, m_cppSnapshot);
|
||||
@@ -202,7 +202,7 @@ QList<Document::Ptr> QuickTestParser::scanDirectoryForQuickTestQmlFiles(const Ut
|
||||
static bool checkQmlDocumentForQuickTestCode(QFutureInterface<TestParseResultPtr> &futureInterface,
|
||||
const Document::Ptr &qmlJSDoc,
|
||||
ITestFramework *framework,
|
||||
const Utils::FilePath &proFile = Utils::FilePath(),
|
||||
const Utils::FilePath &proFile = {},
|
||||
bool checkForDerivedTest = false)
|
||||
{
|
||||
if (qmlJSDoc.isNull())
|
||||
|
@@ -11,10 +11,8 @@ namespace Internal {
|
||||
class QuickTestTreeItem : public TestTreeItem
|
||||
{
|
||||
public:
|
||||
explicit QuickTestTreeItem(ITestFramework *testFramework,
|
||||
const QString &name = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
Type type = Root)
|
||||
explicit QuickTestTreeItem(ITestFramework *testFramework, const QString &name = {},
|
||||
const Utils::FilePath &filePath = {}, Type type = Root)
|
||||
: TestTreeItem(testFramework, name, filePath, type)
|
||||
{}
|
||||
|
||||
|
@@ -26,8 +26,6 @@ class TestOutputReader;
|
||||
class TestResult;
|
||||
enum class TestRunMode;
|
||||
|
||||
using TestResultPtr = QSharedPointer<TestResult>;
|
||||
|
||||
class ITestConfiguration
|
||||
{
|
||||
public:
|
||||
@@ -41,7 +39,7 @@ public:
|
||||
bool hasExecutable() const;
|
||||
Utils::FilePath executableFilePath() const;
|
||||
|
||||
virtual TestOutputReader *createOutputReader(const QFutureInterface<TestResultPtr> &fi,
|
||||
virtual TestOutputReader *createOutputReader(const QFutureInterface<TestResult> &fi,
|
||||
Utils::QtcProcess *app) const = 0;
|
||||
virtual Utils::Environment filteredEnvironment(const Utils::Environment &original) const;
|
||||
|
||||
|
@@ -25,7 +25,7 @@ Utils::FilePath TestOutputReader::constructSourceFilePath(const Utils::FilePath
|
||||
return filePath.isReadableFile() ? filePath : Utils::FilePath();
|
||||
}
|
||||
|
||||
TestOutputReader::TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
TestOutputReader::TestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication,
|
||||
const Utils::FilePath &buildDirectory)
|
||||
: m_futureInterface(futureInterface)
|
||||
@@ -53,7 +53,7 @@ TestOutputReader::TestOutputReader(const QFutureInterface<TestResultPtr> &future
|
||||
|
||||
TestOutputReader::~TestOutputReader()
|
||||
{
|
||||
if (m_sanitizerResult)
|
||||
if (m_sanitizerResult.isValid())
|
||||
sendAndResetSanitizerResult();
|
||||
}
|
||||
|
||||
@@ -71,17 +71,17 @@ void TestOutputReader::processStdError(const QByteArray &outputLine)
|
||||
|
||||
void TestOutputReader::reportCrash()
|
||||
{
|
||||
TestResultPtr result = createDefaultResult();
|
||||
result->setDescription(Tr::tr("Test executable crashed."));
|
||||
result->setResult(ResultType::MessageFatal);
|
||||
TestResult result = createDefaultResult();
|
||||
result.setDescription(Tr::tr("Test executable crashed."));
|
||||
result.setResult(ResultType::MessageFatal);
|
||||
m_futureInterface.reportResult(result);
|
||||
}
|
||||
|
||||
void TestOutputReader::createAndReportResult(const QString &message, ResultType type)
|
||||
{
|
||||
TestResultPtr result = createDefaultResult();
|
||||
result->setDescription(message);
|
||||
result->setResult(type);
|
||||
TestResult result = createDefaultResult();
|
||||
result.setDescription(message);
|
||||
result.setResult(type);
|
||||
reportResult(result);
|
||||
}
|
||||
|
||||
@@ -105,9 +105,9 @@ QString TestOutputReader::removeCommandlineColors(const QString &original)
|
||||
return result;
|
||||
}
|
||||
|
||||
void TestOutputReader::reportResult(const TestResultPtr &result)
|
||||
void TestOutputReader::reportResult(const TestResult &result)
|
||||
{
|
||||
if (m_sanitizerResult)
|
||||
if (m_sanitizerResult.isValid())
|
||||
sendAndResetSanitizerResult();
|
||||
m_futureInterface.reportResult(result);
|
||||
m_hadValidOutput = true;
|
||||
@@ -141,7 +141,7 @@ void TestOutputReader::checkForSanitizerOutput(const QByteArray &line)
|
||||
mode = SanitizerOutputMode::Ubsan;
|
||||
}
|
||||
if (mode != SanitizerOutputMode::None) {
|
||||
if (m_sanitizerResult) // we have a result that has not been reported yet
|
||||
if (m_sanitizerResult.isValid()) // we have a result that has not been reported yet
|
||||
sendAndResetSanitizerResult();
|
||||
|
||||
m_sanitizerOutputMode = mode;
|
||||
@@ -151,32 +151,32 @@ void TestOutputReader::checkForSanitizerOutput(const QByteArray &line)
|
||||
if (m_sanitizerOutputMode == SanitizerOutputMode::Ubsan) {
|
||||
const Utils::FilePath path = constructSourceFilePath(m_buildDir, match.captured(1));
|
||||
// path may be empty if not existing - so, provide at least what we have
|
||||
m_sanitizerResult->setFileName(
|
||||
m_sanitizerResult.setFileName(
|
||||
path.exists() ? path : Utils::FilePath::fromString(match.captured(1)));
|
||||
m_sanitizerResult->setLine(match.captured(2).toInt());
|
||||
m_sanitizerResult.setLine(match.captured(2).toInt());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TestOutputReader::sendAndResetSanitizerResult()
|
||||
{
|
||||
QTC_ASSERT(m_sanitizerResult, return);
|
||||
m_sanitizerResult->setDescription(m_sanitizerLines.join('\n'));
|
||||
m_sanitizerResult->setResult(m_sanitizerOutputMode == SanitizerOutputMode::Ubsan
|
||||
? ResultType::Fail : ResultType::MessageFatal);
|
||||
QTC_ASSERT(m_sanitizerResult.isValid(), return);
|
||||
m_sanitizerResult.setDescription(m_sanitizerLines.join('\n'));
|
||||
m_sanitizerResult.setResult(m_sanitizerOutputMode == SanitizerOutputMode::Ubsan
|
||||
? ResultType::Fail : ResultType::MessageFatal);
|
||||
|
||||
if (m_sanitizerResult->fileName().isEmpty()) {
|
||||
const ITestTreeItem *testItem = m_sanitizerResult->findTestTreeItem();
|
||||
if (m_sanitizerResult.fileName().isEmpty()) {
|
||||
const ITestTreeItem *testItem = m_sanitizerResult.findTestTreeItem();
|
||||
if (testItem && testItem->line()) {
|
||||
m_sanitizerResult->setFileName(testItem->filePath());
|
||||
m_sanitizerResult->setLine(testItem->line());
|
||||
m_sanitizerResult.setFileName(testItem->filePath());
|
||||
m_sanitizerResult.setLine(testItem->line());
|
||||
}
|
||||
}
|
||||
|
||||
m_futureInterface.reportResult(m_sanitizerResult);
|
||||
m_hadValidOutput = true;
|
||||
m_sanitizerLines.clear();
|
||||
m_sanitizerResult.reset();
|
||||
m_sanitizerResult = {};
|
||||
m_sanitizerOutputMode = SanitizerOutputMode::None;
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class TestOutputReader : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
TestOutputReader(const QFutureInterface<TestResultPtr> &futureInterface,
|
||||
TestOutputReader(const QFutureInterface<TestResult> &futureInterface,
|
||||
Utils::QtcProcess *testApplication, const Utils::FilePath &buildDirectory);
|
||||
virtual ~TestOutputReader();
|
||||
void processStdOutput(const QByteArray &outputLine);
|
||||
@@ -40,12 +40,12 @@ protected:
|
||||
|
||||
QString removeCommandlineColors(const QString &original);
|
||||
virtual void processOutputLine(const QByteArray &outputLine) = 0;
|
||||
virtual TestResultPtr createDefaultResult() const = 0;
|
||||
virtual TestResult createDefaultResult() const = 0;
|
||||
void checkForSanitizerOutput(const QByteArray &line);
|
||||
void sendAndResetSanitizerResult();
|
||||
|
||||
void reportResult(const TestResultPtr &result);
|
||||
QFutureInterface<TestResultPtr> m_futureInterface;
|
||||
void reportResult(const TestResult &result);
|
||||
QFutureInterface<TestResult> m_futureInterface;
|
||||
Utils::QtcProcess *m_testApplication; // not owned
|
||||
Utils::FilePath m_buildDir;
|
||||
QString m_id;
|
||||
@@ -53,7 +53,7 @@ protected:
|
||||
int m_disabled = -1;
|
||||
private:
|
||||
enum class SanitizerOutputMode { None, Asan, Ubsan};
|
||||
TestResultPtr m_sanitizerResult;
|
||||
TestResult m_sanitizerResult;
|
||||
QStringList m_sanitizerLines;
|
||||
SanitizerOutputMode m_sanitizerOutputMode = SanitizerOutputMode::None;
|
||||
bool m_hadValidOutput = false;
|
||||
|
@@ -15,6 +15,11 @@ TestResult::TestResult(const QString &id, const QString &name, const ResultHooks
|
||||
{
|
||||
}
|
||||
|
||||
bool TestResult::isValid() const
|
||||
{
|
||||
return !m_id.isEmpty();
|
||||
}
|
||||
|
||||
const QString TestResult::outputString(bool selected) const
|
||||
{
|
||||
if (m_hooks.outputString)
|
||||
@@ -113,10 +118,10 @@ QString TestResult::resultToString(const ResultType type)
|
||||
return QString("BXFAIL");
|
||||
case ResultType::MessageLocation:
|
||||
case ResultType::Application:
|
||||
return QString();
|
||||
return {};
|
||||
default:
|
||||
if (type >= ResultType::INTERNAL_MESSAGES_BEGIN && type <= ResultType::INTERNAL_MESSAGES_END)
|
||||
return QString();
|
||||
return {};
|
||||
return QString("UNKNOWN");
|
||||
}
|
||||
}
|
||||
@@ -156,34 +161,30 @@ QColor TestResult::colorForType(const ResultType type)
|
||||
}
|
||||
}
|
||||
|
||||
bool TestResult::isDirectParentOf(const TestResult *other, bool *needsIntermediate) const
|
||||
bool TestResult::isDirectParentOf(const TestResult &other, bool *needsIntermediate) const
|
||||
{
|
||||
QTC_ASSERT(other, return false);
|
||||
const bool ret = !m_id.isEmpty() && m_id == other->m_id && m_name == other->m_name;
|
||||
QTC_ASSERT(other.isValid(), return false);
|
||||
const bool ret = !m_id.isEmpty() && m_id == other.m_id && m_name == other.m_name;
|
||||
if (!ret)
|
||||
return false;
|
||||
if (m_hooks.directParent)
|
||||
return m_hooks.directParent(*this, *other, needsIntermediate);
|
||||
return m_hooks.directParent(*this, other, needsIntermediate);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TestResult::isIntermediateFor(const TestResult *other) const
|
||||
bool TestResult::isIntermediateFor(const TestResult &other) const
|
||||
{
|
||||
QTC_ASSERT(other, return false);
|
||||
QTC_ASSERT(other.isValid(), return false);
|
||||
if (m_hooks.intermediate)
|
||||
return m_hooks.intermediate(*this, *other);
|
||||
return !m_id.isEmpty() && m_id == other->m_id && m_name == other->m_name;
|
||||
return m_hooks.intermediate(*this, other);
|
||||
return !m_id.isEmpty() && m_id == other.m_id && m_name == other.m_name;
|
||||
}
|
||||
|
||||
TestResult *TestResult::createIntermediateResult() const
|
||||
TestResult TestResult::intermediateResult() const
|
||||
{
|
||||
if (m_hooks.createResult) {
|
||||
TestResult *newResult = new TestResult;
|
||||
*newResult = m_hooks.createResult(*this);
|
||||
return newResult;
|
||||
}
|
||||
TestResult *intermediate = new TestResult(m_id, m_name);
|
||||
return intermediate;
|
||||
if (m_hooks.createResult)
|
||||
return m_hooks.createResult(*this);
|
||||
return {m_id, m_name};
|
||||
}
|
||||
|
||||
} // namespace Autotest
|
||||
|
@@ -5,12 +5,9 @@
|
||||
|
||||
#include "autotestconstants.h"
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QColor>
|
||||
#include <QMetaType>
|
||||
#include <QSharedPointer>
|
||||
#include <QString>
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
@@ -82,6 +79,7 @@ public:
|
||||
TestResult(const QString &id, const QString &name, const ResultHooks &hooks = {});
|
||||
virtual ~TestResult() {}
|
||||
|
||||
bool isValid() const;
|
||||
const QString outputString(bool selected) const;
|
||||
const ITestTreeItem *findTestTreeItem() const;
|
||||
|
||||
@@ -103,9 +101,9 @@ public:
|
||||
static QString resultToString(const ResultType type);
|
||||
static QColor colorForType(const ResultType type);
|
||||
|
||||
bool isDirectParentOf(const TestResult *other, bool *needsIntermediate) const;
|
||||
bool isIntermediateFor(const TestResult *other) const;
|
||||
TestResult *createIntermediateResult() const;
|
||||
bool isDirectParentOf(const TestResult &other, bool *needsIntermediate) const;
|
||||
bool isIntermediateFor(const TestResult &other) const;
|
||||
TestResult intermediateResult() const;
|
||||
|
||||
private:
|
||||
QString m_id;
|
||||
@@ -117,8 +115,6 @@ private:
|
||||
ResultHooks m_hooks;
|
||||
};
|
||||
|
||||
using TestResultPtr = QSharedPointer<TestResult>;
|
||||
|
||||
} // namespace Autotest
|
||||
|
||||
Q_DECLARE_METATYPE(Autotest::TestResult)
|
||||
|
@@ -50,9 +50,9 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
painter->fillRect(opt.rect, background);
|
||||
painter->setPen(foreground);
|
||||
|
||||
LayoutPositions positions(opt, resultFilterModel);
|
||||
const TestResult *testResult = resultFilterModel->testResult(index);
|
||||
QTC_ASSERT(testResult, painter->restore();return);
|
||||
const LayoutPositions positions(opt, resultFilterModel);
|
||||
const TestResult testResult = resultFilterModel->testResult(index);
|
||||
QTC_ASSERT(testResult.isValid(), painter->restore(); return);
|
||||
|
||||
const QWidget *widget = dynamic_cast<const QWidget*>(painter->device());
|
||||
QWindow *window = widget ? widget->window()->windowHandle() : nullptr;
|
||||
@@ -69,15 +69,15 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
painter->drawText(positions.typeAreaLeft(), positions.top() + fm.ascent(), typeStr);
|
||||
} else {
|
||||
QPen tmp = painter->pen();
|
||||
if (testResult->result() == ResultType::TestStart)
|
||||
if (testResult.result() == ResultType::TestStart)
|
||||
painter->setPen(opt.palette.mid().color());
|
||||
else
|
||||
painter->setPen(TestResult::colorForType(testResult->result()));
|
||||
painter->setPen(TestResult::colorForType(testResult.result()));
|
||||
painter->drawText(positions.typeAreaLeft(), positions.top() + fm.ascent(), typeStr);
|
||||
painter->setPen(tmp);
|
||||
}
|
||||
|
||||
QString output = testResult->outputString(selected);
|
||||
QString output = testResult.outputString(selected);
|
||||
|
||||
if (selected) {
|
||||
limitTextOutput(output);
|
||||
@@ -92,12 +92,12 @@ void TestResultDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||
fm.elidedText(output.left(2000), Qt::ElideRight, positions.textAreaWidth()));
|
||||
}
|
||||
|
||||
const QString file = testResult->fileName().fileName();
|
||||
const QString file = testResult.fileName().fileName();
|
||||
painter->setClipRect(positions.fileArea());
|
||||
painter->drawText(positions.fileAreaLeft(), positions.top() + fm.ascent(), file);
|
||||
|
||||
if (testResult->line()) {
|
||||
QString line = QString::number(testResult->line());
|
||||
if (testResult.line()) {
|
||||
QString line = QString::number(testResult.line());
|
||||
painter->setClipRect(positions.lineArea());
|
||||
painter->drawText(positions.lineAreaLeft(), positions.top() + fm.ascent(), line);
|
||||
}
|
||||
@@ -129,9 +129,9 @@ QSize TestResultDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
|
||||
s.setWidth(opt.rect.width() - indentation);
|
||||
|
||||
if (selected) {
|
||||
const TestResult *testResult = resultFilterModel->testResult(index);
|
||||
QTC_ASSERT(testResult, return QSize());
|
||||
QString output = testResult->outputString(selected);
|
||||
const TestResult testResult = resultFilterModel->testResult(index);
|
||||
QTC_ASSERT(testResult.isValid(), return {});
|
||||
QString output = testResult.outputString(selected);
|
||||
limitTextOutput(output);
|
||||
output.replace('\n', QChar::LineSeparator);
|
||||
recalculateTextLayout(index, output, opt.font, positions.textAreaWidth() - indentation);
|
||||
|
@@ -21,7 +21,7 @@ namespace Internal {
|
||||
|
||||
/********************************* TestResultItem ******************************************/
|
||||
|
||||
TestResultItem::TestResultItem(const TestResultPtr &testResult)
|
||||
TestResultItem::TestResultItem(const TestResult &testResult)
|
||||
: m_testResult(testResult)
|
||||
{
|
||||
}
|
||||
@@ -71,9 +71,9 @@ QVariant TestResultItem::data(int column, int role) const
|
||||
{
|
||||
switch (role) {
|
||||
case Qt::DecorationRole: {
|
||||
if (!m_testResult)
|
||||
return QVariant();
|
||||
const ResultType result = m_testResult->result();
|
||||
if (!m_testResult.isValid())
|
||||
return {};
|
||||
const ResultType result = m_testResult.result();
|
||||
if (result == ResultType::MessageLocation && parent())
|
||||
return parent()->data(column, role);
|
||||
if (result == ResultType::TestStart)
|
||||
@@ -81,7 +81,7 @@ QVariant TestResultItem::data(int column, int role) const
|
||||
return testResultIcon(result);
|
||||
}
|
||||
case Qt::DisplayRole:
|
||||
return m_testResult ? m_testResult->outputString(true) : QVariant();
|
||||
return m_testResult.isValid() ? m_testResult.outputString(true) : QVariant();
|
||||
default:
|
||||
return Utils::TreeItem::data(column, role);
|
||||
}
|
||||
@@ -89,9 +89,8 @@ QVariant TestResultItem::data(int column, int role) const
|
||||
|
||||
void TestResultItem::updateDescription(const QString &description)
|
||||
{
|
||||
QTC_ASSERT(m_testResult, return);
|
||||
|
||||
m_testResult->setDescription(description);
|
||||
QTC_ASSERT(m_testResult.isValid(), return);
|
||||
m_testResult.setDescription(description);
|
||||
}
|
||||
|
||||
static bool isSignificant(ResultType type)
|
||||
@@ -117,7 +116,7 @@ void TestResultItem::updateResult(bool &changed, ResultType addedChildType,
|
||||
const std::optional<SummaryEvaluation> &summary)
|
||||
{
|
||||
changed = false;
|
||||
if (m_testResult->result() != ResultType::TestStart)
|
||||
if (m_testResult.result() != ResultType::TestStart)
|
||||
return;
|
||||
|
||||
if (!isSignificant(addedChildType) || (addedChildType == ResultType::TestStart && !summary))
|
||||
@@ -165,13 +164,13 @@ void TestResultItem::updateResult(bool &changed, ResultType addedChildType,
|
||||
TestResultItem *TestResultItem::intermediateFor(const TestResultItem *item) const
|
||||
{
|
||||
QTC_ASSERT(item, return nullptr);
|
||||
const TestResult *otherResult = item->testResult();
|
||||
const TestResult otherResult = item->testResult();
|
||||
for (int row = childCount() - 1; row >= 0; --row) {
|
||||
TestResultItem *child = childAt(row);
|
||||
const TestResult *testResult = child->testResult();
|
||||
if (testResult->result() != ResultType::TestStart)
|
||||
const TestResult testResult = child->testResult();
|
||||
if (testResult.result() != ResultType::TestStart)
|
||||
continue;
|
||||
if (testResult->isIntermediateFor(otherResult))
|
||||
if (testResult.isIntermediateFor(otherResult))
|
||||
return child;
|
||||
}
|
||||
return nullptr;
|
||||
@@ -179,9 +178,9 @@ TestResultItem *TestResultItem::intermediateFor(const TestResultItem *item) cons
|
||||
|
||||
TestResultItem *TestResultItem::createAndAddIntermediateFor(const TestResultItem *child)
|
||||
{
|
||||
TestResultPtr result(child->testResult()->createIntermediateResult());
|
||||
QTC_ASSERT(!result.isNull(), return nullptr);
|
||||
result->setResult(ResultType::TestStart);
|
||||
TestResult result = child->testResult().intermediateResult();
|
||||
QTC_ASSERT(result.isValid(), return nullptr);
|
||||
result.setResult(ResultType::TestStart);
|
||||
TestResultItem *intermediate = new TestResultItem(result);
|
||||
appendChild(intermediate);
|
||||
return intermediate;
|
||||
@@ -189,17 +188,17 @@ TestResultItem *TestResultItem::createAndAddIntermediateFor(const TestResultItem
|
||||
|
||||
QString TestResultItem::resultString() const
|
||||
{
|
||||
if (testResult()->result() != ResultType::TestStart)
|
||||
return TestResult::resultToString(testResult()->result());
|
||||
if (testResult().result() != ResultType::TestStart)
|
||||
return TestResult::resultToString(testResult().result());
|
||||
if (!m_summaryResult)
|
||||
return QString();
|
||||
return {};
|
||||
return m_summaryResult->failed ? QString("FAIL") : QString("PASS");
|
||||
}
|
||||
|
||||
/********************************* TestResultModel *****************************************/
|
||||
|
||||
TestResultModel::TestResultModel(QObject *parent)
|
||||
: Utils::TreeModel<TestResultItem>(new TestResultItem(TestResultPtr()), parent)
|
||||
: Utils::TreeModel<TestResultItem>(new TestResultItem({}), parent)
|
||||
{
|
||||
connect(TestRunner::instance(), &TestRunner::reportSummary,
|
||||
this, [this](const QString &id, const QHash<ResultType, int> &summary){
|
||||
@@ -210,12 +209,12 @@ TestResultModel::TestResultModel(QObject *parent)
|
||||
void TestResultModel::updateParent(const TestResultItem *item)
|
||||
{
|
||||
QTC_ASSERT(item, return);
|
||||
QTC_ASSERT(item->testResult(), return);
|
||||
QTC_ASSERT(item->testResult().isValid(), return);
|
||||
TestResultItem *parentItem = item->parent();
|
||||
if (parentItem == rootItem()) // do not update invisible root item
|
||||
return;
|
||||
bool changed = false;
|
||||
parentItem->updateResult(changed, item->testResult()->result(), item->summaryResult());
|
||||
parentItem->updateResult(changed, item->testResult().result(), item->summaryResult());
|
||||
if (!changed)
|
||||
return;
|
||||
emit dataChanged(parentItem->index(), parentItem->index());
|
||||
@@ -232,16 +231,16 @@ static bool isFailed(ResultType type)
|
||||
}
|
||||
}
|
||||
|
||||
void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoExpand)
|
||||
void TestResultModel::addTestResult(const TestResult &testResult, bool autoExpand)
|
||||
{
|
||||
const int lastRow = rootItem()->childCount() - 1;
|
||||
if (testResult->result() == ResultType::MessageCurrentTest) {
|
||||
if (testResult.result() == ResultType::MessageCurrentTest) {
|
||||
// MessageCurrentTest should always be the last top level item
|
||||
if (lastRow >= 0) {
|
||||
TestResultItem *current = rootItem()->childAt(lastRow);
|
||||
const TestResult *result = current->testResult();
|
||||
if (result && result->result() == ResultType::MessageCurrentTest) {
|
||||
current->updateDescription(testResult->description());
|
||||
const TestResult result = current->testResult();
|
||||
if (result.isValid() && result.result() == ResultType::MessageCurrentTest) {
|
||||
current->updateDescription(testResult.description());
|
||||
emit dataChanged(current->index(), current->index());
|
||||
return;
|
||||
}
|
||||
@@ -251,22 +250,22 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
|
||||
return;
|
||||
}
|
||||
|
||||
m_testResultCount[testResult->id()][testResult->result()]++;
|
||||
m_testResultCount[testResult.id()][testResult.result()]++;
|
||||
|
||||
TestResultItem *newItem = new TestResultItem(testResult);
|
||||
TestResultItem *root = nullptr;
|
||||
if (AutotestPlugin::settings()->displayApplication) {
|
||||
const QString application = testResult->id();
|
||||
const QString application = testResult.id();
|
||||
if (!application.isEmpty()) {
|
||||
root = rootItem()->findFirstLevelChild([&application](TestResultItem *child) {
|
||||
QTC_ASSERT(child, return false);
|
||||
return child->testResult()->id() == application;
|
||||
return child->testResult().id() == application;
|
||||
});
|
||||
|
||||
if (!root) {
|
||||
TestResult *tmpAppResult = new TestResult(application, application);
|
||||
tmpAppResult->setResult(ResultType::Application);
|
||||
root = new TestResultItem(TestResultPtr(tmpAppResult));
|
||||
TestResult tmpAppResult(application, application);
|
||||
tmpAppResult.setResult(ResultType::Application);
|
||||
root = new TestResultItem(tmpAppResult);
|
||||
if (lastRow >= 0)
|
||||
rootItem()->insertChild(lastRow, root);
|
||||
else
|
||||
@@ -276,7 +275,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
|
||||
}
|
||||
|
||||
TestResultItem *parentItem = findParentItemFor(newItem, root);
|
||||
addFileName(testResult->fileName().fileName()); // ensure we calculate the results pane correctly
|
||||
addFileName(testResult.fileName().fileName()); // ensure we calculate the results pane correctly
|
||||
if (parentItem) {
|
||||
parentItem->appendChild(newItem);
|
||||
if (autoExpand) {
|
||||
@@ -288,8 +287,8 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
|
||||
} else {
|
||||
if (lastRow >= 0) {
|
||||
TestResultItem *current = rootItem()->childAt(lastRow);
|
||||
const TestResult *result = current->testResult();
|
||||
if (result && result->result() == ResultType::MessageCurrentTest) {
|
||||
const TestResult result = current->testResult();
|
||||
if (result.isValid() && result.result() == ResultType::MessageCurrentTest) {
|
||||
rootItem()->insertChild(current->index().row(), newItem);
|
||||
return;
|
||||
}
|
||||
@@ -298,8 +297,8 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
|
||||
rootItem()->appendChild(newItem);
|
||||
}
|
||||
|
||||
if (isFailed(testResult->result())) {
|
||||
if (const ITestTreeItem *it = testResult->findTestTreeItem()) {
|
||||
if (isFailed(testResult.result())) {
|
||||
if (const ITestTreeItem *it = testResult.findTestTreeItem()) {
|
||||
TestTreeModel *model = TestTreeModel::instance();
|
||||
model->setData(model->indexForItem(it), true, FailedRole);
|
||||
}
|
||||
@@ -309,7 +308,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
|
||||
void TestResultModel::removeCurrentTestMessage()
|
||||
{
|
||||
TestResultItem *currentMessageItem = rootItem()->findFirstLevelChild([](TestResultItem *it) {
|
||||
return (it->testResult()->result() == ResultType::MessageCurrentTest);
|
||||
return (it->testResult().result() == ResultType::MessageCurrentTest);
|
||||
});
|
||||
if (currentMessageItem)
|
||||
destroyItem(currentMessageItem);
|
||||
@@ -326,12 +325,11 @@ void TestResultModel::clearTestResults()
|
||||
m_widthOfLineNumber = 0;
|
||||
}
|
||||
|
||||
const TestResult *TestResultModel::testResult(const QModelIndex &idx)
|
||||
TestResult TestResultModel::testResult(const QModelIndex &idx)
|
||||
{
|
||||
if (idx.isValid())
|
||||
return itemForIndex(idx)->testResult();
|
||||
|
||||
return nullptr;
|
||||
return {};
|
||||
}
|
||||
|
||||
void TestResultModel::recalculateMaxWidthOfFileName(const QFont &font)
|
||||
@@ -383,15 +381,15 @@ TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
|
||||
{
|
||||
QTC_ASSERT(item, return nullptr);
|
||||
TestResultItem *root = startItem ? const_cast<TestResultItem *>(startItem) : nullptr;
|
||||
const TestResult *result = item->testResult();
|
||||
const QString &name = result->name();
|
||||
const QString &id = result->id();
|
||||
const TestResult result = item->testResult();
|
||||
const QString &name = result.name();
|
||||
const QString &id = result.id();
|
||||
|
||||
if (root == nullptr && !name.isEmpty()) {
|
||||
for (int row = rootItem()->childCount() - 1; row >= 0; --row) {
|
||||
TestResultItem *tmp = rootItem()->childAt(row);
|
||||
auto tmpTestResult = tmp->testResult();
|
||||
if (tmpTestResult->id() == id && tmpTestResult->name() == name) {
|
||||
const TestResult tmpTestResult = tmp->testResult();
|
||||
if (tmpTestResult.id() == id && tmpTestResult.name() == name) {
|
||||
root = tmp;
|
||||
break;
|
||||
}
|
||||
@@ -403,7 +401,7 @@ TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
|
||||
bool needsIntermediate = false;
|
||||
auto predicate = [result, &needsIntermediate](Utils::TreeItem *it) {
|
||||
TestResultItem *currentItem = static_cast<TestResultItem *>(it);
|
||||
return currentItem->testResult()->isDirectParentOf(result, &needsIntermediate);
|
||||
return currentItem->testResult().isDirectParentOf(result, &needsIntermediate);
|
||||
};
|
||||
TestResultItem *parent = root->reverseFindAnyChild(predicate);
|
||||
if (parent) {
|
||||
@@ -480,7 +478,7 @@ bool TestResultFilterModel::hasResults()
|
||||
return rowCount(QModelIndex());
|
||||
}
|
||||
|
||||
const TestResult *TestResultFilterModel::testResult(const QModelIndex &index) const
|
||||
TestResult TestResultFilterModel::testResult(const QModelIndex &index) const
|
||||
{
|
||||
return m_sourceModel->testResult(mapToSource(index));
|
||||
}
|
||||
@@ -495,7 +493,7 @@ bool TestResultFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &s
|
||||
QModelIndex index = m_sourceModel->index(sourceRow, 0, sourceParent);
|
||||
if (!index.isValid())
|
||||
return false;
|
||||
ResultType resultType = m_sourceModel->testResult(index)->result();
|
||||
const ResultType resultType = m_sourceModel->testResult(index).result();
|
||||
if (resultType == ResultType::TestStart) {
|
||||
TestResultItem *item = m_sourceModel->itemForIndex(index);
|
||||
QTC_ASSERT(item, return false);
|
||||
@@ -511,7 +509,7 @@ bool TestResultFilterModel::acceptTestCaseResult(const QModelIndex &srcIndex) co
|
||||
for (int row = 0, count = m_sourceModel->rowCount(srcIndex); row < count; ++row) {
|
||||
const QModelIndex &child = m_sourceModel->index(row, 0, srcIndex);
|
||||
TestResultItem *item = m_sourceModel->itemForIndex(child);
|
||||
ResultType type = item->testResult()->result();
|
||||
const ResultType type = item->testResult().result();
|
||||
|
||||
if (type == ResultType::TestStart) {
|
||||
if (!item->summaryResult())
|
||||
|
@@ -20,9 +20,9 @@ namespace Internal {
|
||||
class TestResultItem : public Utils::TypedTreeItem<TestResultItem, TestResultItem>
|
||||
{
|
||||
public:
|
||||
explicit TestResultItem(const TestResultPtr &testResult);
|
||||
explicit TestResultItem(const TestResult &testResult);
|
||||
QVariant data(int column, int role) const override;
|
||||
const TestResult *testResult() const { return m_testResult.data(); }
|
||||
TestResult testResult() const { return m_testResult; }
|
||||
void updateDescription(const QString &description);
|
||||
|
||||
struct SummaryEvaluation
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
std::optional<SummaryEvaluation> summaryResult() const { return m_summaryResult; }
|
||||
|
||||
private:
|
||||
TestResultPtr m_testResult;
|
||||
TestResult m_testResult;
|
||||
std::optional<SummaryEvaluation> m_summaryResult;
|
||||
};
|
||||
|
||||
@@ -54,11 +54,11 @@ class TestResultModel : public Utils::TreeModel<TestResultItem>
|
||||
public:
|
||||
explicit TestResultModel(QObject *parent = nullptr);
|
||||
|
||||
void addTestResult(const TestResultPtr &testResult, bool autoExpand = false);
|
||||
void addTestResult(const TestResult &testResult, bool autoExpand = false);
|
||||
void removeCurrentTestMessage();
|
||||
void clearTestResults();
|
||||
|
||||
const TestResult *testResult(const QModelIndex &idx);
|
||||
TestResult testResult(const QModelIndex &idx);
|
||||
|
||||
int maxWidthOfFileName(const QFont &font);
|
||||
int maxWidthOfLineNumber(const QFont &font);
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
void toggleTestResultType(ResultType type);
|
||||
void clearTestResults();
|
||||
bool hasResults();
|
||||
const TestResult *testResult(const QModelIndex &index) const;
|
||||
TestResult testResult(const QModelIndex &index) const;
|
||||
TestResultItem *itemForIndex(const QModelIndex &index) const;
|
||||
|
||||
protected:
|
||||
|
@@ -228,7 +228,7 @@ TestResultsPane::~TestResultsPane()
|
||||
s_instance = nullptr;
|
||||
}
|
||||
|
||||
void TestResultsPane::addTestResult(const TestResultPtr &result)
|
||||
void TestResultsPane::addTestResult(const TestResult &result)
|
||||
{
|
||||
const QScrollBar *scrollBar = m_treeView->verticalScrollBar();
|
||||
m_atEnd = scrollBar ? scrollBar->value() == scrollBar->maximum() : true;
|
||||
@@ -457,9 +457,9 @@ void TestResultsPane::onItemActivated(const QModelIndex &index)
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
const TestResult *testResult = m_filterModel->testResult(index);
|
||||
if (testResult && !testResult->fileName().isEmpty())
|
||||
EditorManager::openEditorAt(Utils::Link{testResult->fileName(), testResult->line(), 0});
|
||||
const TestResult testResult = m_filterModel->testResult(index);
|
||||
if (testResult.isValid() && !testResult.fileName().isEmpty())
|
||||
EditorManager::openEditorAt(Utils::Link{testResult.fileName(), testResult.line(), 0});
|
||||
}
|
||||
|
||||
void TestResultsPane::onRunAllTriggered()
|
||||
@@ -609,12 +609,12 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
|
||||
{
|
||||
const bool resultsAvailable = m_filterModel->hasResults();
|
||||
const bool enabled = !m_testRunning && resultsAvailable;
|
||||
const TestResult *clicked = getTestResult(m_treeView->indexAt(pos));
|
||||
const TestResult clicked = getTestResult(m_treeView->indexAt(pos));
|
||||
QMenu menu;
|
||||
|
||||
QAction *action = new QAction(Tr::tr("Copy"), &menu);
|
||||
action->setShortcut(QKeySequence(QKeySequence::Copy));
|
||||
action->setEnabled(resultsAvailable && clicked);
|
||||
action->setEnabled(resultsAvailable && clicked.isValid());
|
||||
connect(action, &QAction::triggered, this, [this, clicked] {
|
||||
onCopyItemTriggered(clicked);
|
||||
});
|
||||
@@ -630,7 +630,7 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
|
||||
connect(action, &QAction::triggered, this, &TestResultsPane::onSaveWholeTriggered);
|
||||
menu.addAction(action);
|
||||
|
||||
const auto correlatingItem = (enabled && clicked) ? clicked->findTestTreeItem() : nullptr;
|
||||
const auto correlatingItem = (enabled && clicked.isValid()) ? clicked.findTestTreeItem() : nullptr;
|
||||
action = new QAction(Tr::tr("Run This Test"), &menu);
|
||||
action->setEnabled(correlatingItem && correlatingItem->canProvideTestConfiguration());
|
||||
connect(action, &QAction::triggered, this, [this, clicked] {
|
||||
@@ -669,21 +669,19 @@ void TestResultsPane::onCustomContextMenuRequested(const QPoint &pos)
|
||||
menu.exec(m_treeView->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
const TestResult *TestResultsPane::getTestResult(const QModelIndex &idx)
|
||||
TestResult TestResultsPane::getTestResult(const QModelIndex &idx)
|
||||
{
|
||||
if (!idx.isValid())
|
||||
return nullptr;
|
||||
|
||||
const TestResult *result = m_filterModel->testResult(idx);
|
||||
QTC_CHECK(result);
|
||||
|
||||
return {};
|
||||
const TestResult result = m_filterModel->testResult(idx);
|
||||
QTC_CHECK(result.isValid());
|
||||
return result;
|
||||
}
|
||||
|
||||
void TestResultsPane::onCopyItemTriggered(const TestResult *result)
|
||||
void TestResultsPane::onCopyItemTriggered(const TestResult &result)
|
||||
{
|
||||
QTC_ASSERT(result, return);
|
||||
setClipboardAndSelection(result->outputString(true));
|
||||
QTC_ASSERT(result.isValid(), return);
|
||||
setClipboardAndSelection(result.outputString(true));
|
||||
}
|
||||
|
||||
void TestResultsPane::onCopyWholeTriggered()
|
||||
@@ -705,12 +703,11 @@ void TestResultsPane::onSaveWholeTriggered()
|
||||
}
|
||||
}
|
||||
|
||||
void TestResultsPane::onRunThisTestTriggered(TestRunMode runMode, const TestResult *result)
|
||||
void TestResultsPane::onRunThisTestTriggered(TestRunMode runMode, const TestResult &result)
|
||||
{
|
||||
QTC_ASSERT(result, return);
|
||||
|
||||
const ITestTreeItem *item = result->findTestTreeItem();
|
||||
QTC_ASSERT(result.isValid(), return);
|
||||
|
||||
const ITestTreeItem *item = result.findTestTreeItem();
|
||||
if (item)
|
||||
TestRunner::instance()->runTest(runMode, item);
|
||||
}
|
||||
@@ -729,11 +726,11 @@ QString TestResultsPane::getWholeOutput(const QModelIndex &parent)
|
||||
QString output;
|
||||
for (int row = 0, count = m_model->rowCount(parent); row < count; ++row) {
|
||||
QModelIndex current = m_model->index(row, 0, parent);
|
||||
const TestResult *result = m_model->testResult(current);
|
||||
QTC_ASSERT(result, continue);
|
||||
const TestResult result = m_model->testResult(current);
|
||||
QTC_ASSERT(result.isValid(), continue);
|
||||
if (auto item = m_model->itemForIndex(current))
|
||||
output.append(item->resultString()).append('\t');
|
||||
output.append(result->outputString(true)).append('\n');
|
||||
output.append(result.outputString(true)).append('\n');
|
||||
output.append(getWholeOutput(current));
|
||||
}
|
||||
return output;
|
||||
@@ -741,25 +738,25 @@ QString TestResultsPane::getWholeOutput(const QModelIndex &parent)
|
||||
|
||||
void TestResultsPane::createMarks(const QModelIndex &parent)
|
||||
{
|
||||
const TestResult *parentResult = m_model->testResult(parent);
|
||||
ResultType parentType = parentResult ? parentResult->result() : ResultType::Invalid;
|
||||
const TestResult parentResult = m_model->testResult(parent);
|
||||
const ResultType parentType = parentResult.isValid() ? parentResult.result() : ResultType::Invalid;
|
||||
const QVector<ResultType> interested{ResultType::Fail, ResultType::UnexpectedPass};
|
||||
for (int row = 0, count = m_model->rowCount(parent); row < count; ++row) {
|
||||
const QModelIndex index = m_model->index(row, 0, parent);
|
||||
const TestResult *result = m_model->testResult(index);
|
||||
QTC_ASSERT(result, continue);
|
||||
const TestResult result = m_model->testResult(index);
|
||||
QTC_ASSERT(result.isValid(), continue);
|
||||
|
||||
if (m_model->hasChildren(index))
|
||||
createMarks(index);
|
||||
|
||||
bool isLocationItem = result->result() == ResultType::MessageLocation;
|
||||
if (interested.contains(result->result())
|
||||
bool isLocationItem = result.result() == ResultType::MessageLocation;
|
||||
if (interested.contains(result.result())
|
||||
|| (isLocationItem && interested.contains(parentType))) {
|
||||
TestEditorMark *mark = new TestEditorMark(index, result->fileName(), result->line());
|
||||
TestEditorMark *mark = new TestEditorMark(index, result.fileName(), result.line());
|
||||
mark->setIcon(index.data(Qt::DecorationRole).value<QIcon>());
|
||||
mark->setColor(Utils::Theme::OutputPanes_TestFailTextColor);
|
||||
mark->setPriority(TextEditor::TextMark::NormalPriority);
|
||||
mark->setToolTip(result->description());
|
||||
mark->setToolTip(result.description());
|
||||
m_marks << mark;
|
||||
}
|
||||
}
|
||||
|
@@ -72,7 +72,7 @@ public:
|
||||
void goToNext() override;
|
||||
void goToPrev() override;
|
||||
|
||||
void addTestResult(const TestResultPtr &result);
|
||||
void addTestResult(const TestResult &result);
|
||||
void addOutputLine(const QByteArray &outputLine, OutputChannel channel);
|
||||
void showTestResult(const QModelIndex &index);
|
||||
private:
|
||||
@@ -92,11 +92,11 @@ private:
|
||||
void onTestRunFinished();
|
||||
void onScrollBarRangeChanged(int, int max);
|
||||
void onCustomContextMenuRequested(const QPoint &pos);
|
||||
const TestResult *getTestResult(const QModelIndex &idx);
|
||||
void onCopyItemTriggered(const TestResult *result);
|
||||
TestResult getTestResult(const QModelIndex &idx);
|
||||
void onCopyItemTriggered(const TestResult &result);
|
||||
void onCopyWholeTriggered();
|
||||
void onSaveWholeTriggered();
|
||||
void onRunThisTestTriggered(TestRunMode runMode, const TestResult *result);
|
||||
void onRunThisTestTriggered(TestRunMode runMode, const TestResult &result);
|
||||
void toggleOutputStyle();
|
||||
QString getWholeOutput(const QModelIndex &parent = QModelIndex());
|
||||
|
||||
|
@@ -72,13 +72,13 @@ TestRunner::TestRunner()
|
||||
|
||||
m_cancelTimer.setSingleShot(true);
|
||||
connect(&m_cancelTimer, &QTimer::timeout, this, [this] { cancelCurrent(Timeout); });
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::resultReadyAt,
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResult>::resultReadyAt,
|
||||
this, [this](int index) { emit testResultReady(m_futureWatcher.resultAt(index)); });
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::finished,
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResult>::finished,
|
||||
this, &TestRunner::onFinished);
|
||||
connect(this, &TestRunner::requestStopTestRun,
|
||||
&m_futureWatcher, &QFutureWatcher<TestResultPtr>::cancel);
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResultPtr>::canceled, this, [this] {
|
||||
&m_futureWatcher, &QFutureWatcher<TestResult>::cancel);
|
||||
connect(&m_futureWatcher, &QFutureWatcher<TestResult>::canceled, this, [this] {
|
||||
cancelCurrent(UserCanceled);
|
||||
reportResult(ResultType::MessageFatal, Tr::tr("Test run canceled by user."));
|
||||
});
|
||||
@@ -537,8 +537,8 @@ void TestRunner::runTestsHelper()
|
||||
int testCaseCount = precheckTestConfigurations();
|
||||
|
||||
// Fake future interface - destruction will be handled by QFuture/QFutureWatcher
|
||||
m_fakeFutureInterface = new QFutureInterface<TestResultPtr>(QFutureInterfaceBase::Running);
|
||||
QFuture<TestResultPtr> future = m_fakeFutureInterface->future();
|
||||
m_fakeFutureInterface = new QFutureInterface<TestResult>(QFutureInterfaceBase::Running);
|
||||
QFuture<TestResult> future = m_fakeFutureInterface->future();
|
||||
m_fakeFutureInterface->setProgressRange(0, testCaseCount);
|
||||
m_fakeFutureInterface->setProgressValue(0);
|
||||
m_futureWatcher.setFuture(future);
|
||||
@@ -648,8 +648,8 @@ void TestRunner::debugTests()
|
||||
}
|
||||
|
||||
// We need a fake QFuture for the results. TODO: replace with QtConcurrent::run
|
||||
QFutureInterface<TestResultPtr> *futureInterface
|
||||
= new QFutureInterface<TestResultPtr>(QFutureInterfaceBase::Running);
|
||||
QFutureInterface<TestResult> *futureInterface
|
||||
= new QFutureInterface<TestResult>(QFutureInterfaceBase::Running);
|
||||
m_futureWatcher.setFuture(futureInterface->future());
|
||||
|
||||
if (useOutputProcessor) {
|
||||
@@ -804,9 +804,9 @@ void TestRunner::onFinished()
|
||||
|
||||
void TestRunner::reportResult(ResultType type, const QString &description)
|
||||
{
|
||||
TestResultPtr result(new TestResult);
|
||||
result->setResult(type);
|
||||
result->setDescription(description);
|
||||
TestResult result("internal", {});
|
||||
result.setResult(type);
|
||||
result.setDescription(description);
|
||||
emit testResultReady(result);
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,7 @@ signals:
|
||||
void testRunStarted();
|
||||
void testRunFinished();
|
||||
void requestStopTestRun();
|
||||
void testResultReady(const TestResultPtr &result);
|
||||
void testResultReady(const TestResult &result);
|
||||
void hadDisabledTests(int disabled);
|
||||
void reportSummary(const QString &id, const QHash<ResultType, int> &summary);
|
||||
|
||||
@@ -76,8 +76,8 @@ private:
|
||||
bool postponeTestRunWithEmptyExecutable(ProjectExplorer::Project *project);
|
||||
void onBuildSystemUpdated();
|
||||
|
||||
QFutureWatcher<TestResultPtr> m_futureWatcher;
|
||||
QFutureInterface<TestResultPtr> *m_fakeFutureInterface = nullptr;
|
||||
QFutureWatcher<TestResult> m_futureWatcher;
|
||||
QFutureInterface<TestResult> *m_fakeFutureInterface = nullptr;
|
||||
QList<ITestConfiguration *> m_selectedTests;
|
||||
bool m_executingTests = false;
|
||||
bool m_canceled = false;
|
||||
|
@@ -51,8 +51,8 @@ public:
|
||||
};
|
||||
|
||||
explicit ITestTreeItem(ITestBase *testBase,
|
||||
const QString &name = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
const QString &name = {},
|
||||
const Utils::FilePath &filePath = {},
|
||||
Type type = Root);
|
||||
|
||||
virtual QVariant data(int column, int role) const override;
|
||||
@@ -97,8 +97,8 @@ class TestTreeItem : public ITestTreeItem
|
||||
{
|
||||
public:
|
||||
explicit TestTreeItem(ITestFramework *testFramework,
|
||||
const QString &name = QString(),
|
||||
const Utils::FilePath &filePath = Utils::FilePath(),
|
||||
const QString &name = {},
|
||||
const Utils::FilePath &filePath = {},
|
||||
Type type = Root);
|
||||
|
||||
virtual TestTreeItem *copyWithoutChildren() = 0;
|
||||
|
@@ -160,8 +160,7 @@ TestResult SquishResultFilterModel::testResult(const QModelIndex &idx) const
|
||||
{
|
||||
if (auto item = static_cast<SquishResultItem *>(m_sourceModel->itemForIndex(mapToSource(idx))))
|
||||
return item->result();
|
||||
|
||||
return TestResult();
|
||||
return {};
|
||||
}
|
||||
|
||||
bool SquishResultFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
|
@@ -244,7 +244,7 @@ void SquishXmlOutputHandler::outputAvailable(const QByteArray &output)
|
||||
// SquishReport tags will be ignored completely
|
||||
if (currentName == "epilog") {
|
||||
QTC_ASSERT(testCaseRootItem, break);
|
||||
TestResult result(Result::End, QString(), time);
|
||||
const TestResult result(Result::End, QString(), time);
|
||||
SquishResultItem *item = new SquishResultItem(result);
|
||||
testCaseRootItem->appendChild(item);
|
||||
emit updateStatus(result.text());
|
||||
@@ -283,7 +283,7 @@ void SquishXmlOutputHandler::outputAvailable(const QByteArray &output)
|
||||
|
||||
if (!logDetailsList.isEmpty()) {
|
||||
for (const QString &detail : std::as_const(logDetailsList)) {
|
||||
TestResult childResult(Result::Detail, detail);
|
||||
const TestResult childResult(Result::Detail, detail);
|
||||
SquishResultItem *childItem = new SquishResultItem(childResult);
|
||||
item->appendChild(childItem);
|
||||
emit updateStatus(childResult.text());
|
||||
|
Reference in New Issue
Block a user