forked from qt-creator/qt-creator
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:
committed by
Christian Stenger
parent
537c6fa9a8
commit
6bd7c3ef3b
@@ -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)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
int grandChildCount = child->childCount();
|
const int grandChildCount = child->childCount();
|
||||||
|
QTC_ASSERT(grandChildCount != 0, continue);
|
||||||
|
|
||||||
|
switch (child->checked()) {
|
||||||
|
case Qt::Unchecked:
|
||||||
|
continue;
|
||||||
|
case Qt::Checked: {
|
||||||
|
auto &testCases = proFilesWithCheckedTestSets[createProfile(child->childItem(0))];
|
||||||
|
testCases.filters.append(gtestFilter(child->state()).arg(child->name()).arg('*'));
|
||||||
|
testCases.additionalTestCaseCount += grandChildCount - 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case Qt::PartiallyChecked: {
|
||||||
for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) {
|
for (int grandChildRow = 0; grandChildRow < grandChildCount; ++grandChildRow) {
|
||||||
const TestTreeItem *grandChild = child->childItem(grandChildRow);
|
const TestTreeItem *grandChild = child->childItem(grandChildRow);
|
||||||
if (grandChild->checked() == Qt::Checked) {
|
if (grandChild->checked() == Qt::Checked) {
|
||||||
ProFileWithDisplayName key(grandChild->proFile(),
|
proFilesWithCheckedTestSets[createProfile(grandChild)].filters.append(
|
||||||
TestUtils::getCMakeDisplayNameIfNecessary(grandChild->filePath(),
|
|
||||||
grandChild->proFile()));
|
|
||||||
|
|
||||||
proFilesWithCheckedTestSets[key].append(
|
|
||||||
gtestFilter(child->state()).arg(child->name()).arg(grandChild->name()));
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user