diff options
author | Christian Stenger <christian.stenger@qt.io> | 2019-06-03 14:47:54 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2019-06-07 06:41:15 +0000 |
commit | 679b31f841de88a57e0dda883ca4ac5812a9e8e2 (patch) | |
tree | 60ec0daa71c4314d3e1a16bec62301a685d8b498 /src/plugins/autotest | |
parent | c20824f5ff77ecb8fee9ed480a124f4d41faa0fa (diff) |
AutoTest: Add support for templated boost tests
Change-Id: I393d20f186a47d7d1d18775a8f1102890c9de9f4
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/autotest')
-rw-r--r-- | src/plugins/autotest/boost/boostcodeparser.cpp | 10 | ||||
-rw-r--r-- | src/plugins/autotest/boost/boosttestparser.cpp | 4 | ||||
-rw-r--r-- | src/plugins/autotest/boost/boosttesttreeitem.cpp | 17 | ||||
-rw-r--r-- | src/plugins/autotest/boost/boosttesttreeitem.h | 1 |
4 files changed, 27 insertions, 5 deletions
diff --git a/src/plugins/autotest/boost/boostcodeparser.cpp b/src/plugins/autotest/boost/boostcodeparser.cpp index f15b8307d4d..79c612285b1 100644 --- a/src/plugins/autotest/boost/boostcodeparser.cpp +++ b/src/plugins/autotest/boost/boostcodeparser.cpp @@ -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; diff --git a/src/plugins/autotest/boost/boosttestparser.cpp b/src/plugins/autotest/boost/boosttestparser.cpp index 0d349de40a1..6f953e515a8 100644 --- a/src/plugins/autotest/boost/boosttestparser.cpp +++ b/src/plugins/autotest/boost/boosttestparser.cpp @@ -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) diff --git a/src/plugins/autotest/boost/boosttesttreeitem.cpp b/src/plugins/autotest/boost/boosttesttreeitem.cpp index ac1e900b47c..e2e58c28aff 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.cpp +++ b/src/plugins/autotest/boost/boosttesttreeitem.cpp @@ -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; diff --git a/src/plugins/autotest/boost/boosttesttreeitem.h b/src/plugins/autotest/boost/boosttesttreeitem.h index 31d4dd00456..1149720f9d0 100644 --- a/src/plugins/autotest/boost/boosttesttreeitem.h +++ b/src/plugins/autotest/boost/boosttesttreeitem.h @@ -43,6 +43,7 @@ public: Parameterized = 0x10, Fixture = 0x20, + Templated = 0x40, }; Q_FLAGS(TestState) Q_DECLARE_FLAGS(TestStates, TestState) |