Clang: Fix release build

* The QtTest include is not available in release builds.
* Make the batch file mode only available in debug/test builds as that
  one uses test utilities that are only available in debug builds.

Change-Id: I441c51ec00b14b81a396ad0199882cf46fff10b0
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-02-27 16:08:04 +01:00
parent 69ec8054a6
commit d1133916a9
4 changed files with 13 additions and 11 deletions

View File

@@ -54,7 +54,7 @@
#include <QLoggingCategory>
#include <QSharedPointer>
#include <QString>
#include <QtTest>
#include <QThread>
using namespace ClangBackEnd;
using namespace ClangCodeModel;

View File

@@ -9,9 +9,7 @@ SOURCES += \
clangassistproposal.cpp \
clangassistproposalitem.cpp \
clangassistproposalmodel.cpp \
clangautomationutils.cpp \
clangbackendipcintegration.cpp \
clangbatchfileprocessor.cpp \
clangcodemodelplugin.cpp \
clangcompletionassistinterface.cpp \
clangcompletionassistprocessor.cpp \
@@ -41,9 +39,7 @@ HEADERS += \
clangassistproposal.h \
clangassistproposalitem.h \
clangassistproposalmodel.h \
clangautomationutils.h \
clangbackendipcintegration.h \
clangbatchfileprocessor.h \
clangcodemodelplugin.h \
clangcompletionassistinterface.h \
clangcompletionassistprocessor.h \
@@ -80,10 +76,14 @@ DISTFILES += \
equals(TEST, 1) {
HEADERS += \
test/clangcodecompletion_test.h
test/clangautomationutils.h \
test/clangbatchfileprocessor.h \
test/clangcodecompletion_test.h \
SOURCES += \
test/clangcodecompletion_test.cpp
test/clangautomationutils.cpp \
test/clangbatchfileprocessor.cpp \
test/clangcodecompletion_test.cpp \
RESOURCES += test/data/clangtestdata.qrc
OTHER_FILES += $$files(test/data/*)

View File

@@ -41,12 +41,8 @@ QtcPlugin {
"clangassistproposalitem.h",
"clangassistproposalmodel.cpp",
"clangassistproposalmodel.h",
"clangautomationutils.cpp",
"clangautomationutils.h",
"clangbackendipcintegration.cpp",
"clangbackendipcintegration.h",
"clangbatchfileprocessor.cpp",
"clangbatchfileprocessor.h",
"clangcodemodel.qrc",
"clangcodemodelplugin.cpp",
"clangcodemodelplugin.h",
@@ -102,6 +98,10 @@ QtcPlugin {
condition: qtc.testsEnabled
prefix: "test/"
files: [
"clangautomationutils.cpp",
"clangautomationutils.h",
"clangbatchfileprocessor.cpp",
"clangbatchfileprocessor.h",
"clangcodecompletion_test.cpp",
"clangcodecompletion_test.h",
"data/clangtestdata.qrc",

View File

@@ -98,11 +98,13 @@ void ClangCodeModelPlugin::extensionsInitialized()
// For e.g. creation of profile-guided optimization builds.
void ClangCodeModelPlugin::maybeHandleBatchFileAndExit() const
{
#ifdef WITH_TESTS
const QString batchFilePath = QString::fromLocal8Bit(qgetenv("QTC_CLANG_BATCH"));
if (!batchFilePath.isEmpty() && QTC_GUARD(QFileInfo::exists(batchFilePath))) {
const bool runSucceeded = runClangBatchFile(batchFilePath);
QCoreApplication::exit(!runSucceeded);
}
#endif
}
#ifdef WITH_TESTS