diff options
author | Christian Stenger <[email protected]> | 2019-05-21 13:39:00 +0200 |
---|---|---|
committer | Christian Stenger <[email protected]> | 2019-05-24 06:27:22 +0000 |
commit | b86c05b96ac4e4d7b8af54035fb9350b7bd89142 (patch) | |
tree | f6dd7a1bf5b25c9ee428d990ea4fd85b9d7da90c /src/plugins/autotest/autotestunittests.cpp | |
parent | 5c6eb0a2bac1cf644cbccf200fc547668e0079ca (diff) |
AutoTest: Add unit test for parsing boost tests
To execute them you need - beside the former prerequisites -
either have boost installed installed at system level (UNIX)
or you must specify BOOST_INCLUDE_DIR as environment variable
otherwise the respective test will be skipped.
Change-Id: I6bd8472e554132ab05e58b56e3ccbd5e9dffada9
Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/plugins/autotest/autotestunittests.cpp')
-rw-r--r-- | src/plugins/autotest/autotestunittests.cpp | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/src/plugins/autotest/autotestunittests.cpp b/src/plugins/autotest/autotestunittests.cpp index 2b8624a8346..eeeeb599de3 100644 --- a/src/plugins/autotest/autotestunittests.cpp +++ b/src/plugins/autotest/autotestunittests.cpp @@ -39,6 +39,7 @@ #include <projectexplorer/projectexplorer.h> #include <projectexplorer/toolchain.h> +#include <QFileInfo> #include <QSignalSpy> #include <QTest> @@ -53,9 +54,7 @@ namespace Internal { AutoTestUnitTests::AutoTestUnitTests(TestTreeModel *model, QObject *parent) : QObject(parent), - m_model(model), - m_tmpDir(nullptr), - m_isQt4(false) + m_model(model) { } @@ -74,6 +73,16 @@ void AutoTestUnitTests::initTestCase() QSKIP("This test requires that there is a kit with a toolchain."); m_tmpDir = new CppTools::Tests::TemporaryCopiedDir(":/unit_test"); + + if (!qgetenv("BOOST_INCLUDE_DIR").isEmpty()) { + m_checkBoost = true; + } else { + if (QFileInfo::exists("/usr/include/boost/version.hpp") + || QFileInfo::exists("/usr/local/include/boost/version.hpp")) { + qDebug() << "Found boost at system level - will run boost parser test."; + m_checkBoost = true; + } + } } void AutoTestUnitTests::cleanupTestCase() @@ -218,6 +227,7 @@ void AutoTestUnitTests::testCodeParserGTest() QCOMPARE(m_model->namedQuickTestsCount(), 0); QCOMPARE(m_model->unnamedQuickTestsCount(), 0); QCOMPARE(m_model->dataTagsCount(), 0); + QCOMPARE(m_model->boostTestNamesCount(), 0); } void AutoTestUnitTests::testCodeParserGTest_data() @@ -229,5 +239,51 @@ void AutoTestUnitTests::testCodeParserGTest_data() << QString(m_tmpDir->path() + "/simple_gt/simple_gt.qbs"); } +void AutoTestUnitTests::testCodeParserBoostTest() +{ + if (!m_checkBoost) + QSKIP("This test needs boost - set BOOST_INCLUDE_DIR (or have it installed)"); + + QFETCH(QString, projectFilePath); + CppTools::Tests::ProjectOpenerAndCloser projectManager; + CppTools::ProjectInfo projectInfo = projectManager.open(projectFilePath, true); + QVERIFY(projectInfo.isValid()); + + QSignalSpy parserSpy(m_model->parser(), SIGNAL(parsingFinished())); + QSignalSpy modelUpdateSpy(m_model, SIGNAL(sweepingDone())); + QVERIFY(parserSpy.wait(20000)); + QVERIFY(modelUpdateSpy.wait()); + + QCOMPARE(m_model->boostTestNamesCount(), 5); + + QMultiMap<QString, int> expectedSuitesAndTests; + expectedSuitesAndTests.insert(QStringLiteral("Master Test Suite"), 2); // decorators w/o suite + expectedSuitesAndTests.insert(QStringLiteral("Master Test Suite"), 2); // fixtures + expectedSuitesAndTests.insert(QStringLiteral("Master Test Suite"), 3); // functions + expectedSuitesAndTests.insert(QStringLiteral("Suite1"), 4); + expectedSuitesAndTests.insert(QStringLiteral("SuiteOuter"), 5); // 2 sub suites + 3 tests + + QMultiMap<QString, int> foundNamesAndSets = m_model->boostTestSuitesAndTests(); + QCOMPARE(expectedSuitesAndTests.size(), foundNamesAndSets.size()); + for (const QString &name : expectedSuitesAndTests.keys()) + QCOMPARE(expectedSuitesAndTests.values(name), foundNamesAndSets.values(name)); + + // check also that no Qt related tests have been found + QCOMPARE(m_model->autoTestsCount(), 0); + QCOMPARE(m_model->namedQuickTestsCount(), 0); + QCOMPARE(m_model->unnamedQuickTestsCount(), 0); + QCOMPARE(m_model->dataTagsCount(), 0); + QCOMPARE(m_model->gtestNamesCount(), 0); +} + +void AutoTestUnitTests::testCodeParserBoostTest_data() +{ + QTest::addColumn<QString>("projectFilePath"); + QTest::newRow("simpleBoostTest") + << QString(m_tmpDir->path() + "/simple_boost/simple_boost.pro"); + QTest::newRow("simpleBoostTestQbs") + << QString(m_tmpDir->path() + "/simple_boost/simple_boost.qbs"); +} + } // namespace Internal } // namespace Autotest |