forked from qt-creator/qt-creator
CompilationDatabase: Fix unit-test
Change-Id: I2a2e2b5ead35236f11e6f9f0ec15608b30335fd1 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
committed by
Ivan Donchevskii
parent
24263717f3
commit
d4c5a6f9b2
@@ -29,6 +29,7 @@
|
||||
#include <projectexplorer/headerpath.h>
|
||||
#include <projectexplorer/projectmacro.h>
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/hostosinfo.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace CompilationDatabaseProjectManager;
|
||||
@@ -68,10 +69,15 @@ TEST_F(CompilationDatabaseUtils, FilterFromFilename)
|
||||
|
||||
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++",
|
||||
flags = filterFromFileName(
|
||||
QStringList{"clang++",
|
||||
"-c",
|
||||
"-m32",
|
||||
"-target",
|
||||
@@ -84,35 +90,38 @@ TEST_F(CompilationDatabaseUtils, FilterArguments)
|
||||
"-DQT_CREATOR",
|
||||
"-fPIC",
|
||||
"-I",
|
||||
"C:\\Qt\\5.9.2\\mingw53_32\\include",
|
||||
QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1),
|
||||
"-I",
|
||||
"C:\\Qt\\5.9.2\\mingw53_32\\include\\QtWidgets",
|
||||
QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2),
|
||||
"-x",
|
||||
"c++",
|
||||
"C:\\qt-creator\\src\\plugins\\cpptools\\compileroptionsbuilder.cpp"
|
||||
}, "compileroptionsbuilder");
|
||||
"C:\\qt-creator\\src\\plugins\\cpptools\\compileroptionsbuilder.cpp"},
|
||||
"compileroptionsbuilder");
|
||||
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind);
|
||||
|
||||
ASSERT_THAT(flags, Eq(QStringList{"-m32",
|
||||
ASSERT_THAT(flags,
|
||||
Eq(QStringList{"-m32",
|
||||
"-target",
|
||||
"i686-w64-mingw32",
|
||||
"-std=gnu++14",
|
||||
"-fcxx-exceptions",
|
||||
"-fexceptions"}));
|
||||
ASSERT_THAT(headerPaths, Eq(HeaderPaths{
|
||||
{"C:\\Qt\\5.9.2\\mingw53_32\\include", HeaderPathType::User},
|
||||
{"C:\\Qt\\5.9.2\\mingw53_32\\include\\QtWidgets", HeaderPathType::User}
|
||||
}));
|
||||
ASSERT_THAT(macros, Eq(Macros{
|
||||
{"UNICODE", "1"},
|
||||
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"}
|
||||
}));
|
||||
{"QT_CREATOR", "1"}}));
|
||||
ASSERT_THAT(fileKind, CppTools::ProjectFile::Kind::CXXSource);
|
||||
}
|
||||
|
||||
static QString kCmakeCommand = "C:\\PROGRA~2\\MICROS~2\\2017\\COMMUN~1\\VC\\Tools\\MSVC\\1415~1.267\\bin\\HostX64\\x64\\cl.exe "
|
||||
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 "
|
||||
@@ -163,19 +172,12 @@ TEST_F(CompilationDatabaseUtils, FilterCommand)
|
||||
|
||||
filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind);
|
||||
|
||||
ASSERT_THAT(flags, Eq(QStringList{"/Zc:inline",
|
||||
"/Zc:strictStrings",
|
||||
"/Zc:rvalueCast",
|
||||
"/Zi"}));
|
||||
ASSERT_THAT(headerPaths, Eq(HeaderPaths{
|
||||
{"tools\\clang\\lib\\Sema", HeaderPathType::User}
|
||||
}));
|
||||
ASSERT_THAT(macros, Eq(Macros{
|
||||
{"UNICODE", "1"},
|
||||
{"_HAS_EXCEPTIONS", "0"},
|
||||
{"WIN32", "1"},
|
||||
{"_WINDOWS", "1"}
|
||||
}));
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -208,4 +210,4 @@ TEST_F(CompilationDatabaseUtils, SkipOutputFiles)
|
||||
ASSERT_THAT(flags.isEmpty(), true);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
Reference in New Issue
Block a user