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(); description.clear();
} else if (disabledTests.exactMatch(line)) { } else if (disabledTests.exactMatch(line)) {
auto testResult = new GTestResult(); auto testResult = new GTestResult();
testResult->setResult(Result::MessageInternal); testResult->setResult(Result::MessageDisabledTests);
int disabled = disabledTests.cap(1).toInt(); int disabled = disabledTests.cap(1).toInt();
testResult->setDescription(tr("You have %n disabled test(s).", 0, disabled)); testResult->setDescription(tr("You have %n disabled test(s).", 0, disabled));
testResult->setLine(disabled); // misuse line property to hold number of disabled
testResultCreated(testResult); testResultCreated(testResult);
description.clear(); description.clear();
} }

View File

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

View File

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

View File

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

View File

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