diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2019-04-26 14:09:21 +0200 |
---|---|---|
committer | Ivan Donchevskii <yv.ivan@gmail.com> | 2019-04-30 12:46:41 +0000 |
commit | d4c5a6f9b28af470f0886e9c03230461ce6b5659 (patch) | |
tree | 845dde7943a35df54a1d827f5eb68a42824544b4 /tests | |
parent | 24263717f39730cfd02e4b5efbdf41c76bd63ba4 (diff) | |
download | qt-creator-d4c5a6f9b28af470f0886e9c03230461ce6b5659.tar.gz |
CompilationDatabase: Fix unit-test
Change-Id: I2a2e2b5ead35236f11e6f9f0ec15608b30335fd1
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unittest/compilationdatabaseutils-test.cpp | 158 |
1 files changed, 80 insertions, 78 deletions
diff --git a/tests/unit/unittest/compilationdatabaseutils-test.cpp b/tests/unit/unittest/compilationdatabaseutils-test.cpp index 1455fa0334..9e46ef48f7 100644 --- a/tests/unit/unittest/compilationdatabaseutils-test.cpp +++ b/tests/unit/unittest/compilationdatabaseutils-test.cpp @@ -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,77 +69,85 @@ 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++", - "-c", - "-m32", - "-target", - "i686-w64-mingw32", - "-std=gnu++14", - "-fcxx-exceptions", - "-fexceptions", - "-DUNICODE", - "-DRELATIVE_PLUGIN_PATH=\"../lib/qtcreator/plugins\"", - "-DQT_CREATOR", - "-fPIC", - "-I", - "C:\\Qt\\5.9.2\\mingw53_32\\include", - "-I", - "C:\\Qt\\5.9.2\\mingw53_32\\include\\QtWidgets", - "-x", - "c++", - "C:\\qt-creator\\src\\plugins\\cpptools\\compileroptionsbuilder.cpp" - }, "compileroptionsbuilder"); + 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", + "-fPIC", + "-I", + QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath1 : otherPath1), + "-I", + QString::fromUtf8(HostOsInfo::isWindowsHost() ? winPath2 : otherPath2), + "-x", + "c++", + "C:\\qt-creator\\src\\plugins\\cpptools\\compileroptionsbuilder.cpp"}, + "compileroptionsbuilder"); filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind); - 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"}, - {"RELATIVE_PLUGIN_PATH", "\"../lib/qtcreator/plugins\""}, - {"QT_CREATOR", "1"} - })); + 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); } -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"; +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) { @@ -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); } @@ -192,7 +194,7 @@ TEST_F(CompilationDatabaseUtils, FileKindDifferentFromExtension) TEST_F(CompilationDatabaseUtils, FileKindDifferentFromExtension2) { fileName = "foo.cpp"; - flags = QStringList{"-x", "c"}; + flags = QStringList{"-x", "c"}; filteredFlags(fileName, workingDir, flags, headerPaths, macros, fileKind); @@ -208,4 +210,4 @@ TEST_F(CompilationDatabaseUtils, SkipOutputFiles) ASSERT_THAT(flags.isEmpty(), true); } -} +} // namespace |