From ebfc118c35a97d4e83aff760fae85279ac80e080 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 9 Dec 2015 13:21:23 +0100 Subject: [PATCH] Add capability to execute selected gtests Change-Id: Ib7354d6e86176852b2e3bb01aed091db8036bfdf Reviewed-by: Niels Weber --- plugins/autotest/testrunner.cpp | 8 ++++++++ plugins/autotest/testtreemodel.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/plugins/autotest/testrunner.cpp b/plugins/autotest/testrunner.cpp index a8ceaa34612..7c613984bd6 100644 --- a/plugins/autotest/testrunner.cpp +++ b/plugins/autotest/testrunner.cpp @@ -177,6 +177,14 @@ void performTestRun(QFutureInterface &futureInterface, if (testConfiguration->testCases().count()) argumentList << testConfiguration->testCases(); testProcess.setArguments(argumentList); + } else { // TestConfiguration::GTest + const QStringList &testSets = testConfiguration->testCases(); + if (testSets.size()) { + QStringList argumentList; + argumentList << QLatin1String("--gtest_filter=") + + testSets.join(QLatin1Char(':')); + testProcess.setArguments(argumentList); + } } testProcess.setWorkingDirectory(testConfiguration->workingDirectory()); diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp index 770b92a4237..91811f621f1 100644 --- a/plugins/autotest/testtreemodel.cpp +++ b/plugins/autotest/testtreemodel.cpp @@ -376,6 +376,34 @@ QList TestTreeModel::getSelectedTests() const if (!config->unnamedOnly()) result << config; + // get selected Google Tests + QMap proFilesWithEnabledTestSets; + + for (int row = 0, count = m_googleTestRootItem->childCount(); row < count; ++row) { + const TestTreeItem *child = m_googleTestRootItem->childItem(row); + if (child->checked() == Qt::Unchecked) // add this test name to disabled list ? + continue; + + int grandChildCount = child->childCount(); + for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) { + const TestTreeItem *grandChild = child->childItem(grandChildRow); + const QString &proFile = grandChild->mainFile(); + QStringList enabled = proFilesWithEnabledTestSets.value(proFile); + if (grandChild->checked() == Qt::Checked) + enabled << child->name() + QLatin1Char('.') + grandChild->name(); + proFilesWithEnabledTestSets.insert(proFile, enabled); + } + } + + foreach (const QString &proFile, proFilesWithEnabledTestSets.keys()) { + TestConfiguration *tc = new TestConfiguration(QString(), + proFilesWithEnabledTestSets.value(proFile)); + tc->setTestType(TestConfiguration::GTest); + tc->setProFile(proFile); + tc->setProject(project); + result << tc; + } + return result; }