Handle disabled gtests more correctly

Test summary now displays the number of disabled tests instead of having
them printed as loose messages.

Change-Id: I8ea736f789afc7c8ad6101a03fa5ca6428d92744
Reviewed-by: Niels Weber <niels.weber@theqtcompany.com>
This commit is contained in:
Christian Stenger
2015-12-14 12:48:58 +01:00
parent c8c79c409f
commit ce926564b0
5 changed files with 14 additions and 2 deletions

View File

@@ -344,9 +344,10 @@ void TestOutputReader::processGTestOutput()
description.clear();
} else if (disabledTests.exactMatch(line)) {
auto testResult = new GTestResult();
testResult->setResult(Result::MessageInternal);
testResult->setResult(Result::MessageDisabledTests);
int disabled = disabledTests.cap(1).toInt();
testResult->setDescription(tr("You have %n disabled test(s).", 0, disabled));
testResult->setLine(disabled); // misuse line property to hold number of disabled
testResultCreated(testResult);
description.clear();
}

View File

@@ -42,6 +42,7 @@ enum Type {
MessageFatal,
MessageInternal, INTERNAL_MESSAGES_BEGIN = MessageInternal,
MessageDisabledTests,
MessageTestCaseStart,
MessageTestCaseSuccess,
MessageTestCaseWarn,

View File

@@ -116,7 +116,8 @@ void TestResultItem::updateResult()
TestResultModel::TestResultModel(QObject *parent)
: Utils::TreeModel(parent),
m_widthOfLineNumber(0),
m_maxWidthOfFileName(0)
m_maxWidthOfFileName(0),
m_disabled(0)
{
}
@@ -140,6 +141,8 @@ void TestResultModel::addTestResult(TestResult *testResult, bool autoExpand)
// we'll add the new item, so raising it's counter
if (!isCurrentTestMssg) {
int count = m_testResultCount.value(testResult->result(), 0);
if (testResult->result() == Result::MessageDisabledTests)
m_disabled += testResult->line();
m_testResultCount.insert(testResult->result(), ++count);
} else {
// MessageCurrentTest should always be the last top level item
@@ -205,6 +208,7 @@ void TestResultModel::clearTestResults()
{
clear();
m_testResultCount.clear();
m_disabled = 0;
m_processedIndices.clear();
m_maxWidthOfFileName = 0;
m_widthOfLineNumber = 0;

View File

@@ -62,11 +62,13 @@ public:
int maxWidthOfLineNumber(const QFont &font);
int resultTypeCount(Result::Type type) const { return m_testResultCount.value(type, 0); }
int disabledTests() const { return m_disabled; }
private:
QMap<Result::Type, int> m_testResultCount;
int m_widthOfLineNumber;
int m_maxWidthOfFileName;
int m_disabled;
QList<int> m_processedIndices;
QFont m_measurementFont;
};

View File

@@ -445,6 +445,10 @@ void TestResultsPane::updateSummaryLabel()
labelText.append(QString::fromLatin1(", %1 %2")
.arg(QString::number(count), tr("blacklisted")));
count = m_model->disabledTests();
if (count)
labelText.append(tr(", %1 disabled").arg(count));
labelText.append(QLatin1String(".</p>"));
m_summaryLabel->setText(labelText);
}