forked from qt-creator/qt-creator
AutoTest: Enhance reporting passes and fails
Depending on the report and log level of Boost UTF the number of test passes and fails might be wrong. Circumvent by providing a way to report a summary. Change-Id: I6d2cb7674550f10a0263e08d21cce42569f3d7a8 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -48,6 +48,8 @@ public:
|
|||||||
void createAndReportResult(const QString &message, ResultType type);
|
void createAndReportResult(const QString &message, ResultType type);
|
||||||
bool hadValidOutput() const { return m_hadValidOutput; }
|
bool hadValidOutput() const { return m_hadValidOutput; }
|
||||||
int disabledTests() const { return m_disabled; }
|
int disabledTests() const { return m_disabled; }
|
||||||
|
bool hasSummary() const { return !m_summary.isEmpty(); }
|
||||||
|
QHash<ResultType, int> summary() const { return m_summary; }
|
||||||
void setId(const QString &id) { m_id = id; }
|
void setId(const QString &id) { m_id = id; }
|
||||||
QString id() const { return m_id; }
|
QString id() const { return m_id; }
|
||||||
|
|
||||||
@@ -64,6 +66,7 @@ protected:
|
|||||||
QProcess *m_testApplication; // not owned
|
QProcess *m_testApplication; // not owned
|
||||||
QString m_buildDir;
|
QString m_buildDir;
|
||||||
QString m_id;
|
QString m_id;
|
||||||
|
QHash<ResultType, int> m_summary;
|
||||||
int m_disabled = -1;
|
int m_disabled = -1;
|
||||||
private:
|
private:
|
||||||
bool m_hadValidOutput = false;
|
bool m_hadValidOutput = false;
|
||||||
|
|||||||
@@ -23,10 +23,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "testresultmodel.h"
|
||||||
#include "autotesticons.h"
|
#include "autotesticons.h"
|
||||||
#include "autotestplugin.h"
|
#include "autotestplugin.h"
|
||||||
#include "testresultdelegate.h"
|
#include "testresultdelegate.h"
|
||||||
#include "testresultmodel.h"
|
#include "testrunner.h"
|
||||||
#include "testsettings.h"
|
#include "testsettings.h"
|
||||||
|
|
||||||
#include <projectexplorer/projectexplorericons.h>
|
#include <projectexplorer/projectexplorericons.h>
|
||||||
@@ -220,6 +221,10 @@ QString TestResultItem::resultString() const
|
|||||||
TestResultModel::TestResultModel(QObject *parent)
|
TestResultModel::TestResultModel(QObject *parent)
|
||||||
: Utils::TreeModel<TestResultItem>(new TestResultItem(TestResultPtr()), parent)
|
: Utils::TreeModel<TestResultItem>(new TestResultItem(TestResultPtr()), parent)
|
||||||
{
|
{
|
||||||
|
connect(TestRunner::instance(), &TestRunner::reportSummary,
|
||||||
|
this, [this](const QString &id, const QHash<ResultType, int> &summary){
|
||||||
|
m_reportedSummary.insert(id, summary);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestResultModel::updateParent(const TestResultItem *item)
|
void TestResultModel::updateParent(const TestResultItem *item)
|
||||||
@@ -256,7 +261,7 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_testResultCount[testResult->result()]++;
|
m_testResultCount[testResult->id()][testResult->result()]++;
|
||||||
|
|
||||||
TestResultItem *newItem = new TestResultItem(testResult);
|
TestResultItem *newItem = new TestResultItem(testResult);
|
||||||
TestResultItem *root = nullptr;
|
TestResultItem *root = nullptr;
|
||||||
@@ -314,6 +319,7 @@ void TestResultModel::clearTestResults()
|
|||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
m_testResultCount.clear();
|
m_testResultCount.clear();
|
||||||
|
m_reportedSummary.clear();
|
||||||
m_disabled = 0;
|
m_disabled = 0;
|
||||||
m_fileNames.clear();
|
m_fileNames.clear();
|
||||||
m_maxWidthOfFileName = 0;
|
m_maxWidthOfFileName = 0;
|
||||||
@@ -363,6 +369,21 @@ int TestResultModel::maxWidthOfLineNumber(const QFont &font)
|
|||||||
return m_widthOfLineNumber;
|
return m_widthOfLineNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TestResultModel::resultTypeCount(ResultType type) const
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
|
||||||
|
for (auto resultsForId : m_testResultCount.values())
|
||||||
|
result += resultsForId.value(type, 0);
|
||||||
|
|
||||||
|
for (auto id : m_reportedSummary.keys()) {
|
||||||
|
if (int counted = m_testResultCount.value(id).value(type))
|
||||||
|
result -= counted;
|
||||||
|
result += m_reportedSummary[id].value(type);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
|
TestResultItem *TestResultModel::findParentItemFor(const TestResultItem *item,
|
||||||
const TestResultItem *startItem) const
|
const TestResultItem *startItem) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public:
|
|||||||
int maxWidthOfFileName(const QFont &font);
|
int maxWidthOfFileName(const QFont &font);
|
||||||
int maxWidthOfLineNumber(const QFont &font);
|
int maxWidthOfLineNumber(const QFont &font);
|
||||||
|
|
||||||
int resultTypeCount(ResultType type) const { return m_testResultCount.value(type, 0); }
|
int resultTypeCount(ResultType type) const;
|
||||||
int disabledTests() const { return m_disabled; }
|
int disabledTests() const { return m_disabled; }
|
||||||
void raiseDisabledTests(int amount) { m_disabled += amount; }
|
void raiseDisabledTests(int amount) { m_disabled += amount; }
|
||||||
|
|
||||||
@@ -94,7 +94,8 @@ private:
|
|||||||
TestResultItem *findParentItemFor(const TestResultItem *item,
|
TestResultItem *findParentItemFor(const TestResultItem *item,
|
||||||
const TestResultItem *startItem = nullptr) const;
|
const TestResultItem *startItem = nullptr) const;
|
||||||
void updateParent(const TestResultItem *item);
|
void updateParent(const TestResultItem *item);
|
||||||
QMap<ResultType, int> m_testResultCount;
|
QHash<QString, QMap<ResultType, int>> m_testResultCount;
|
||||||
|
QHash<QString, QHash<ResultType, int>> m_reportedSummary;
|
||||||
int m_widthOfLineNumber = 0;
|
int m_widthOfLineNumber = 0;
|
||||||
int m_maxWidthOfFileName = 0;
|
int m_maxWidthOfFileName = 0;
|
||||||
int m_disabled = 0;
|
int m_disabled = 0;
|
||||||
|
|||||||
@@ -270,6 +270,9 @@ void TestRunner::onProcessFinished()
|
|||||||
const int disabled = m_currentOutputReader->disabledTests();
|
const int disabled = m_currentOutputReader->disabledTests();
|
||||||
if (disabled > 0)
|
if (disabled > 0)
|
||||||
emit hadDisabledTests(disabled);
|
emit hadDisabledTests(disabled);
|
||||||
|
if (m_currentOutputReader->hasSummary())
|
||||||
|
emit reportSummary(m_currentOutputReader->id(), m_currentOutputReader->summary());
|
||||||
|
|
||||||
resetInternalPointers();
|
resetInternalPointers();
|
||||||
|
|
||||||
if (!m_fakeFutureInterface) {
|
if (!m_fakeFutureInterface) {
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ signals:
|
|||||||
void requestStopTestRun();
|
void requestStopTestRun();
|
||||||
void testResultReady(const TestResultPtr &result);
|
void testResultReady(const TestResultPtr &result);
|
||||||
void hadDisabledTests(int disabled);
|
void hadDisabledTests(int disabled);
|
||||||
|
void reportSummary(const QString &id, const QHash<ResultType, int> &summary);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void buildProject(ProjectExplorer::Project *project);
|
void buildProject(ProjectExplorer::Project *project);
|
||||||
|
|||||||
Reference in New Issue
Block a user