forked from qt-creator/qt-creator
AutoTest: Add support for templated boost tests
Change-Id: I393d20f186a47d7d1d18775a8f1102890c9de9f4 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -115,6 +115,13 @@ void BoostCodeParser::handleIdentifier()
|
||||
} else if (identifier == "BOOST_DATA_TEST_CASE_F") {
|
||||
m_currentState.setFlag(BoostTestTreeItem::Fixture);
|
||||
handleTestCase(TestCaseType::Data);
|
||||
} else if (identifier == "BOOST_AUTO_TEST_CASE_TEMPLATE") {
|
||||
m_currentState.setFlag(BoostTestTreeItem::Templated);
|
||||
handleTestCase(TestCaseType::Auto);
|
||||
} else if (identifier == "BOOST_FIXTURE_TEST_CASE_TEMPLATE") {
|
||||
m_currentState.setFlag(BoostTestTreeItem::Fixture);
|
||||
m_currentState.setFlag(BoostTestTreeItem::Templated);
|
||||
handleTestCase(TestCaseType::Auto);
|
||||
} else if (identifier == "BOOST_TEST_DECORATOR") {
|
||||
handleDecorator();
|
||||
}
|
||||
@@ -237,7 +244,8 @@ void BoostCodeParser::handleTestCase(TestCaseType testCaseType)
|
||||
m_currentState = BoostTestTreeItem::Enabled;
|
||||
}
|
||||
} else {
|
||||
handleDecorators();
|
||||
if (!m_currentState.testFlag(BoostTestTreeItem::Templated))
|
||||
handleDecorators();
|
||||
locationAndType = locationAndTypeFromToken(token, m_source, m_currentState, m_suites);
|
||||
m_testCases.append(locationAndType);
|
||||
m_currentState = BoostTestTreeItem::Enabled;
|
||||
|
@@ -40,7 +40,9 @@ namespace BoostTestUtils {
|
||||
static const QStringList relevant = {
|
||||
QStringLiteral("BOOST_AUTO_TEST_CASE"), QStringLiteral("BOOST_TEST_CASE"),
|
||||
QStringLiteral("BOOST_DATA_TEST_CASE"), QStringLiteral("BOOST_FIXTURE_TEST_CASE"),
|
||||
QStringLiteral("BOOST_PARAM_TEST_CASE"), QStringLiteral("BOOST_DATA_TEST_CASE_F")
|
||||
QStringLiteral("BOOST_PARAM_TEST_CASE"), QStringLiteral("BOOST_DATA_TEST_CASE_F"),
|
||||
QStringLiteral("BOOST_AUTO_TEST_CASE_TEMPLATE"),
|
||||
QStringLiteral("BOOST_FIXTURE_TEST_CASE_TEMPLATE"),
|
||||
};
|
||||
|
||||
bool isBoostTestMacro(const QString ¯o)
|
||||
|
@@ -233,7 +233,10 @@ QList<TestConfiguration *> BoostTestTreeItem::getSelectedTestConfigurations() co
|
||||
if (!item->enabled()) // ignore child tests known to be disabled when using run selected
|
||||
return;
|
||||
if (item->checked() == Qt::Checked) {
|
||||
QString tcName = handleSpecialFunctionNames(item->name());
|
||||
QString tcName = item->name();
|
||||
if (item->state().testFlag(BoostTestTreeItem::Templated))
|
||||
tcName.append("<*");
|
||||
tcName = handleSpecialFunctionNames(tcName);
|
||||
testCasesForProjectFile[item->proFile()].testCases.append(
|
||||
item->prependWithParentsSuitePaths(tcName));
|
||||
testCasesForProjectFile[item->proFile()].internalTargets.unite(item->internalTargets());
|
||||
@@ -268,12 +271,17 @@ TestConfiguration *BoostTestTreeItem::testConfiguration() const
|
||||
QString tcName = handleSpecialFunctionNames(boostItem->name());
|
||||
if (boostItem->type() == TestSuite) // execute everything below a suite
|
||||
tcName.append("/*");
|
||||
else if (boostItem->state().testFlag(BoostTestTreeItem::Templated))
|
||||
tcName.append("<*");
|
||||
testCases.append(boostItem->prependWithParentsSuitePaths(tcName));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
testCases.append(prependWithParentsSuitePaths(handleSpecialFunctionNames(name())));
|
||||
QString tcName = name();
|
||||
if (state().testFlag(BoostTestTreeItem::Templated))
|
||||
tcName.append("<*");
|
||||
testCases.append(prependWithParentsSuitePaths(handleSpecialFunctionNames(tcName)));
|
||||
}
|
||||
|
||||
BoostTestConfiguration *config = new BoostTestConfiguration;
|
||||
@@ -297,12 +305,15 @@ TestConfiguration *BoostTestTreeItem::debugConfiguration() const
|
||||
QString BoostTestTreeItem::nameSuffix() const
|
||||
{
|
||||
static QString markups[] = {QCoreApplication::translate("BoostTestTreeItem", "parameterized"),
|
||||
QCoreApplication::translate("BoostTestTreeItem", "fixture")};
|
||||
QCoreApplication::translate("BoostTestTreeItem", "fixture"),
|
||||
QCoreApplication::translate("BoostTestTreeItem", "templated")};
|
||||
QString suffix;
|
||||
if (m_state & Parameterized)
|
||||
suffix = QString(" [") + markups[0];
|
||||
if (m_state & Fixture)
|
||||
suffix += (suffix.isEmpty() ? QString(" [") : QString(", ")) + markups[1];
|
||||
if (m_state & Templated)
|
||||
suffix += (suffix.isEmpty() ? QString(" [") : QString(", ")) + markups[2];
|
||||
if (!suffix.isEmpty())
|
||||
suffix += ']';
|
||||
return suffix;
|
||||
|
@@ -43,6 +43,7 @@ public:
|
||||
|
||||
Parameterized = 0x10,
|
||||
Fixture = 0x20,
|
||||
Templated = 0x40,
|
||||
};
|
||||
Q_FLAGS(TestState)
|
||||
Q_DECLARE_FLAGS(TestStates, TestState)
|
||||
|
Reference in New Issue
Block a user