diff options
author | Christian Stenger <christian.stenger@qt.io> | 2016-05-04 16:53:58 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2016-05-04 15:42:29 +0000 |
commit | 500286cab77dbce5be9173c5e5ab74104da4cf01 (patch) | |
tree | a04a7d0d129fa2f9d87f5157ec75406c3154eed2 /src/plugins | |
parent | aac0086d1d80bd2073aea6f00c361f4fdc7ffdf9 (diff) | |
download | qt-creator-500286cab77dbce5be9173c5e5ab74104da4cf01.tar.gz |
AutoTest: Fix parsing of Qt tests when using developerbuild
Change-Id: I226884c10e8fea48d08892b4dab3793b9babc0e5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/autotest/testcodeparser.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/src/plugins/autotest/testcodeparser.cpp b/src/plugins/autotest/testcodeparser.cpp index e39400d2e9..31dd747389 100644 --- a/src/plugins/autotest/testcodeparser.cpp +++ b/src/plugins/autotest/testcodeparser.cpp @@ -177,20 +177,21 @@ static QByteArray getFileContent(QString filePath) static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, const CppTools::CppModelManager *cppMM) { - static QString expectedHeaderPrefix + static QStringList expectedHeaderPrefixes = Utils::HostOsInfo::isMacHost() - ? QLatin1String("QtTest.framework/Headers") - : QLatin1String("QtTest"); + ? QStringList({ QLatin1String("QtTest.framework/Headers"), QLatin1String("QtTest") }) + : QStringList({ QLatin1String("QtTest") }); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); foreach (const CPlusPlus::Document::Include &inc, includes) { // TODO this short cut works only for #include <QtTest> // bad, as there could be much more different approaches - if (inc.unresolvedFileName() == QLatin1String("QtTest") - && inc.resolvedFileName().endsWith( - QString::fromLatin1("%1/QtTest").arg(expectedHeaderPrefix))) { - return true; + if (inc.unresolvedFileName() == QLatin1String("QtTest")) { + foreach (const QString &prefix, expectedHeaderPrefixes) { + if (inc.resolvedFileName().endsWith(QString::fromLatin1("%1/QtTest").arg(prefix))) + return true; + } } } @@ -198,9 +199,9 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, CPlusPlus::Snapshot snapshot = cppMM->snapshot(); const QSet<QString> allIncludes = snapshot.allIncludesForDocument(doc->fileName()); foreach (const QString &include, allIncludes) { - - if (include.endsWith(QString::fromLatin1("%1/qtest.h").arg(expectedHeaderPrefix))) { - return true; + foreach (const QString &prefix, expectedHeaderPrefixes) { + if (include.endsWith(QString::fromLatin1("%1/qtest.h").arg(prefix))) + return true; } } } @@ -210,25 +211,31 @@ static bool includesQtTest(const CPlusPlus::Document::Ptr &doc, static bool includesQtQuickTest(const CPlusPlus::Document::Ptr &doc, const CppTools::CppModelManager *cppMM) { - static QString expectedHeaderPrefix + static QStringList expectedHeaderPrefixes = Utils::HostOsInfo::isMacHost() - ? QLatin1String("QtQuickTest.framework/Headers") - : QLatin1String("QtQuickTest"); + ? QStringList({ QLatin1String("QtQuickTest.framework/Headers"), + QLatin1String("QtQuickTest") }) + : QStringList({ QLatin1String("QtQuickTest") }); const QList<CPlusPlus::Document::Include> includes = doc->resolvedIncludes(); foreach (const CPlusPlus::Document::Include &inc, includes) { - if (inc.unresolvedFileName() == QLatin1String("QtQuickTest/quicktest.h") - && inc.resolvedFileName().endsWith( - QString::fromLatin1("%1/quicktest.h").arg(expectedHeaderPrefix))) { - return true; + if (inc.unresolvedFileName() == QLatin1String("QtQuickTest/quicktest.h")) { + foreach (const QString &prefix, expectedHeaderPrefixes) { + if (inc.resolvedFileName().endsWith( + QString::fromLatin1("%1/quicktest.h").arg(prefix))) { + return true; + } + } } } if (cppMM) { foreach (const QString &include, cppMM->snapshot().allIncludesForDocument(doc->fileName())) { - if (include.endsWith(QString::fromLatin1("%1/quicktest.h").arg(expectedHeaderPrefix))) - return true; + foreach (const QString &prefix, expectedHeaderPrefixes) { + if (include.endsWith(QString::fromLatin1("%1/quicktest.h").arg(prefix))) + return true; + } } } return false; |