forked from qt-creator/qt-creator
AutoTest: Improve matching test results to tree item
...when using Boost UTF. We need to take parameterized and templated tests into account differently and we may have results that do not provide file information at all, so try to find a matching tree item from what we have got. Change-Id: Ia0b1894d5dd729d39e5724d9fdeadd574a9cfde5 Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#include "boosttestoutputreader.h"
|
||||
#include "boosttestsettings.h"
|
||||
#include "boosttestresult.h"
|
||||
#include "boosttesttreeitem.h"
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -107,6 +108,9 @@ void BoostTestOutputReader::sendCompleteInformation()
|
||||
if (m_lineNumber) {
|
||||
result->setLine(m_lineNumber);
|
||||
result->setFileName(m_fileName);
|
||||
} else if (const TestTreeItem *it = result->findTestTreeItem()) {
|
||||
result->setLine(it->line());
|
||||
result->setFileName(it->filePath());
|
||||
}
|
||||
|
||||
result->setDescription(m_description);
|
||||
|
||||
@@ -85,10 +85,10 @@ const TestTreeItem *BoostTestResult::findTestTreeItem() const
|
||||
if (!rootNode)
|
||||
return nullptr;
|
||||
|
||||
const auto item = rootNode->findAnyChild([this](const Utils::TreeItem *item) {
|
||||
const auto foundItem = rootNode->findAnyChild([this](const Utils::TreeItem *item) {
|
||||
return matches(static_cast<const BoostTestTreeItem *>(item));
|
||||
});
|
||||
return static_cast<const TestTreeItem *>(item);
|
||||
return static_cast<const TestTreeItem *>(foundItem);
|
||||
}
|
||||
|
||||
bool BoostTestResult::matches(const BoostTestTreeItem *item) const
|
||||
@@ -99,16 +99,26 @@ bool BoostTestResult::matches(const BoostTestTreeItem *item) const
|
||||
return false;
|
||||
if (m_testCase.isEmpty()) // a top level module node
|
||||
return item->proFile() == m_projectFile;
|
||||
if (item->proFile() != m_projectFile)
|
||||
return false;
|
||||
if (!fileName().isEmpty() && fileName() != item->filePath())
|
||||
return false;
|
||||
|
||||
if (item->state() & BoostTestTreeItem::Parameterized) {
|
||||
if (!m_testCase.startsWith(item->name()))
|
||||
return false;
|
||||
} else {
|
||||
if (item->name() != m_testCase)
|
||||
return false;
|
||||
QString fullName = "::" + m_testCase;
|
||||
fullName.prepend(m_testSuite.isEmpty() ? QString(BoostTest::Constants::BOOST_MASTER_SUITE)
|
||||
: m_testSuite);
|
||||
|
||||
BoostTestTreeItem::TestStates states = item->state();
|
||||
if (states & BoostTestTreeItem::Templated) {
|
||||
const QRegularExpression regex(
|
||||
QRegularExpression::wildcardToRegularExpression(item->fullName() + "<*>"));
|
||||
return regex.match(fullName).hasMatch();
|
||||
} else if (states & BoostTestTreeItem::Parameterized) {
|
||||
const QRegularExpression regex(
|
||||
QRegularExpression::anchoredPattern(item->fullName() + "_\\d+"));
|
||||
return regex.isValid() && regex.match(fullName).hasMatch();
|
||||
}
|
||||
|
||||
return item->filePath() == fileName() && item->proFile() == m_projectFile;
|
||||
return item->fullName() == fullName;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -240,7 +240,7 @@ QList<TestConfiguration *> BoostTestTreeItem::getTestConfigurations(
|
||||
if (item->state().testFlag(BoostTestTreeItem::Templated))
|
||||
tcName.append("<*");
|
||||
else if (item->state().testFlag(BoostTestTreeItem::Parameterized))
|
||||
tcName.append('*');
|
||||
tcName.append("_*");
|
||||
tcName = handleSpecialFunctionNames(tcName);
|
||||
testCasesForProjectFile[item->proFile()].testCases.append(
|
||||
item->prependWithParentsSuitePaths(tcName));
|
||||
@@ -293,7 +293,7 @@ TestConfiguration *BoostTestTreeItem::testConfiguration() const
|
||||
if (boostItem->type() == TestSuite) // execute everything below a suite
|
||||
tcName.append("/*");
|
||||
else if (boostItem->state().testFlag(BoostTestTreeItem::Parameterized))
|
||||
tcName.append('*');
|
||||
tcName.append("_*");
|
||||
else if (boostItem->state().testFlag(BoostTestTreeItem::Templated))
|
||||
tcName.append("<*");
|
||||
testCases.append(boostItem->prependWithParentsSuitePaths(tcName));
|
||||
@@ -305,7 +305,7 @@ TestConfiguration *BoostTestTreeItem::testConfiguration() const
|
||||
if (state().testFlag(BoostTestTreeItem::Templated))
|
||||
tcName.append("<*");
|
||||
else if (state().testFlag(BoostTestTreeItem::Parameterized))
|
||||
tcName.append('*');
|
||||
tcName.append("_*");
|
||||
testCases.append(prependWithParentsSuitePaths(handleSpecialFunctionNames(tcName)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user