forked from qt-creator/qt-creator
AutoTest: Add report helper function
Adds a report() function which generates a simple string holding the number of items per framework root node and uses it inside the logging after a full parse. Change-Id: Ib4be89de778aeab7e9c80b5c0522ee7f3f1bb587 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -456,6 +456,13 @@ void TestCodeParser::onFinished(bool success)
|
||||
emit parsingFinished();
|
||||
qCDebug(LOG) << QDateTime::currentDateTime().toString("hh:mm:ss.zzz") << "ParsingFin";
|
||||
qCDebug(LOG) << "Parsing took:" << m_parsingTimer.elapsed() << "ms";
|
||||
if (LOG().isInfoEnabled()) {
|
||||
qCInfo(LOG).noquote().nospace()
|
||||
<< "Current test tree:" << TestTreeModel::instance()->report(true);
|
||||
} else {
|
||||
qCDebug(LOG).noquote().nospace()
|
||||
<< "Current test tree:" << TestTreeModel::instance()->report(false);
|
||||
}
|
||||
}
|
||||
m_dirty = false;
|
||||
break;
|
||||
@@ -497,6 +504,12 @@ void TestCodeParser::onPartialParsingFinished()
|
||||
m_updateParsers.clear();
|
||||
emit parsingFinished();
|
||||
qCDebug(LOG) << QDateTime::currentDateTime().toString("hh:mm:ss.zzz") << "ParsingFin";
|
||||
if (LOG().isDebugEnabled()) {
|
||||
QMetaObject::invokeMethod(this, [] { // sweep() needs to be processed before logging
|
||||
qCDebug(LOG).noquote().nospace()
|
||||
<< "Current test tree:" << TestTreeModel::instance()->report(false);
|
||||
}, Qt::QueuedConnection);
|
||||
}
|
||||
} else {
|
||||
qCDebug(LOG) << "not emitting parsingFinished"
|
||||
<< "(on PartialParsingFinished, singleshot scheduled)";
|
||||
|
||||
@@ -500,6 +500,40 @@ void TestTreeModel::sweep()
|
||||
#endif
|
||||
}
|
||||
|
||||
QString TestTreeModel::report(bool full) const
|
||||
{
|
||||
QString result;
|
||||
int items = 0;
|
||||
QString tree;
|
||||
for (TestTreeItem *rootNode : frameworkRootNodes()) {
|
||||
int itemsPerRoot = 0;
|
||||
result.append("\n");
|
||||
result += rootNode->name();
|
||||
result.append(" > ");
|
||||
|
||||
if (full) {
|
||||
TestTreeSortFilterModel sortFilterModel(const_cast<TestTreeModel *>(this));
|
||||
sortFilterModel.setDynamicSortFilter(true);
|
||||
sortFilterModel.sort(0);
|
||||
tree = "\n" + sortFilterModel.report();
|
||||
rootNode->forAllChildren([&itemsPerRoot](TreeItem *) {
|
||||
++itemsPerRoot;
|
||||
});
|
||||
|
||||
} else {
|
||||
rootNode->forAllChildren([&itemsPerRoot](TreeItem *) {
|
||||
++itemsPerRoot;
|
||||
});
|
||||
}
|
||||
result.append(QString::number(itemsPerRoot));
|
||||
items += itemsPerRoot;
|
||||
}
|
||||
result.append("\nItems: " + QString::number(items));
|
||||
if (full)
|
||||
return tree + '\n' + result;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @note after calling this function emit testTreeModelChanged() if it returns true
|
||||
*/
|
||||
@@ -891,6 +925,26 @@ TestTreeSortFilterModel::FilterMode TestTreeSortFilterModel::toFilterMode(int f)
|
||||
}
|
||||
}
|
||||
|
||||
static QString dumpIndex(const QModelIndex &idx, int level = 0)
|
||||
{
|
||||
QString result;
|
||||
result.append(QString(level, ' '));
|
||||
result.append(idx.data().toString() + '\n');
|
||||
for (int row = 0, end = idx.model()->rowCount(idx); row < end; ++row)
|
||||
result.append(dumpIndex(idx.model()->index(row, 0, idx), level + 1));
|
||||
return result;
|
||||
}
|
||||
|
||||
QString TestTreeSortFilterModel::report() const
|
||||
{
|
||||
QString result;
|
||||
for (int row = 0, end = rowCount(); row < end; ++row) {
|
||||
auto idx = index(row, 0);
|
||||
result.append(dumpIndex(idx));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TestTreeSortFilterModel::lessThan(const QModelIndex &left, const QModelIndex &right) const
|
||||
{
|
||||
// root items keep the intended order
|
||||
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
void markAllFrameworkItemsForRemoval();
|
||||
void markForRemoval(const QSet<Utils::FilePath> &filePaths);
|
||||
void sweep();
|
||||
QString report(bool full) const;
|
||||
|
||||
signals:
|
||||
void testTreeModelChanged();
|
||||
@@ -117,6 +118,7 @@ public:
|
||||
void toggleFilter(FilterMode filterMode);
|
||||
static FilterMode toFilterMode(int f);
|
||||
|
||||
QString report() const;
|
||||
protected:
|
||||
bool lessThan(const QModelIndex &left, const QModelIndex &right) const final;
|
||||
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const final;
|
||||
|
||||
Reference in New Issue
Block a user