UnitTest: Break the dependency to LLVM

If you have no LLVM installed it was impossible to compile the unit test.
But some unit test don't depend on LLVM. With this change it is now
possible to compile them.

Change-Id: Iac0c1b3cdf6c317e6ba4755acd5f8458db5a7451
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marco Bubke
2016-08-17 14:18:55 +02:00
parent d23c4985cb
commit 68aeff4b9f
6 changed files with 62 additions and 36 deletions

View File

@@ -1,5 +1,8 @@
!isEmpty(LLVM_INSTALL_DIR) {
include(../../../src/shared/clang/clang_installation.pri) include(../../../src/shared/clang/clang_installation.pri)
requires(!isEmpty(LIBCLANG_LIBS)) requires(!isEmpty(LIBCLANG_LIBS))
DEFINES += CLANG_UNIT_TESTS
INCLUDEPATH += $$LLVM_INCLUDEPATH INCLUDEPATH += $$LLVM_INCLUDEPATH
LIBS += $$LIBTOOLING_LIBS $$LIBCLANG_LIBS LIBS += $$LIBTOOLING_LIBS $$LIBCLANG_LIBS
}

View File

@@ -1,4 +1,3 @@
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
include($$PWD/../../../src/libs/utils/utils-lib.pri)
include($$PWD/../../../src/libs/cplusplus/cplusplus-lib.pri) include($$PWD/../../../src/libs/cplusplus/cplusplus-lib.pri)

View File

@@ -1,18 +1,23 @@
include(../../../src/libs/sqlite/sqlite-lib.pri) include($$PWD/../../../src/libs/utils/utils-lib.pri)
include(../../../src/libs/clangbackendipc/clangbackendipc-lib.pri) include($$PWD/../../../src/libs/sqlite/sqlite-lib.pri)
include(../../../src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri) include($$PWD/../../../src/libs/clangbackendipc/clangbackendipc-lib.pri)
include(../../../src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri) include($$PWD/../../../src/plugins/coreplugin/corepluginunittestfiles.pri)
include(../../../src/plugins/coreplugin/corepluginunittestfiles.pri)
include(../../../src/plugins/clangcodemodel/clangcodemodelunittestfiles.pri) !isEmpty(LLVM_INSTALL_DIR) {
include(../../../src/plugins/cpptools/cpptoolsunittestfiles.pri) include($$PWD/../../../src/tools/clangbackend/ipcsource/clangbackendclangipc-source.pri)
include(../../../src/plugins/clangrefactoring/clangrefactoring-source.pri) include($$PWD/../../../src/tools/clangrefactoringbackend/source/clangrefactoringbackend-source.pri)
include($$PWD/../../../src/plugins/clangcodemodel/clangcodemodelunittestfiles.pri)
include($$PWD/../../../src/plugins/cpptools/cpptoolsunittestfiles.pri)
include($$PWD/../../../src/plugins/clangrefactoring/clangrefactoring-source.pri)
include(cplusplus.pri) include(cplusplus.pri)
DEFINES += CLANG_VERSION=\\\"$${LLVM_VERSION}\\\"
DEFINES += "\"CLANG_RESOURCE_DIR=\\\"$${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include\\\"\""
}
DEFINES += QTC_REL_TOOLS_PATH=$$shell_quote(\"$$relative_path($$IDE_LIBEXEC_PATH, $$IDE_BIN_PATH)\")
INCLUDEPATH += \ INCLUDEPATH += \
$$PWD/../../../src/libs \ $$PWD/../../../src/libs \
$$PWD/../../../src/libs/3rdparty \ $$PWD/../../../src/libs/3rdparty \
$$PWD/../../../src/plugins $$PWD/../../../src/plugins
DEFINES += QTC_REL_TOOLS_PATH=$$shell_quote(\"$$relative_path($$IDE_LIBEXEC_PATH, $$IDE_BIN_PATH)\")
DEFINES += CLANG_VERSION=\\\"$${LLVM_VERSION}\\\"
DEFINES += "\"CLANG_RESOURCE_DIR=\\\"$${LLVM_LIBDIR}/clang/$${LLVM_VERSION}/include\\\"\""

View File

@@ -31,8 +31,10 @@
#pragma GCC diagnostic ignored "-Wunused-parameter" #pragma GCC diagnostic ignored "-Wunused-parameter"
#endif #endif
#ifdef CLANG_UNIT_TESTS
#include <clang/Basic/SourceLocation.h> #include <clang/Basic/SourceLocation.h>
#include <clang/Basic/SourceManager.h> #include <clang/Basic/SourceManager.h>
#endif
#if defined(__GNUC__) #if defined(__GNUC__)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
@@ -64,6 +66,7 @@ inline void PrintTo(const QString &text, ::std::ostream *os)
QT_END_NAMESPACE QT_END_NAMESPACE
#ifdef CLANG_UNIT_TESTS
namespace clang { namespace clang {
inline void PrintTo(const clang::FullSourceLoc &sourceLocation, ::std::ostream *os) inline void PrintTo(const clang::FullSourceLoc &sourceLocation, ::std::ostream *os)
@@ -78,6 +81,7 @@ inline void PrintTo(const clang::FullSourceLoc &sourceLocation, ::std::ostream *
} }
} }
#endif
//namespace testing { //namespace testing {
//namespace internal { //namespace internal {

View File

@@ -35,7 +35,6 @@
#include <messageenvelop.h> #include <messageenvelop.h>
#include <requestdocumentannotations.h> #include <requestdocumentannotations.h>
#include <readmessageblock.h> #include <readmessageblock.h>
#include <sourcelocation.h>
#include <registerunsavedfilesforeditormessage.h> #include <registerunsavedfilesforeditormessage.h>
#include <unregisterunsavedfilesforeditormessage.h> #include <unregisterunsavedfilesforeditormessage.h>
#include <updatetranslationunitsforeditormessage.h> #include <updatetranslationunitsforeditormessage.h>

View File

@@ -24,6 +24,19 @@ msvc: QMAKE_CXXFLAGS_WARN_ON -= -w34100 # 'unreferenced formal parameter' in MAT
win32:DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echo)xxx\\\"\" win32:DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echo)xxx\\\"\"
unix: DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echoserver/echo)xxx\\\"\" unix: DEFINES += ECHOSERVER=\"R\\\"xxx($$OUT_PWD/../echoserver/echo)xxx\\\"\"
SOURCES += \
clientserverinprocesstest.cpp \
clientserveroutsideprocess.cpp \
lineprefixertest.cpp \
main.cpp \
readandwritemessageblocktest.cpp \
sizedarraytest.cpp \
spydummy.cpp \
smallstringtest.cpp \
testutils.cpp \
utf8test.cpp
!isEmpty($$LIBCLANG_LIBS) {
SOURCES += \ SOURCES += \
activationsequencecontextprocessortest.cpp \ activationsequencecontextprocessortest.cpp \
activationsequenceprocessortest.cpp \ activationsequenceprocessortest.cpp \
@@ -33,8 +46,6 @@ SOURCES += \
clangfixitoperationtest.cpp \ clangfixitoperationtest.cpp \
clangipcservertest.cpp \ clangipcservertest.cpp \
clangstringtest.cpp \ clangstringtest.cpp \
clientserverinprocesstest.cpp \
clientserveroutsideprocess.cpp \
codecompletionsextractortest.cpp \ codecompletionsextractortest.cpp \
codecompletiontest.cpp \ codecompletiontest.cpp \
completionchunkstotextconvertertest.cpp \ completionchunkstotextconvertertest.cpp \
@@ -42,13 +53,9 @@ SOURCES += \
diagnosticsettest.cpp \ diagnosticsettest.cpp \
diagnostictest.cpp \ diagnostictest.cpp \
fixittest.cpp \ fixittest.cpp \
lineprefixertest.cpp \
main.cpp \
projecttest.cpp \ projecttest.cpp \
readandwritemessageblocktest.cpp \
sourcelocationtest.cpp \ sourcelocationtest.cpp \
sourcerangetest.cpp \ sourcerangetest.cpp \
spydummy.cpp \
sqlitecolumntest.cpp \ sqlitecolumntest.cpp \
sqlitedatabasebackendtest.cpp \ sqlitedatabasebackendtest.cpp \
sqlitedatabasetest.cpp \ sqlitedatabasetest.cpp \
@@ -58,7 +65,6 @@ SOURCES += \
translationunitstest.cpp \ translationunitstest.cpp \
translationunittest.cpp \ translationunittest.cpp \
unsavedfilestest.cpp \ unsavedfilestest.cpp \
utf8test.cpp \
senddocumenttrackertest.cpp \ senddocumenttrackertest.cpp \
cursortest.cpp \ cursortest.cpp \
skippedsourcerangestest.cpp \ skippedsourcerangestest.cpp \
@@ -66,25 +72,27 @@ SOURCES += \
chunksreportedmonitor.cpp \ chunksreportedmonitor.cpp \
unsavedfiletest.cpp \ unsavedfiletest.cpp \
clangisdiagnosticrelatedtolocationtest.cpp \ clangisdiagnosticrelatedtolocationtest.cpp \
smallstringtest.cpp \
highlightingmarkstest.cpp \ highlightingmarkstest.cpp \
sizedarraytest.cpp \
utf8positionfromlinecolumntest.cpp \ utf8positionfromlinecolumntest.cpp \
translationunitupdatertest.cpp \ translationunitupdatertest.cpp \
testutils.cpp \
clangasyncjobtest.cpp \ clangasyncjobtest.cpp \
clangcompletecodejobtest.cpp \ clangcompletecodejobtest.cpp \
clangcreateinitialdocumentpreamblejobtest.cpp \ clangcreateinitialdocumentpreamblejobtest.cpp \
clangjobqueuetest.cpp \ clangjobqueuetest.cpp \
refactoringcompilationdatabasetest.cpp \
symbolfindertest.cpp \
refactoringclientserverinprocesstest.cpp \
refactoringservertest.cpp \
refactoringenginetest.cpp \
refactoringclienttest.cpp \
clangjobstest.cpp \ clangjobstest.cpp \
clangrequestdocumentannotationsjobtest.cpp \ clangrequestdocumentannotationsjobtest.cpp \
clangupdatedocumentannotationsjobtest.cpp clangupdatedocumentannotationsjobtest.cpp
}
!isEmpty($$LIBTOOLING_LIBS) {
SOURCES += \
refactoringclientserverinprocesstest.cpp \
refactoringcompilationdatabasetest.cpp \
refactoringservertest.cpp \
refactoringenginetest.cpp \
refactoringclienttest.cpp \
symbolfindertest.cpp
}
exists($$GOOGLEBENCHMARK_DIR) { exists($$GOOGLEBENCHMARK_DIR) {
SOURCES += \ SOURCES += \
@@ -93,17 +101,25 @@ SOURCES += \
HEADERS += \ HEADERS += \
gtest-qt-printing.h \ gtest-qt-printing.h \
spydummy.h \
dummyclangipcclient.h \
testutils.h \
mockclangcodemodelclient.h \ mockclangcodemodelclient.h \
mockclangcodemodelserver.h \ mockclangcodemodelserver.h \
mockrefactoringclient.h \ mockrefactoringclient.h \
mockrefactoringserver.h \ mockrefactoringserver.h \
spydummy.h \ refactoringclientcallbackmock.h
dummyclangipcclient.h \
matcher-diagnosticcontainer.h \ !isEmpty($$LIBCLANG_LIBS) {
chunksreportedmonitor.h \ HEADERS += \
testutils.h \
clangasyncjobtest.h \ clangasyncjobtest.h \
refactoringclientcallbackmock.h \ chunksreportedmonitor.h \
matcher-diagnosticcontainer.h
}
!isEmpty($$LIBTOOLING_LIBS) {
HEADERS += \
filesystemutilities.h filesystemutilities.h
}
OTHER_FILES += $$files(data/*) OTHER_FILES += $$files(data/*)