forked from qt-creator/qt-creator
CompilationDatabaseProjectManager: Move tests to plugin
Change-Id: Ife4ee68cdbd1560830f294610f8fab40653a4f5b Reviewed-by: Christian Stenger <christian.stenger@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
committed by
Christian Stenger
parent
1e912f7318
commit
da588b7cc4
@@ -25,6 +25,8 @@
|
||||
|
||||
#include "compilationdatabasetests.h"
|
||||
|
||||
#include "compilationdatabaseutils.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <cpptools/cpptoolstestcase.h>
|
||||
#include <cpptools/projectinfo.h>
|
||||
@@ -37,9 +39,11 @@
|
||||
|
||||
#include <QtTest>
|
||||
|
||||
using namespace CppTools;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace CompilationDatabaseProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
CompilationDatabaseTests::CompilationDatabaseTests(QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -54,7 +58,7 @@ void CompilationDatabaseTests::initTestCase()
|
||||
QSKIP("This test requires at least one kit to be present.");
|
||||
|
||||
ToolChain *toolchain = ToolChainManager::toolChain([](const ToolChain *tc) {
|
||||
return tc->isValid() && tc->language() == Constants::CXX_LANGUAGE_ID;
|
||||
return tc->isValid() && tc->language() == ProjectExplorer::Constants::CXX_LANGUAGE_ID;
|
||||
});
|
||||
if (!toolchain)
|
||||
QSKIP("This test requires that there is at least one C++ toolchain present.");
|
||||
@@ -95,6 +99,186 @@ void CompilationDatabaseTests::testProject_data()
|
||||
addTestRow("llvm/compile_commands.json");
|
||||
}
|
||||
|
||||
namespace {
|
||||
class CompilationDatabaseUtilsTestData
|
||||
{
|
||||
public:
|
||||
QStringList getSplitCommandLine(const QString &commandLine)
|
||||
{
|
||||
QSet<QString> fc;
|
||||
return splitCommandLine(commandLine, fc);
|
||||
}
|
||||
|
||||
QStringList getFilteredFlags()
|
||||
{
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind, sysRoot);
|
||||
return flags;
|
||||
}
|
||||
|
||||
HeaderPaths headerPaths;
|
||||
Macros macros;
|
||||
CppTools::ProjectFile::Kind fileKind = CppTools::ProjectFile::Unclassified;
|
||||
QStringList flags;
|
||||
QString fileName;
|
||||
QString workingDir;
|
||||
QString sysRoot;
|
||||
};
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::testFilterEmptyFlags()
|
||||
{
|
||||
QVERIFY(CompilationDatabaseUtilsTestData().getFilteredFlags().isEmpty());
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::testFilterFromFilename()
|
||||
{
|
||||
QCOMPARE(filterFromFileName(QStringList{"-o", "foo.o"}, "foo"), QStringList{"-o"});
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::testFilterArguments()
|
||||
{
|
||||
using Utils::HostOsInfo;
|
||||
const char winPath1[] = "C:\\Qt\\5.9.2\\mingw53_32\\include";
|
||||
const char otherPath1[] = "/Qt/5.9.2/mingw53_32/include";
|
||||
const char winPath2[] = "C:\\Qt\\5.9.2\\mingw53_32\\include\\QtWidgets";
|
||||
const char otherPath2[] = "/Qt/5.9.2/mingw53_32/include/QtWidgets";
|
||||
CompilationDatabaseUtilsTestData testData;
|
||||
testData.fileName = "compileroptionsbuilder.cpp";
|
||||
testData.workingDir = "C:/build-qtcreator-MinGW_32bit-Debug";
|
||||
testData.flags = filterFromFileName(
|
||||
QStringList{"clang++",
|
||||
"-c",
|
||||
"-m32",
|
||||
"-target",
|
||||
"i686-w64-mingw32",
|
||||
"-std=gnu++14",
|
||||
"-fcxx-exceptions",
|
||||
"-fexceptions",
|
||||
"-DUNICODE",
|
||||
"-DRELATIVE_PLUGIN_PATH=\"../lib/qtcreator/plugins\"",
|
||||
"-DQT_CREATOR",
|
||||
"-I",
|
||||
QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
|
||||
"-I",
|
||||
QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2),
|
||||
"-x",
|
||||
"c++",
|
||||
QString("--sysroot=") + (HostOsInfo::isWindowsHost()
|
||||
? "C:\\sysroot\\embedded" : "/opt/sysroot/embedded"),
|
||||
"C:\\qt-creator\\src\\plugins\\cpptools\\compileroptionsbuilder.cpp"},
|
||||
"compileroptionsbuilder");
|
||||
|
||||
testData.getFilteredFlags();
|
||||
|
||||
QCOMPARE(testData.flags, (QStringList{"-m32", "-target", "i686-w64-mingw32", "-std=gnu++14",
|
||||
"-fcxx-exceptions", "-fexceptions"}));
|
||||
QCOMPARE(testData.headerPaths,
|
||||
(HeaderPaths{{QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
|
||||
HeaderPathType::User},
|
||||
{QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2),
|
||||
HeaderPathType::User}}));
|
||||
QCOMPARE(testData.macros, (Macros{{"UNICODE", "1"},
|
||||
{"RELATIVE_PLUGIN_PATH", "\"../lib/qtcreator/plugins\""},
|
||||
{"QT_CREATOR", "1"}}));
|
||||
QCOMPARE(testData.fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
||||
QCOMPARE(testData.sysRoot, HostOsInfo::isWindowsHost() ? QString("C:\\sysroot\\embedded")
|
||||
: QString("/opt/sysroot/embedded"));
|
||||
}
|
||||
|
||||
static QString kCmakeCommand
|
||||
= "C:\\PROGRA~2\\MICROS~2\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1415~1.267\\bin\\HostX64\\x64\\cl."
|
||||
"exe "
|
||||
"/nologo "
|
||||
"/TP "
|
||||
"-DUNICODE "
|
||||
"-D_HAS_EXCEPTIONS=0 "
|
||||
"-Itools\\clang\\lib\\Sema "
|
||||
"/DWIN32 "
|
||||
"/D_WINDOWS "
|
||||
"/Zc:inline "
|
||||
"/Zc:strictStrings "
|
||||
"/Oi "
|
||||
"/Zc:rvalueCast "
|
||||
"/W4 "
|
||||
"-wd4141 "
|
||||
"-wd4146 "
|
||||
"/MDd "
|
||||
"/Zi "
|
||||
"/Ob0 "
|
||||
"/Od "
|
||||
"/RTC1 "
|
||||
"/EHs-c- "
|
||||
"/GR "
|
||||
"/Fotools\\clang\\lib\\Sema\\CMakeFiles\\clangSema.dir\\SemaCodeComplete.cpp.obj "
|
||||
"/FdTARGET_COMPILE_PDB "
|
||||
"/FS "
|
||||
"-c "
|
||||
"C:\\qt_llvm\\tools\\clang\\lib\\Sema\\SemaCodeComplete.cpp";
|
||||
|
||||
void CompilationDatabaseTests::testSplitFlags()
|
||||
{
|
||||
CompilationDatabaseUtilsTestData testData;
|
||||
testData.flags = testData.getSplitCommandLine(kCmakeCommand);
|
||||
|
||||
QCOMPARE(testData.flags.size(), 27);
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::testSplitFlagsWithEscapedQuotes()
|
||||
{
|
||||
CompilationDatabaseUtilsTestData testData;
|
||||
testData.flags = testData.getSplitCommandLine("-DRC_FILE_VERSION=\\\"7.0.0\\\" "
|
||||
"-DRELATIVE_PLUGIN_PATH=\"../lib/qtcreator/plugins\"");
|
||||
|
||||
QCOMPARE(testData.flags.size(), 2);
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::testFilterCommand()
|
||||
{
|
||||
CompilationDatabaseUtilsTestData testData;
|
||||
testData.fileName = "SemaCodeComplete.cpp";
|
||||
testData.workingDir = "C:/build-qt_llvm-msvc2017_64bit-Debug";
|
||||
testData.flags = filterFromFileName(testData.getSplitCommandLine(kCmakeCommand),
|
||||
"SemaCodeComplete");
|
||||
testData.getFilteredFlags();
|
||||
|
||||
QCOMPARE(testData.flags,
|
||||
(QStringList{"/Zc:inline", "/Zc:strictStrings", "/Zc:rvalueCast", "/Zi"}));
|
||||
QCOMPARE(testData.headerPaths,
|
||||
(HeaderPaths{{"C:/build-qt_llvm-msvc2017_64bit-Debug/tools\\clang\\lib\\Sema",
|
||||
HeaderPathType::User}}));
|
||||
QCOMPARE(testData.macros, (Macros{{"UNICODE", "1"}, {"_HAS_EXCEPTIONS", "0"}, {"WIN32", "1"},
|
||||
{"_WINDOWS", "1"}}));
|
||||
QCOMPARE(testData.fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::testFileKindDifferentFromExtension()
|
||||
{
|
||||
CompilationDatabaseUtilsTestData testData;
|
||||
testData.fileName = "foo.c";
|
||||
testData.flags = QStringList{"-xc++"};
|
||||
testData.getFilteredFlags();
|
||||
|
||||
QCOMPARE(testData.fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::testFileKindDifferentFromExtension2()
|
||||
{
|
||||
CompilationDatabaseUtilsTestData testData;
|
||||
testData.fileName = "foo.cpp";
|
||||
testData.flags = QStringList{"-x", "c"};
|
||||
testData.getFilteredFlags();
|
||||
|
||||
QCOMPARE(testData.fileKind, CppTools::ProjectFile::Kind::CSource);
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::testSkipOutputFiles()
|
||||
{
|
||||
CompilationDatabaseUtilsTestData testData;
|
||||
testData.flags = filterFromFileName(QStringList{"-o", "foo.o"}, "foo");
|
||||
|
||||
QVERIFY(testData.getFilteredFlags().isEmpty());
|
||||
}
|
||||
|
||||
void CompilationDatabaseTests::addTestRow(const QByteArray &relativeFilePath)
|
||||
{
|
||||
const QString absoluteFilePath = m_tmpDir->absolutePath(relativeFilePath);
|
||||
@@ -102,4 +286,5 @@ void CompilationDatabaseTests::addTestRow(const QByteArray &relativeFilePath)
|
||||
QTest::newRow(relativeFilePath.constData()) << absoluteFilePath;
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CompilationDatabaseProjectManager
|
||||
|
@@ -31,6 +31,7 @@
|
||||
namespace CppTools { namespace Tests { class TemporaryCopiedDir; } }
|
||||
|
||||
namespace CompilationDatabaseProjectManager {
|
||||
namespace Internal {
|
||||
|
||||
class CompilationDatabaseTests : public QObject
|
||||
{
|
||||
@@ -44,6 +45,15 @@ private slots:
|
||||
void cleanupTestCase();
|
||||
void testProject();
|
||||
void testProject_data();
|
||||
void testFilterEmptyFlags();
|
||||
void testFilterFromFilename();
|
||||
void testFilterArguments();
|
||||
void testSplitFlags();
|
||||
void testSplitFlagsWithEscapedQuotes();
|
||||
void testFilterCommand();
|
||||
void testFileKindDifferentFromExtension();
|
||||
void testFileKindDifferentFromExtension2();
|
||||
void testSkipOutputFiles();
|
||||
|
||||
private:
|
||||
void addTestRow(const QByteArray &relativeFilePath);
|
||||
@@ -51,4 +61,5 @@ private:
|
||||
std::unique_ptr<CppTools::Tests::TemporaryCopiedDir> m_tmpDir;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace CompilationDatabaseProjectManager
|
||||
|
@@ -1,7 +0,0 @@
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/compilationdatabaseutils.cpp
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/compilationdatabaseutils.h
|
@@ -6,10 +6,8 @@ shared {
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/cppprojectfile.h \
|
||||
$$PWD/senddocumenttracker.h \
|
||||
$$PWD/projectpart.h
|
||||
$$PWD/senddocumenttracker.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/cppprojectfile.cpp \
|
||||
$$PWD/senddocumenttracker.cpp \
|
||||
$$PWD/projectpart.cpp
|
||||
$$PWD/senddocumenttracker.cpp
|
||||
|
@@ -411,17 +411,6 @@ extend_qtc_test(unittest
|
||||
analyzer/diagnosticlocation.h
|
||||
)
|
||||
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX ../../../src/plugins/compilationdatabaseprojectmanager
|
||||
SOURCES
|
||||
compilationdatabaseutils.cpp compilationdatabaseutils.h
|
||||
)
|
||||
|
||||
extend_qtc_test(unittest
|
||||
SOURCES
|
||||
compilationdatabaseutils-test.cpp
|
||||
)
|
||||
|
||||
extend_qtc_test(unittest
|
||||
SOURCES_PREFIX ../../../src/plugins/coreplugin
|
||||
DEFINES CORE_STATIC_LIBRARY
|
||||
@@ -437,7 +426,6 @@ extend_qtc_test(unittest
|
||||
SOURCES
|
||||
cppprojectfile.cpp cppprojectfile.h
|
||||
senddocumenttracker.cpp senddocumenttracker.h
|
||||
projectpart.cpp projectpart.h
|
||||
)
|
||||
|
||||
extend_qtc_test(unittest
|
||||
|
@@ -1,218 +0,0 @@
|
||||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2018 The Qt Company Ltd.
|
||||
** Contact: https://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of Qt Creator.
|
||||
**
|
||||
** Commercial License Usage
|
||||
** Licensees holding valid commercial Qt licenses may use this file in
|
||||
** accordance with the commercial license agreement provided with the
|
||||
** Software or, alternatively, in accordance with the terms contained in
|
||||
** a written agreement between you and The Qt Company. For licensing terms
|
||||
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||
** information use the contact form at https://www.qt.io/contact-us.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3 as published by the Free Software
|
||||
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||
** included in the packaging of this file. Please review the following
|
||||
** information to ensure the GNU General Public License requirements will
|
||||
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "googletest.h"
|
||||
|
||||
#include <compilationdatabaseprojectmanager/compilationdatabaseutils.h>
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/projectmacro.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace CompilationDatabaseProjectManager;
|
||||
using namespace CompilationDatabaseProjectManager::Internal;
|
||||
|
||||
namespace {
|
||||
|
||||
class CompilationDatabaseUtils : public ::testing::Test
|
||||
{
|
||||
protected:
|
||||
QStringList splitCommandLine(const QString &commandLine)
|
||||
{
|
||||
QSet<QString> flagsCache;
|
||||
return CompilationDatabaseProjectManager::Internal::splitCommandLine(commandLine, flagsCache);
|
||||
}
|
||||
|
||||
HeaderPaths headerPaths;
|
||||
Macros macros;
|
||||
CppTools::ProjectFile::Kind fileKind = CppTools::ProjectFile::Unclassified;
|
||||
QStringList flags;
|
||||
QString fileName;
|
||||
QString workingDir;
|
||||
QString sysRoot;
|
||||
};
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, FilterEmptyFlags)
|
||||
{
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind, sysRoot);
|
||||
|
||||
ASSERT_THAT(flags.isEmpty(), true);
|
||||
}
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, FilterFromFilename)
|
||||
{
|
||||
flags = filterFromFileName(QStringList{"-o", "foo.o"}, "foo");
|
||||
|
||||
ASSERT_THAT(flags, QStringList{"-o"});
|
||||
}
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, FilterArguments)
|
||||
{
|
||||
using Utils::HostOsInfo;
|
||||
const char winPath1[] = "C:\\Qt\\5.9.2\\mingw53_32\\include";
|
||||
const char otherPath1[] = "/Qt/5.9.2/mingw53_32/include";
|
||||
const char winPath2[] = "C:\\Qt\\5.9.2\\mingw53_32\\include\\QtWidgets";
|
||||
const char otherPath2[] = "/Qt/5.9.2/mingw53_32/include/QtWidgets";
|
||||
fileName = "compileroptionsbuilder.cpp";
|
||||
workingDir = "C:/build-qtcreator-MinGW_32bit-Debug";
|
||||
flags = filterFromFileName(
|
||||
QStringList{"clang++",
|
||||
"-c",
|
||||
"-m32",
|
||||
"-target",
|
||||
"i686-w64-mingw32",
|
||||
"-std=gnu++14",
|
||||
"-fcxx-exceptions",
|
||||
"-fexceptions",
|
||||
"-DUNICODE",
|
||||
"-DRELATIVE_PLUGIN_PATH=\"../lib/qtcreator/plugins\"",
|
||||
"-DQT_CREATOR",
|
||||
"-I",
|
||||
QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
|
||||
"-I",
|
||||
QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2),
|
||||
"-x",
|
||||
"c++",
|
||||
QString("--sysroot=") + (HostOsInfo::isWindowsHost()
|
||||
? "C:\\sysroot\\embedded" : "/opt/sysroot/embedded"),
|
||||
"C:\\qt-creator\\src\\plugins\\cpptools\\compileroptionsbuilder.cpp"},
|
||||
"compileroptionsbuilder");
|
||||
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind, sysRoot);
|
||||
|
||||
ASSERT_THAT(flags,
|
||||
Eq(QStringList{"-m32",
|
||||
"-target",
|
||||
"i686-w64-mingw32",
|
||||
"-std=gnu++14",
|
||||
"-fcxx-exceptions",
|
||||
"-fexceptions"}));
|
||||
ASSERT_THAT(headerPaths,
|
||||
Eq(HeaderPaths{{QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
|
||||
HeaderPathType::User},
|
||||
{QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2),
|
||||
HeaderPathType::User}}));
|
||||
ASSERT_THAT(macros,
|
||||
Eq(Macros{{"UNICODE", "1"},
|
||||
{"RELATIVE_PLUGIN_PATH", "\"../lib/qtcreator/plugins\""},
|
||||
{"QT_CREATOR", "1"}}));
|
||||
ASSERT_THAT(fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
||||
ASSERT_THAT(sysRoot, HostOsInfo::isWindowsHost() ? QString("C:\\sysroot\\embedded")
|
||||
: QString("/opt/sysroot/embedded"));
|
||||
}
|
||||
|
||||
static QString kCmakeCommand
|
||||
= "C:\\PROGRA~2\\MICROS~2\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1415~1.267\\bin\\HostX64\\x64\\cl."
|
||||
"exe "
|
||||
"/nologo "
|
||||
"/TP "
|
||||
"-DUNICODE "
|
||||
"-D_HAS_EXCEPTIONS=0 "
|
||||
"-Itools\\clang\\lib\\Sema "
|
||||
"/DWIN32 "
|
||||
"/D_WINDOWS "
|
||||
"/Zc:inline "
|
||||
"/Zc:strictStrings "
|
||||
"/Oi "
|
||||
"/Zc:rvalueCast "
|
||||
"/W4 "
|
||||
"-wd4141 "
|
||||
"-wd4146 "
|
||||
"/MDd "
|
||||
"/Zi "
|
||||
"/Ob0 "
|
||||
"/Od "
|
||||
"/RTC1 "
|
||||
"/EHs-c- "
|
||||
"/GR "
|
||||
"/Fotools\\clang\\lib\\Sema\\CMakeFiles\\clangSema.dir\\SemaCodeComplete.cpp.obj "
|
||||
"/FdTARGET_COMPILE_PDB "
|
||||
"/FS "
|
||||
"-c "
|
||||
"C:\\qt_llvm\\tools\\clang\\lib\\Sema\\SemaCodeComplete.cpp";
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, SplitFlags)
|
||||
{
|
||||
flags = splitCommandLine(kCmakeCommand);
|
||||
|
||||
ASSERT_THAT(flags.size(), 27);
|
||||
}
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, SplitFlagsWithEscapedQuotes)
|
||||
{
|
||||
flags = splitCommandLine("-DRC_FILE_VERSION=\\\"7.0.0\\\" "
|
||||
"-DRELATIVE_PLUGIN_PATH=\"../lib/qtcreator/plugins\"");
|
||||
|
||||
ASSERT_THAT(flags.size(), 2);
|
||||
}
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, FilterCommand)
|
||||
{
|
||||
fileName = "SemaCodeComplete.cpp";
|
||||
workingDir = "C:/build-qt_llvm-msvc2017_64bit-Debug";
|
||||
flags = filterFromFileName(splitCommandLine(kCmakeCommand), "SemaCodeComplete");
|
||||
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind, sysRoot);
|
||||
|
||||
ASSERT_THAT(flags, Eq(QStringList{"/Zc:inline", "/Zc:strictStrings", "/Zc:rvalueCast", "/Zi"}));
|
||||
ASSERT_THAT(headerPaths,
|
||||
Eq(HeaderPaths{{"C:/build-qt_llvm-msvc2017_64bit-Debug/tools\\clang\\lib\\Sema",
|
||||
HeaderPathType::User}}));
|
||||
ASSERT_THAT(macros,
|
||||
Eq(Macros{{"UNICODE", "1"}, {"_HAS_EXCEPTIONS", "0"}, {"WIN32", "1"}, {"_WINDOWS", "1"}}));
|
||||
ASSERT_THAT(fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
||||
}
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, FileKindDifferentFromExtension)
|
||||
{
|
||||
fileName = "foo.c";
|
||||
flags = QStringList{"-xc++"};
|
||||
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind, sysRoot);
|
||||
|
||||
ASSERT_THAT(fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
||||
}
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, FileKindDifferentFromExtension2)
|
||||
{
|
||||
fileName = "foo.cpp";
|
||||
flags = QStringList{"-x", "c"};
|
||||
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind, sysRoot);
|
||||
|
||||
ASSERT_THAT(fileKind, CppTools::ProjectFile::Kind::CSource);
|
||||
}
|
||||
|
||||
TEST_F(CompilationDatabaseUtils, SkipOutputFiles)
|
||||
{
|
||||
flags = filterFromFileName(QStringList{"-o", "foo.o"}, "foo");
|
||||
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind, sysRoot);
|
||||
|
||||
ASSERT_THAT(flags.isEmpty(), true);
|
||||
}
|
||||
|
||||
} // namespace
|
@@ -11,7 +11,6 @@ include($$PWD/../../../src/plugins/coreplugin/corepluginunittestfiles.pri)
|
||||
include($$PWD/../../../src/plugins/projectexplorer/projectexplorerunittestfiles.pri)
|
||||
include($$PWD/../../../src/plugins/cpptools/cpptoolsunittestfiles.pri)
|
||||
include($$PWD/../../../src/plugins/debugger/debuggerunittestfiles.pri)
|
||||
include($$PWD/../../../src/plugins/compilationdatabaseprojectmanager/compilationdatabaseunittestfiles.pri)
|
||||
include($$PWD/../../../src/plugins/qmldesigner/qmldesignerunittestfiles.pri)
|
||||
!isEmpty(QTC_UNITTEST_BUILD_CPP_PARSER):include(cplusplus.pri)
|
||||
!isEmpty(LLVM_VERSION) {
|
||||
|
@@ -88,7 +88,6 @@ SOURCES += \
|
||||
processcreator-test.cpp \
|
||||
mocktimer.cpp \
|
||||
task.cpp \
|
||||
compilationdatabaseutils-test.cpp \
|
||||
sqlitecolumn-test.cpp \
|
||||
sqlitedatabasebackend-test.cpp \
|
||||
sqlitedatabase-test.cpp \
|
||||
|
@@ -169,7 +169,6 @@ Project {
|
||||
"clientserverinprocess-test.cpp",
|
||||
"clientserveroutsideprocess-test.cpp",
|
||||
"compare-operators.h",
|
||||
"compilationdatabaseutils-test.cpp",
|
||||
"conditionally-disabled-tests.h",
|
||||
"createtablesqlstatementbuilder-test.cpp",
|
||||
"dummyclangipcclient.h",
|
||||
@@ -471,8 +470,6 @@ Project {
|
||||
files: [
|
||||
"cppprojectfile.cpp",
|
||||
"cppprojectfile.h",
|
||||
"projectpart.cpp",
|
||||
"projectpart.h",
|
||||
"senddocumenttracker.cpp",
|
||||
"senddocumenttracker.h",
|
||||
]
|
||||
@@ -490,15 +487,6 @@ Project {
|
||||
]
|
||||
}
|
||||
|
||||
Group {
|
||||
name: "sources from clangdbpm"
|
||||
prefix: "../../../src/plugins/compilationdatabaseprojectmanager/"
|
||||
files: [
|
||||
"compilationdatabaseutils.cpp",
|
||||
"compilationdatabaseutils.h",
|
||||
]
|
||||
}
|
||||
|
||||
Group {
|
||||
name: "sources from ProjectExplorer"
|
||||
prefix: "../../../src/plugins/projectexplorer/"
|
||||
|
Reference in New Issue
Block a user