Commit 6a470f0a authored by Christian Stenger's avatar Christian Stenger

AutoTest: Do not overwrite already found build system targets

Especially when using CMake based projects in combination with GTest
we might have lots of build targets defined inside the same
'project file'. Overwriting the already assigned content is purely
wrong. Instead handle each found build system target on its own.

Task-number: QTCREATORBUG-17882
Task-number: QTCREATORBUG-18932
Change-Id: I3297a9e1da8ae4186fd4267e3485368b1a059314
Reviewed-by: default avatarDavid Schulz <david.schulz@qt.io>
parent 7cbc7af0
......@@ -138,19 +138,22 @@ QList<TestConfiguration *> GTestTreeItem::getAllTestConfigurations() const
const TestTreeItem *grandChild = child->childItem(grandChildRow);
const QString &key = grandChild->proFile();
proFilesWithTestSets.insert(key, proFilesWithTestSets[key] + 1);
proFilesWithInternalTargets.insert(key, grandChild->internalTargets());
proFilesWithInternalTargets[key].unite(grandChild->internalTargets());
}
}
QHash<QString, int>::ConstIterator it = proFilesWithTestSets.begin();
QHash<QString, int>::ConstIterator end = proFilesWithTestSets.end();
for ( ; it != end; ++it) {
GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCaseCount(it.value());
tc->setProjectFile(it.key());
tc->setProject(project);
tc->setInternalTargets(proFilesWithInternalTargets.value(it.key()));
result << tc;
const QSet<QString> &internalTargets = proFilesWithInternalTargets[it.key()];
for (const QString &target : internalTargets) {
GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCaseCount(it.value());
tc->setProjectFile(it.key());
tc->setProject(project);
tc->setInternalTarget(target);
result << tc;
}
}
return result;
......@@ -184,8 +187,8 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
auto &testCases = proFilesWithCheckedTestSets[child->childItem(0)->proFile()];
testCases.filters.append(gtestFilter(child->state()).arg(child->name()).arg('*'));
testCases.additionalTestCaseCount += grandChildCount - 1;
proFilesWithInternalTargets.insert(child->childItem(0)->proFile(),
child->internalTargets());
proFilesWithInternalTargets[child->childItem(0)->proFile()].unite(
child->internalTargets());
break;
}
case Qt::PartiallyChecked: {
......@@ -194,8 +197,8 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
if (grandChild->checked() == Qt::Checked) {
proFilesWithCheckedTestSets[grandChild->proFile()].filters.append(
gtestFilter(child->state()).arg(child->name()).arg(grandChild->name()));
proFilesWithInternalTargets.insert(grandChild->proFile(),
grandChild->internalTargets());
proFilesWithInternalTargets[grandChild->proFile()].unite(
grandChild->internalTargets());
}
}
break;
......@@ -206,13 +209,16 @@ QList<TestConfiguration *> GTestTreeItem::getSelectedTestConfigurations() const
QHash<QString, TestCases>::ConstIterator it = proFilesWithCheckedTestSets.begin();
QHash<QString, TestCases>::ConstIterator end = proFilesWithCheckedTestSets.end();
for ( ; it != end; ++it) {
GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCases(it.value().filters);
tc->setTestCaseCount(tc->testCaseCount() + it.value().additionalTestCaseCount);
tc->setProjectFile(it.key());
tc->setProject(project);
tc->setInternalTargets(proFilesWithInternalTargets[it.key()]);
result << tc;
const QSet<QString> &internalTargets = proFilesWithInternalTargets[it.key()];
for (const QString &target : internalTargets) {
GTestConfiguration *tc = new GTestConfiguration;
tc->setTestCases(it.value().filters);
tc->setTestCaseCount(tc->testCaseCount() + it.value().additionalTestCaseCount);
tc->setProjectFile(it.key());
tc->setProject(project);
tc->setInternalTarget(target);
result << tc;
}
}
return result;
......
......@@ -320,6 +320,12 @@ void TestConfiguration::setProject(Project *project)
m_project = project;
}
void TestConfiguration::setInternalTarget(const QString &target)
{
m_buildTargets.clear();
m_buildTargets.insert(target);
}
void TestConfiguration::setInternalTargets(const QSet<QString> &targets)
{
m_buildTargets = targets;
......
......@@ -67,6 +67,7 @@ public:
void setDisplayName(const QString &displayName);
void setEnvironment(const Utils::Environment &env);
void setProject(ProjectExplorer::Project *project);
void setInternalTarget(const QString &target);
void setInternalTargets(const QSet<QString> &targets);
void setOriginalRunConfiguration(ProjectExplorer::RunConfiguration *runConfig);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment