AutoTest: Use wildcards for gtest filter.

If all test sets of a test case are selected use a wildcard filter.
This reduces the length of the command line which is limited on
Windows.

Change-Id: Ie4c1e3ede91eff6293c982e03d454bcf8c9b5815
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2016-06-17 14:01:53 +02:00
committed by Christian Stenger
parent 537c6fa9a8
commit 6bd7c3ef3b

View File

@@ -199,6 +199,19 @@ QList<TestConfiguration *> GTestTreeItem::getAllTestConfigurations() const
return result; return result;
} }
struct TestCases
{
QStringList filters;
int additionalTestCaseCount = 0;
};
static const ProFileWithDisplayName createProfile(const TestTreeItem *item)
{
return ProFileWithDisplayName(
item->proFile(),
TestUtils::getCMakeDisplayNameIfNecessary(item->filePath(), item->proFile()));
}
QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
{ {
QList<TestConfiguration *> result; QList<TestConfiguration *> result;
@@ -206,34 +219,44 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
if (!project || type() != Root) if (!project || type() != Root)
return result; return result;
QHash<ProFileWithDisplayName, QStringList> proFilesWithCheckedTestSets; QHash<ProFileWithDisplayName, TestCases> proFilesWithCheckedTestSets;
for (int row = 0, count = childCount(); row < count; ++row) { for (int row = 0, count = childCount(); row < count; ++row) {
const GTestTreeItem *child = static_cast<const GTestTreeItem *>(childItem(row)); const GTestTreeItem *child = static_cast<const GTestTreeItem *>(childItem(row));
if (child->checked() == Qt::Unchecked)
const int grandChildCount = child->childCount();
QTC_ASSERT(grandChildCount != 0, continue);
switch (child->checked()) {
case Qt::Unchecked:
continue; continue;
case Qt::Checked: {
int grandChildCount = child->childCount(); auto &testCases = proFilesWithCheckedTestSets[createProfile(child->childItem(0))];
for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) { testCases.filters.append(gtestFilter(child->state()).arg(child->name()).arg('*'));
const TestTreeItem *grandChild = child->childItem(grandChildRow); testCases.additionalTestCaseCount += grandChildCount - 1;
if (grandChild->checked() == Qt::Checked) { break;
ProFileWithDisplayName key(grandChild->proFile(), }
TestUtils::getCMakeDisplayNameIfNecessary(grandChild->filePath(), case Qt::PartiallyChecked: {
grandChild->proFile())); for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) {
const TestTreeItem *grandChild = child->childItem(grandChildRow);
proFilesWithCheckedTestSets[key].append( if (grandChild->checked() == Qt::Checked) {
gtestFilter(child->state()).arg(child->name()).arg(grandChild->name())); proFilesWithCheckedTestSets[createProfile(grandChild)].filters.append(
gtestFilter(child->state()).arg(child->name()).arg(grandChild->name()));
}
} }
break;
}
} }
} }
QHash<ProFileWithDisplayName, QStringList>::ConstIterator it = proFilesWithCheckedTestSets.begin(); QHash<ProFileWithDisplayName, TestCases>::ConstIterator it = proFilesWithCheckedTestSets.begin();
QHash<ProFileWithDisplayName, QStringList>::ConstIterator end = proFilesWithCheckedTestSets.end(); QHash<ProFileWithDisplayName, TestCases>::ConstIterator end = proFilesWithCheckedTestSets.end();
for ( ; it != end; ++it) { for ( ; it != end; ++it) {
const ProFileWithDisplayName &key = it.key(); const ProFileWithDisplayName &proFileWithDisplayName = it.key();
GTestConfiguration *tc = new GTestConfiguration; GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCases(it.value()); tc->setTestCases(it.value().filters);
tc->setProFile(key.proFile); tc->setTestCaseCount(tc->testCaseCount() + it.value().additionalTestCaseCount);
tc->setDisplayName(key.displayName); tc->setProFile(proFileWithDisplayName.proFile);
tc->setDisplayName(proFileWithDisplayName.displayName);
tc->setProject(project); tc->setProject(project);
result << tc; result << tc;
} }