diff options
author | Marco Bubke <marco.bubke@qt.io> | 2019-07-11 17:40:46 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2019-07-16 08:19:06 +0000 |
commit | ec3c7946af36e539375dc9c0e366d31dfe4ca2b5 (patch) | |
tree | f7c81b238712fd994addfa9d8caad3d5acfabbe7 | |
parent | 5af1f95f25c62123c83ed27cd644ab7ead8f65f1 (diff) |
UnitTests: Fix compile without Clang
I moved the clang depend code under the condition that it is only compiled
if LLVM is present.
Change-Id: If1e37f677464ff38833c81dbebdfe8eaa563cdde
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r-- | src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri | 8 | ||||
-rw-r--r-- | tests/unit/unittest/benchmark_dependency.pri | 2 | ||||
-rw-r--r-- | tests/unit/unittest/conditionally-disabled-tests.h | 3 | ||||
-rw-r--r-- | tests/unit/unittest/gtest-clang-printing.cpp | 57 | ||||
-rw-r--r-- | tests/unit/unittest/gtest-clang-printing.h | 16 | ||||
-rw-r--r-- | tests/unit/unittest/gtest-creator-printing.cpp | 60 | ||||
-rw-r--r-- | tests/unit/unittest/unittest.pro | 6 |
7 files changed, 81 insertions, 71 deletions
diff --git a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri index dd4e51028d..ce809e9efb 100644 --- a/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri +++ b/src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri @@ -2,7 +2,6 @@ INCLUDEPATH += $$PWD HEADERS += \ $$PWD/clangrefactoringbackend_global.h \ - $$PWD/filestatuspreprocessorcallbacks.h \ $$PWD/sourcerangefilter.h \ $$PWD/symbolindexer.h \ $$PWD/symbolentry.h \ @@ -14,10 +13,8 @@ HEADERS += \ $$PWD/symbolindexinginterface.h \ $$PWD/collectmacrospreprocessorcallbacks.h \ $$PWD/projectpartentry.h \ - $$PWD/symbolsvisitorbase.h \ $$PWD/usedmacro.h \ $$PWD/sourcedependency.h \ - $$PWD/indexdataconsumer.h \ $$PWD/sourcesmanager.h \ $$PWD/symbolindexertaskqueue.h \ $$PWD/symbolindexertaskqueueinterface.h \ @@ -35,6 +32,7 @@ SOURCES += \ $$PWD/collectsymbolsaction.cpp \ $$PWD/collectmacrossourcefilecallbacks.cpp \ $$PWD/symbolscollector.cpp \ + $$PWD/filestatuspreprocessorcallbacks.cpp \ $$PWD/clangquerygatherer.cpp \ $$PWD/symbolindexing.cpp \ $$PWD/indexdataconsumer.cpp @@ -51,10 +49,12 @@ HEADERS += \ $$PWD/collectsymbolsaction.h \ $$PWD/collectmacrossourcefilecallbacks.h \ $$PWD/symbolscollector.h \ + $$PWD/symbolsvisitorbase.h \ + $$PWD/indexdataconsumer.h \ + $$PWD/filestatuspreprocessorcallbacks.h \ $$PWD/clangquerygatherer.h } SOURCES += \ - $$PWD/filestatuspreprocessorcallbacks.cpp \ $$PWD/sourcerangefilter.cpp \ $$PWD/symbolindexer.cpp diff --git a/tests/unit/unittest/benchmark_dependency.pri b/tests/unit/unittest/benchmark_dependency.pri index dd17215e67..e9e0408530 100644 --- a/tests/unit/unittest/benchmark_dependency.pri +++ b/tests/unit/unittest/benchmark_dependency.pri @@ -1,6 +1,6 @@ GOOGLEBENCHMARK_DIR = $$(GOOGLEBENCHMARK_DIR) -exists($$GOOGLEBENCHMARK_DIR) { +!isEmpty(GOOGLEBENCHMARK_DIR):exists($$GOOGLEBENCHMARK_DIR) { INCLUDEPATH += $$GOOGLEBENCHMARK_DIR/include DEFINES += HAVE_STD_REGEX WITH_BENCHMARKS diff --git a/tests/unit/unittest/conditionally-disabled-tests.h b/tests/unit/unittest/conditionally-disabled-tests.h index c88a844b96..128520a881 100644 --- a/tests/unit/unittest/conditionally-disabled-tests.h +++ b/tests/unit/unittest/conditionally-disabled-tests.h @@ -24,9 +24,6 @@ ****************************************************************************/ #include <QtGlobal> -#include <clang-c/Index.h> - -#include <clangbackend_global.h> #ifdef Q_OS_WIN # define DISABLED_ON_WINDOWS(x) DISABLED_##x diff --git a/tests/unit/unittest/gtest-clang-printing.cpp b/tests/unit/unittest/gtest-clang-printing.cpp index d6299f1057..4c10958f52 100644 --- a/tests/unit/unittest/gtest-clang-printing.cpp +++ b/tests/unit/unittest/gtest-clang-printing.cpp @@ -23,9 +23,17 @@ ** ****************************************************************************/ +#include "gtest-creator-printing.h" + #ifdef CLANG_UNIT_TESTS #include <clang/Basic/SourceLocation.h> #include <clang/Basic/SourceManager.h> + +#include <clangdocumentsuspenderresumer.h> +#include <clangreferencescollector.h> +#include <fulltokeninfo.h> +#include <tokenprocessor.h> + #endif #include <gtest/gtest-printers.h> @@ -77,3 +85,52 @@ void PrintTo(const SourceRange &sourceRange, ::std::ostream *os) } } + +namespace ClangBackEnd { +std::ostream &operator<<(std::ostream &os, const TokenInfo &tokenInfo) +{ + os << "(type: " << tokenInfo.types() << ", " + << " line: " << tokenInfo.line() << ", " + << " column: " << tokenInfo.column() << ", " + << " length: " << tokenInfo.length() << ")"; + + return os; +} + +template<class T> +std::ostream &operator<<(std::ostream &out, const TokenProcessor<T> &tokenInfos) +{ + out << "["; + + for (const T &entry : tokenInfos) + out << entry; + + out << "]"; + + return out; +} + +template std::ostream &operator<<(std::ostream &out, const TokenProcessor<TokenInfo> &tokenInfos); +template std::ostream &operator<<(std::ostream &out, const TokenProcessor<FullTokenInfo> &tokenInfos); + +std::ostream &operator<<(std::ostream &out, const SuspendResumeJobsEntry &entry) +{ + return out << "(" << entry.document.filePath() << ", " << entry.jobRequestType << ", " + << entry.preferredTranslationUnit << ")"; +} + +std::ostream &operator<<(std::ostream &os, const ReferencesResult &value) +{ + os << "ReferencesResult("; + os << value.isLocalVariable << ", {"; + for (const SourceRangeContainer &r : value.references) { + os << r.start.line << ","; + os << r.start.column << ","; + os << r.end.column - r.start.column << ","; + } + os << "})"; + + return os; +} + +} // namespace ClangBackEnd diff --git a/tests/unit/unittest/gtest-clang-printing.h b/tests/unit/unittest/gtest-clang-printing.h index 7ed5a8b960..b0c0a93afb 100644 --- a/tests/unit/unittest/gtest-clang-printing.h +++ b/tests/unit/unittest/gtest-clang-printing.h @@ -27,6 +27,8 @@ #include <iosfwd> +#include <gtest/gtest-printers.h> + namespace llvm { class StringRef; @@ -48,3 +50,17 @@ namespace TestGlobal { void setSourceManager(const clang::SourceManager *sourceManager); } +namespace ClangBackEnd { +class TokenInfo; +template<typename T> +class TokenProcessor; +class SuspendResumeJobsEntry; +class ReferencesResult; + +std::ostream &operator<<(std::ostream &os, const TokenInfo &tokenInfo); +template<class T> +std::ostream &operator<<(std::ostream &out, const TokenProcessor<T> &tokenInfos); +std::ostream &operator<<(std::ostream &out, const SuspendResumeJobsEntry &entry); +std::ostream &operator<<(std::ostream &os, const ReferencesResult &value); + +} // namespace ClangBackEnd diff --git a/tests/unit/unittest/gtest-creator-printing.cpp b/tests/unit/unittest/gtest-creator-printing.cpp index 773a632142..141a926d9e 100644 --- a/tests/unit/unittest/gtest-creator-printing.cpp +++ b/tests/unit/unittest/gtest-creator-printing.cpp @@ -35,15 +35,12 @@ #include <builddependency.h> #include <clangcodemodelclientmessages.h> #include <clangcodemodelservermessages.h> -#include <clangdocumentsuspenderresumer.h> #include <clangpathwatcher.h> #include <clangrefactoringmessages.h> -#include <clangreferencescollector.h> #include <filepath.h> #include <filepathcaching.h> #include <filepathview.h> #include <filestatus.h> -#include <fulltokeninfo.h> #include <includesearchpath.h> #include <nativefilepath.h> #include <pchpaths.h> @@ -58,16 +55,12 @@ #include <symbol.h> #include <symbolentry.h> #include <symbolindexertaskqueue.h> -#include <tokenprocessor.h> #include <toolchainargumentscache.h> #include <tooltipinfo.h> #include <usedmacro.h> - #include <cpptools/usages.h> - #include <projectexplorer/projectmacro.h> #include <projectexplorer/headerpath.h> - #include <coreplugin/find/searchresultitem.h> #include <coreplugin/locator/ilocatorfilter.h> @@ -924,35 +917,6 @@ std::ostream &operator<<(std::ostream &os, const DocumentVisibilityChangedMessag return os; } -std::ostream &operator<<(std::ostream &os, const TokenInfo &tokenInfo) -{ - os << "(type: " << tokenInfo.types() << ", " - << " line: " << tokenInfo.line() << ", " - << " column: " << tokenInfo.column() << ", " - << " length: " << tokenInfo.length() - << ")"; - - return os; -} - -template<class T> -std::ostream &operator<<(std::ostream &out, const TokenProcessor<T> &tokenInfos) -{ - out << "["; - - for (const T &entry : tokenInfos) - out << entry; - - out << "]"; - - return out; -} - -template -std::ostream &operator<<(std::ostream &out, const TokenProcessor<TokenInfo> &tokenInfos); -template -std::ostream &operator<<(std::ostream &out, const TokenProcessor<FullTokenInfo> &tokenInfos); - std::ostream &operator<<(std::ostream &out, const FilePath &filePath) { return out << "(" << filePath.path() << ", " << filePath.slashIndex() << ")"; @@ -1078,30 +1042,6 @@ std::ostream &operator<<(std::ostream &out, const RemoveGeneratedFilesMessage &m return out << "(" << message.generatedFiles << ")"; } -std::ostream &operator<<(std::ostream &out, const SuspendResumeJobsEntry &entry) -{ - return out << "(" - << entry.document.filePath() << ", " - << entry.jobRequestType << ", " - << entry.preferredTranslationUnit - << ")"; -} - -std::ostream &operator<<(std::ostream &os, const ReferencesResult &value) -{ - os << "ReferencesResult("; - os << value.isLocalVariable << ", {"; - for (const SourceRangeContainer &r : value.references) { - os << r.start.line << ","; - os << r.start.column << ","; - EXPECT_THAT(r.start.line, testing::Eq(r.end.line)); - os << r.end.column - r.start.column << ","; - } - os << "})"; - - return os; -} - std::ostream &operator<<(std::ostream &out, const SymbolIndexerTask &task) { return out << "(" << task.filePathId << ", " << task.projectPartId << ")"; diff --git a/tests/unit/unittest/unittest.pro b/tests/unit/unittest/unittest.pro index c64d22925b..bcd1bae2b0 100644 --- a/tests/unit/unittest/unittest.pro +++ b/tests/unit/unittest/unittest.pro @@ -97,10 +97,8 @@ SOURCES += \ nativefilepath-test.cpp \ nativefilepathview-test.cpp \ mocktimer.cpp \ - tokenprocessor-test.cpp \ projectpartartefact-test.cpp \ filestatuscache-test.cpp \ - highlightingresultreporter-test.cpp \ precompiledheaderstorage-test.cpp \ generatedfiles-test.cpp \ sourcesmanager-test.cpp \ @@ -163,6 +161,7 @@ SOURCES += \ diagnosticset-test.cpp \ diagnostic-test.cpp \ fixit-test.cpp \ + highlightingresultreporter-test.cpp \ senddocumenttracker-test.cpp \ skippedsourceranges-test.cpp \ sourcelocation-test.cpp \ @@ -174,6 +173,7 @@ SOURCES += \ sqlitetable-test.cpp \ sqlstatementbuilder-test.cpp \ token-test.cpp \ + tokenprocessor-test.cpp \ translationunitupdater-test.cpp \ unsavedfiles-test.cpp \ unsavedfile-test.cpp \ @@ -205,7 +205,7 @@ SOURCES += \ SOURCES += clangformat-test.cpp } -exists($$GOOGLEBENCHMARK_DIR) { +!isEmpty(GOOGLEBENCHMARK_DIR):exists($$GOOGLEBENCHMARK_DIR) { SOURCES += \ smallstring-benchmark.cpp } |