summaryrefslogtreecommitdiff
path: root/src/plugins/cpptools/cpptoolsplugin.cpp
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2017-09-13 10:32:39 +0200
committerChristian Stenger <christian.stenger@qt.io>2017-09-26 07:00:48 +0000
commit3c602b32d4914768465e0b226b2f996081333e08 (patch)
tree3780018f7b34f42e12394ee6015577bfa641762c /src/plugins/cpptools/cpptoolsplugin.cpp
parentfb063a09bea0046c7ac72b9fc4d8fb563cfed06d (diff)
downloadqt-creator-3c602b32d4914768465e0b226b2f996081333e08.tar.gz
AutoTest: Try harder to find relevant build targets
If there are tests defined or registered inside libraries we ended up trying to execute the library or nothing at all. If possible try to find correct build targets for such cases. Change-Id: I58e9edb7f858e3e5407ece6fcb8782f5a129acd0 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'src/plugins/cpptools/cpptoolsplugin.cpp')
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp
index d0dfec3a56..af192cb082 100644
--- a/src/plugins/cpptools/cpptoolsplugin.cpp
+++ b/src/plugins/cpptools/cpptoolsplugin.cpp
@@ -357,7 +357,8 @@ static int commonFilePathLength(const QString &s1, const QString &s2)
static QString correspondingHeaderOrSourceInProject(const QFileInfo &fileInfo,
const QStringList &candidateFileNames,
- const ProjectExplorer::Project *project)
+ const ProjectExplorer::Project *project,
+ CacheUsage cacheUsage)
{
QString bestFileName;
int compareValue = 0;
@@ -376,8 +377,10 @@ static QString correspondingHeaderOrSourceInProject(const QFileInfo &fileInfo,
if (!bestFileName.isEmpty()) {
const QFileInfo candidateFi(bestFileName);
QTC_ASSERT(candidateFi.isFile(), return QString());
- m_headerSourceMapping[fileInfo.absoluteFilePath()] = candidateFi.absoluteFilePath();
- m_headerSourceMapping[candidateFi.absoluteFilePath()] = fileInfo.absoluteFilePath();
+ if (cacheUsage == CacheUsage::ReadWrite) {
+ m_headerSourceMapping[fileInfo.absoluteFilePath()] = candidateFi.absoluteFilePath();
+ m_headerSourceMapping[candidateFi.absoluteFilePath()] = fileInfo.absoluteFilePath();
+ }
return candidateFi.absoluteFilePath();
}
@@ -386,7 +389,7 @@ static QString correspondingHeaderOrSourceInProject(const QFileInfo &fileInfo,
} // namespace Internal
-QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
+QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader, CacheUsage cacheUsage)
{
using namespace Internal;
@@ -437,9 +440,11 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
const QString normalized = Utils::FileUtils::normalizePathName(candidateFilePath);
const QFileInfo candidateFi(normalized);
if (candidateFi.isFile()) {
- m_headerSourceMapping[fi.absoluteFilePath()] = candidateFi.absoluteFilePath();
- if (!isHeader || !baseName.endsWith(privateHeaderSuffix))
- m_headerSourceMapping[candidateFi.absoluteFilePath()] = fi.absoluteFilePath();
+ if (cacheUsage == CacheUsage::ReadWrite) {
+ m_headerSourceMapping[fi.absoluteFilePath()] = candidateFi.absoluteFilePath();
+ if (!isHeader || !baseName.endsWith(privateHeaderSuffix))
+ m_headerSourceMapping[candidateFi.absoluteFilePath()] = fi.absoluteFilePath();
+ }
return candidateFi.absoluteFilePath();
}
}
@@ -449,7 +454,7 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectTree::currentProject();
if (currentProject) {
const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames,
- currentProject);
+ currentProject, cacheUsage);
if (!path.isEmpty())
return path;
@@ -462,7 +467,8 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
if (project == currentProject)
continue; // We have already checked the current project.
- const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames, project);
+ const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames,
+ project, cacheUsage);
if (!path.isEmpty())
return path;
}