From 2d520140d01a8c6d9ff88c7f7205dfa28cc06d2d Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Wed, 24 Apr 2019 14:07:39 +0200 Subject: Clang: Fix system pre include search path We now get the resource path from creator. The -fPIC case is working now too. Change-Id: Id191e89e6d46706748d50440038a06a349972cc9 Reviewed-by: Ivan Donchevskii --- tests/unit/mockup/coreplugin/icore.h | 5 + .../unittest/builddependencycollector-test.cpp | 99 ++++++++++++++-- tests/unit/unittest/clangfollowsymbol-test.cpp | 4 +- .../unittest/clangreferencescollector-test.cpp | 4 +- .../unittest/codecompletionsextractor-test.cpp | 4 +- tests/unit/unittest/commandlinebuilder-test.cpp | 58 ++++------ tests/unit/unittest/cursor-test.cpp | 4 +- tests/unit/unittest/data/preincludes/system1.h | 1 + tests/unit/unittest/diagnostic-test.cpp | 6 +- tests/unit/unittest/diagnosticset-test.cpp | 6 +- .../unittest/highlightingresultreporter-test.cpp | 4 +- tests/unit/unittest/pchcreator-test.cpp | 16 ++- tests/unit/unittest/pchtaskqueue-test.cpp | 15 ++- tests/unit/unittest/projectupdater-test.cpp | 1 - tests/unit/unittest/skippedsourceranges-test.cpp | 4 +- tests/unit/unittest/sourcerange-test.cpp | 4 +- tests/unit/unittest/symbolindexer-test.cpp | 126 +++++++++++---------- tests/unit/unittest/symbolindexing-test.cpp | 8 +- tests/unit/unittest/testenvironment.h | 28 ++--- tests/unit/unittest/token-test.cpp | 4 +- tests/unit/unittest/tokenprocessor-test.cpp | 4 +- tests/unit/unittest/unittest-utility-functions.h | 12 +- 22 files changed, 258 insertions(+), 159 deletions(-) create mode 100644 tests/unit/unittest/data/preincludes/system1.h (limited to 'tests/unit') diff --git a/tests/unit/mockup/coreplugin/icore.h b/tests/unit/mockup/coreplugin/icore.h index 579fbc3b56..8cf88f7037 100644 --- a/tests/unit/mockup/coreplugin/icore.h +++ b/tests/unit/mockup/coreplugin/icore.h @@ -12,5 +12,10 @@ inline static QString cacheResourcePath() return QDir::tempPath(); } +inline static QString resourcePath() +{ + return QDir::tempPath(); +} + } // namespace ICore } // namespace Core diff --git a/tests/unit/unittest/builddependencycollector-test.cpp b/tests/unit/unittest/builddependencycollector-test.cpp index 6c2153fe0c..0d1b9650dc 100644 --- a/tests/unit/unittest/builddependencycollector-test.cpp +++ b/tests/unit/unittest/builddependencycollector-test.cpp @@ -737,10 +737,16 @@ TEST_F(BuildDependencyCollector, Create) 1, {}, {}, - {{TESTDATA_DIR "/builddependencycollector/system", 1, IncludeSearchPathType::System}}, + {{TESTDATA_DIR "/builddependencycollector/system", + 1, + ClangBackEnd::IncludeSearchPathType::System}}, { - {TESTDATA_DIR "/builddependencycollector/project", 1, IncludeSearchPathType::User}, - {TESTDATA_DIR "/builddependencycollector/external", 2, IncludeSearchPathType::User}, + {TESTDATA_DIR "/builddependencycollector/project", + 1, + ClangBackEnd::IncludeSearchPathType::User}, + {TESTDATA_DIR "/builddependencycollector/external", + 2, + ClangBackEnd::IncludeSearchPathType::User}, }, { id(TESTDATA_DIR "/builddependencycollector/project/header1.h"), @@ -771,6 +777,7 @@ TEST_F(BuildDependencyCollector, Create) "/builddependencycollector/external/indirect_external2.h"), fileStatus(TESTDATA_DIR "/builddependencycollector/external/external2.h"), fileStatus(TESTDATA_DIR "/builddependencycollector/system/system1.h"), + fileStatus(TESTDATA_DIR "/preincludes/system1.h"), fileStatus(TESTDATA_DIR "/builddependencycollector/system/indirect_system.h"), fileStatus(TESTDATA_DIR "/builddependencycollector/system/indirect_system2.h"), @@ -804,7 +811,7 @@ TEST_F(BuildDependencyCollector, Create) HasSource(id(TESTDATA_DIR "/builddependencycollector/external/external2.h"), SourceType::TopProjectInclude), HasSource(id(TESTDATA_DIR "/builddependencycollector/system/system1.h"), - SourceType::TopSystemInclude), + SourceType::SystemInclude), HasSource(id(TESTDATA_DIR "/builddependencycollector/system/indirect_system.h"), SourceType::SystemInclude), HasSource(id(TESTDATA_DIR @@ -813,7 +820,8 @@ TEST_F(BuildDependencyCollector, Create) HasSource(id(TESTDATA_DIR "/builddependencycollector/project/macros.h"), SourceType::UserInclude), HasSource(id(TESTDATA_DIR "/builddependencycollector/project/generated_file.h"), - SourceType::UserInclude))), + SourceType::UserInclude), + HasSource(id(TESTDATA_DIR "/preincludes/system1.h"), SourceType::TopSystemInclude))), Field(&BuildDependency::usedMacros, UnorderedElementsAre( UsedMacro{"IFDEF", id(TESTDATA_DIR "/builddependencycollector/project/macros.h")}, @@ -830,6 +838,7 @@ TEST_F(BuildDependencyCollector, Create) id(TESTDATA_DIR "/builddependencycollector/external/indirect_external2.h"), id(TESTDATA_DIR "/builddependencycollector/external/external2.h"), id(TESTDATA_DIR "/builddependencycollector/system/system1.h"), + id(TESTDATA_DIR "/preincludes/system1.h"), id(TESTDATA_DIR "/builddependencycollector/system/indirect_system.h"), id(TESTDATA_DIR "/builddependencycollector/system/indirect_system2.h"), id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"), @@ -854,6 +863,8 @@ TEST_F(BuildDependencyCollector, Create) id(TESTDATA_DIR "/builddependencycollector/external/external2.h")), SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"), + id(TESTDATA_DIR "/preincludes/system1.h")), + SourceDependency(id(TESTDATA_DIR "/preincludes/system1.h"), id(TESTDATA_DIR "/builddependencycollector/system/system1.h")), SourceDependency(id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp"), id(TESTDATA_DIR "/builddependencycollector/project/macros.h")), @@ -888,10 +899,16 @@ TEST_F(BuildDependencyCollector, Clear) 1, {}, {}, - {{TESTDATA_DIR "/builddependencycollector/system", 1, IncludeSearchPathType::System}}, + {{TESTDATA_DIR "/builddependencycollector/system", + 1, + ClangBackEnd::IncludeSearchPathType::System}}, { - {TESTDATA_DIR "/builddependencycollector/project", 1, IncludeSearchPathType::User}, - {TESTDATA_DIR "/builddependencycollector/external", 2, IncludeSearchPathType::User}, + {TESTDATA_DIR "/builddependencycollector/project", + 1, + ClangBackEnd::IncludeSearchPathType::User}, + {TESTDATA_DIR "/builddependencycollector/external", + 2, + ClangBackEnd::IncludeSearchPathType::User}, }, { id(TESTDATA_DIR "/builddependencycollector/project/header1.h"), @@ -899,14 +916,76 @@ TEST_F(BuildDependencyCollector, Clear) id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"), id(TESTDATA_DIR "/builddependencycollector/project/macros.h"), }, - {}, + {id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp")}, Utils::Language::Cxx, Utils::LanguageVersion::CXX11, Utils::LanguageExtension::None}; collector.create(projectPart); + ClangBackEnd::ProjectPartContainer emptyProjectPart{ + 1, + {}, + {}, + {{TESTDATA_DIR "/builddependencycollector/system", + 1, + ClangBackEnd::IncludeSearchPathType::System}}, + { + {TESTDATA_DIR "/builddependencycollector/project", + 1, + ClangBackEnd::IncludeSearchPathType::User}, + {TESTDATA_DIR "/builddependencycollector/external", + 2, + ClangBackEnd::IncludeSearchPathType::User}, + }, + { + id(TESTDATA_DIR "/builddependencycollector/project/header1.h"), + id(TESTDATA_DIR "/builddependencycollector/project/header2.h"), + id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"), + id(TESTDATA_DIR "/builddependencycollector/project/macros.h"), + }, + {}, + Utils::Language::Cxx, + Utils::LanguageVersion::CXX11, + Utils::LanguageExtension::None}; - auto buildDependency = collector.create(projectPart); + auto buildDependency = collector.create(emptyProjectPart); ASSERT_THAT(buildDependency.sources, IsEmpty()); } + +TEST_F(BuildDependencyCollector, PreIncludes) +{ + using ClangBackEnd::IncludeSearchPathType; + ClangBackEnd::BuildDependencyCollector collector{filePathCache, generatedFiles, environment}; + ClangBackEnd::ProjectPartContainer projectPart{ + 1, + {}, + {}, + {{TESTDATA_DIR "/builddependencycollector/system", + 1, + ClangBackEnd::IncludeSearchPathType::System}}, + { + {TESTDATA_DIR "/builddependencycollector/project", + 1, + ClangBackEnd::IncludeSearchPathType::User}, + {TESTDATA_DIR "/builddependencycollector/external", + 2, + ClangBackEnd::IncludeSearchPathType::User}, + }, + { + id(TESTDATA_DIR "/builddependencycollector/project/header1.h"), + id(TESTDATA_DIR "/builddependencycollector/project/header2.h"), + id(TESTDATA_DIR "/builddependencycollector/project/missingfile.h"), + id(TESTDATA_DIR "/builddependencycollector/project/macros.h"), + }, + {id(TESTDATA_DIR "/builddependencycollector/project/main4.cpp")}, + Utils::Language::Cxx, + Utils::LanguageVersion::CXX11, + Utils::LanguageExtension::None}; + + auto buildDependency = collector.create(projectPart); + + ASSERT_THAT(buildDependency.sources, + Contains(HasSource(id(TESTDATA_DIR "/preincludes/system1.h"), + SourceType::TopSystemInclude))); +} } // namespace diff --git a/tests/unit/unittest/clangfollowsymbol-test.cpp b/tests/unit/unittest/clangfollowsymbol-test.cpp index 628aa07618..e836cc83c6 100644 --- a/tests/unit/unittest/clangfollowsymbol-test.cpp +++ b/tests/unit/unittest/clangfollowsymbol-test.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "googletest.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -113,7 +113,7 @@ public: ClangBackEnd::UnsavedFiles unsavedFiles; ClangBackEnd::Documents documents{unsavedFiles}; Utf8StringVector compilationArguments{ - TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")})}; + UnitTest::addPlatformArguments({Utf8StringLiteral("-std=c++14")})}; Document document = {sourceFilePath, compilationArguments, {}, documents}; Document headerDocument = {headerFilePath, compilationArguments, {}, documents}; QVector deps{sourceFilePath, cursorPath}; diff --git a/tests/unit/unittest/clangreferencescollector-test.cpp b/tests/unit/unittest/clangreferencescollector-test.cpp index acf7c42ac3..bb04d8c8d1 100644 --- a/tests/unit/unittest/clangreferencescollector-test.cpp +++ b/tests/unit/unittest/clangreferencescollector-test.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "googletest.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -59,7 +59,7 @@ struct Data { ClangBackEnd::UnsavedFiles unsavedFiles; ClangBackEnd::Documents documents{unsavedFiles}; Document document{Utf8StringLiteral(TESTDATA_DIR"/references.cpp"), - TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")}), + UnitTest::addPlatformArguments({Utf8StringLiteral("-std=c++14")}), {}, documents}; }; diff --git a/tests/unit/unittest/codecompletionsextractor-test.cpp b/tests/unit/unittest/codecompletionsextractor-test.cpp index ae7559ce78..509dfd49dc 100644 --- a/tests/unit/unittest/codecompletionsextractor-test.cpp +++ b/tests/unit/unittest/codecompletionsextractor-test.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "googletest.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -148,7 +148,7 @@ protected: protected: ClangBackEnd::UnsavedFiles unsavedFiles; ClangBackEnd::Documents documents{unsavedFiles}; - Utf8StringVector compilationArguments{TestEnvironment::addPlatformArguments()}; + Utf8StringVector compilationArguments{UnitTest::addPlatformArguments()}; Document functionDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_function.cpp"), compilationArguments, {}, documents}; Document functionOverloadDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_functionoverload.cpp"), compilationArguments, {}, documents}; Document variableDocument{Utf8StringLiteral(TESTDATA_DIR"/complete_extractor_variable.cpp"), compilationArguments, {}, documents}; diff --git a/tests/unit/unittest/commandlinebuilder-test.cpp b/tests/unit/unittest/commandlinebuilder-test.cpp index d16bb008bb..c5765037dc 100644 --- a/tests/unit/unittest/commandlinebuilder-test.cpp +++ b/tests/unit/unittest/commandlinebuilder-test.cpp @@ -36,6 +36,7 @@ namespace { template using Builder = ClangBackEnd::CommandLineBuilder; +using ClangBackEnd::FilePath; using ClangBackEnd::IncludeSearchPathType; using ClangBackEnd::InputFileType; @@ -136,8 +137,6 @@ TYPED_TEST(CommandLineBuilder, CHeader) "c-header", "-std=c11", "-nostdinc", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.c"))); } @@ -156,8 +155,6 @@ TYPED_TEST(CommandLineBuilder, CSource) "c", "-std=c11", "-nostdinc", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.c"))); } @@ -177,8 +174,6 @@ TYPED_TEST(CommandLineBuilder, ObjectiveCHeader) "objective-c-header", "-std=c11", "-nostdinc", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.c"))); } @@ -198,8 +193,6 @@ TYPED_TEST(CommandLineBuilder, ObjectiveCSource) "objective-c", "-std=c11", "-nostdinc", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.c"))); } @@ -219,8 +212,6 @@ TYPED_TEST(CommandLineBuilder, CppHeader) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.cpp"))); } @@ -240,8 +231,6 @@ TYPED_TEST(CommandLineBuilder, CppSource) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.cpp"))); } @@ -262,8 +251,6 @@ TYPED_TEST(CommandLineBuilder, ObjectiveCppHeader) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.cpp"))); } @@ -284,8 +271,6 @@ TYPED_TEST(CommandLineBuilder, ObjectiveCppSource) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.cpp"))); } @@ -509,7 +494,13 @@ TYPED_TEST(CommandLineBuilder, IncludesOrder) {"/system/foo", 3, IncludeSearchPathType::Framework}, {"/builtin/bar", 2, IncludeSearchPathType::BuiltIn}, {"/builtin/foo", 1, IncludeSearchPathType::BuiltIn}}; - Builder builder{this->emptyProjectInfo, {}, InputFileType::Header, "/source/file.cpp"}; + Builder builder{this->emptyProjectInfo, + {}, + InputFileType::Header, + "/source/file.cpp", + {}, + {}, + ClangBackEnd::NativeFilePath{FilePath{"/resource/path"}}}; ASSERT_THAT(builder.commandLine, ElementsAre("clang++", @@ -520,8 +511,8 @@ TYPED_TEST(CommandLineBuilder, IncludesOrder) "-std=c++11", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath("/resource/path"), "-I", toNativePath("/include/foo"), "-I", @@ -549,9 +540,7 @@ TYPED_TEST(CommandLineBuilder, EmptySourceFile) "c++-header", "-std=c++98", "-nostdinc", - "-nostdinc++", - "-I", - toNativePath(resourcePath()))); + "-nostdinc++")); } TYPED_TEST(CommandLineBuilder, SourceFile) @@ -567,8 +556,6 @@ TYPED_TEST(CommandLineBuilder, SourceFile) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.cpp"))); } @@ -586,8 +573,6 @@ TYPED_TEST(CommandLineBuilder, EmptyOutputFile) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), toNativePath("/source/file.cpp"))); } @@ -608,13 +593,24 @@ TYPED_TEST(CommandLineBuilder, OutputFile) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), "-o", toNativePath("/output/file.o"), toNativePath("/source/file.cpp"))); } +TYPED_TEST(CommandLineBuilder, PreIncludeSearchPath) +{ + Builder builder{this->emptyProjectInfo, + {}, + {}, + {}, + {}, + {}, + ClangBackEnd::NativeFilePath{FilePath{"/resource/path"}}}; + + ASSERT_THAT(builder.commandLine, Contains(toNativePath("/resource/path"))); +} + TYPED_TEST(CommandLineBuilder, IncludePchPath) { Builder builder{this->emptyProjectInfo, @@ -633,8 +629,6 @@ TYPED_TEST(CommandLineBuilder, IncludePchPath) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), "-Xclang", "-include-pch", "-Xclang", @@ -660,9 +654,7 @@ TYPED_TEST(CommandLineBuilder, CompilerMacros) "-nostdinc", "-nostdinc++", "-DER=2", - "-DYI=1", - "-I", - toNativePath(resourcePath()))); + "-DYI=1")); } } // namespace diff --git a/tests/unit/unittest/cursor-test.cpp b/tests/unit/unittest/cursor-test.cpp index e55668d420..2fa4bff709 100644 --- a/tests/unit/unittest/cursor-test.cpp +++ b/tests/unit/unittest/cursor-test.cpp @@ -26,7 +26,7 @@ #include "googletest.h" #include "clangcompareoperators.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -63,7 +63,7 @@ struct Data { ClangBackEnd::Documents documents{unsavedFiles}; Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/cursor.cpp")}; Document document{filePath, - TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11")}), + UnitTest::addPlatformArguments({Utf8StringLiteral("-std=c++11")}), {}, documents}; TranslationUnit translationUnit{filePath, diff --git a/tests/unit/unittest/data/preincludes/system1.h b/tests/unit/unittest/data/preincludes/system1.h new file mode 100644 index 0000000000..005a65916e --- /dev/null +++ b/tests/unit/unittest/data/preincludes/system1.h @@ -0,0 +1 @@ +#include_next diff --git a/tests/unit/unittest/diagnostic-test.cpp b/tests/unit/unittest/diagnostic-test.cpp index fac44162cd..3ab382c46b 100644 --- a/tests/unit/unittest/diagnostic-test.cpp +++ b/tests/unit/unittest/diagnostic-test.cpp @@ -23,10 +23,10 @@ ** ****************************************************************************/ -#include "googletest.h" #include "diagnosticcontainer-matcher.h" +#include "googletest.h" #include "rundocumentparse-utility.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -87,7 +87,7 @@ protected: ClangBackEnd::UnsavedFiles unsavedFiles; ClangBackEnd::Documents documents{unsavedFiles}; Document document{Utf8StringLiteral(TESTDATA_DIR"/diagnostic_diagnostic.cpp"), - TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11")}), + UnitTest::addPlatformArguments({Utf8StringLiteral("-std=c++11")}), {}, documents}; UnitTest::RunDocumentParse _1{document}; diff --git a/tests/unit/unittest/diagnosticset-test.cpp b/tests/unit/unittest/diagnosticset-test.cpp index f37d00e13f..b59325e0e7 100644 --- a/tests/unit/unittest/diagnosticset-test.cpp +++ b/tests/unit/unittest/diagnosticset-test.cpp @@ -23,9 +23,9 @@ ** ****************************************************************************/ -#include "googletest.h" #include "diagnosticcontainer-matcher.h" -#include "testenvironment.h" +#include "googletest.h" +#include "unittest-utility-functions.h" #include #include @@ -64,7 +64,7 @@ protected: ClangBackEnd::UnsavedFiles unsavedFiles; ClangBackEnd::Documents documents{unsavedFiles}; Utf8StringVector compilationArguments{ - TestEnvironment::addPlatformArguments({Utf8StringLiteral("-pedantic")})}; + UnitTest::addPlatformArguments({Utf8StringLiteral("-pedantic")})}; Document document{Utf8StringLiteral(TESTDATA_DIR "/diagnostic_diagnosticset.cpp"), compilationArguments, {}, diff --git a/tests/unit/unittest/highlightingresultreporter-test.cpp b/tests/unit/unittest/highlightingresultreporter-test.cpp index dfe8dfbd2e..dd2001e02f 100644 --- a/tests/unit/unittest/highlightingresultreporter-test.cpp +++ b/tests/unit/unittest/highlightingresultreporter-test.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "googletest.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -51,7 +51,7 @@ struct Data { UnsavedFiles unsavedFiles; Documents documents{unsavedFiles}; Document document{Utf8StringLiteral(TESTDATA_DIR "/highlightingmarks.cpp"), - TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++14")}), + UnitTest::addPlatformArguments({Utf8StringLiteral("-std=c++14")}), Utf8StringVector(), documents}; }; diff --git a/tests/unit/unittest/pchcreator-test.cpp b/tests/unit/unittest/pchcreator-test.cpp index 9c40b7fea7..19bc087ca6 100644 --- a/tests/unit/unittest/pchcreator-test.cpp +++ b/tests/unit/unittest/pchcreator-test.cpp @@ -27,6 +27,7 @@ #include "fakeprocess.h" #include "filesystem-utilities.h" +#include "testenvironment.h" #include "mockbuilddependenciesstorage.h" #include "mockclangpathwatcher.h" @@ -79,7 +80,11 @@ MATCHER_P2(HasIdAndType, class PchCreator: public ::testing::Test { protected: - PchCreator() { creator.setUnsavedFiles({generatedFile}); } + PchCreator() + { + creator.setUnsavedFiles({generatedFile}); + pchTask1.preIncludeSearchPath = testEnvironment.preIncludeSearchPath(); + } ClangBackEnd::FilePathId id(ClangBackEnd::FilePathView path) { @@ -121,6 +126,7 @@ protected: {TESTDATA_DIR "/builddependencycollector/external", 1, IncludeSearchPathType::System}}, {{TESTDATA_DIR "/builddependencycollector/project", 1, IncludeSearchPathType::User}}, }; + TestEnvironment testEnvironment; }; using PchCreatorSlowTest = PchCreator; using PchCreatorVerySlowTest = PchCreator; @@ -148,8 +154,8 @@ TEST_F(PchCreator, CreateProjectPartClangCompilerArguments) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath(TESTDATA_DIR "/builddependencycollector/project"), "-isystem", @@ -175,8 +181,8 @@ TEST_F(PchCreator, CreateProjectPartClangCompilerArgumentsWithSystemPch) "-std=c++98", "-nostdinc", "-nostdinc++", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath(TESTDATA_DIR "/builddependencycollector/project"), "-isystem", diff --git a/tests/unit/unittest/pchtaskqueue-test.cpp b/tests/unit/unittest/pchtaskqueue-test.cpp index 4a8c0862ee..0851224d9d 100644 --- a/tests/unit/unittest/pchtaskqueue-test.cpp +++ b/tests/unit/unittest/pchtaskqueue-test.cpp @@ -29,6 +29,7 @@ #include "mockprecompiledheaderstorage.h" #include "mocksqlitetransactionbackend.h" #include "mocktaskscheduler.h" +#include "testenvironment.h" #include #include @@ -50,11 +51,13 @@ protected: MockSqliteTransactionBackend mockSqliteTransactionBackend; NiceMock> mockSetProgressCallback; ClangBackEnd::ProgressCounter progressCounter{mockSetProgressCallback.AsStdFunction()}; + TestEnvironment testEnvironment; ClangBackEnd::PchTaskQueue queue{mockSytemPchTaskScheduler, mockProjectPchTaskScheduler, progressCounter, mockPrecompiledHeaderStorage, - mockSqliteTransactionBackend}; + mockSqliteTransactionBackend, + testEnvironment}; IncludeSearchPaths systemIncludeSearchPaths{ {"/includes", 1, IncludeSearchPathType::BuiltIn}, {"/other/includes", 2, IncludeSearchPathType::System}}; @@ -297,6 +300,7 @@ TEST_F(PchTaskQueue, CreateProjectTaskFromPchTask) auto tasks = queue.createProjectTasks({projectTask1}); auto projectTask = projectTask1; projectTask.systemPchPath = "/path/to/pch"; + projectTask.preIncludeSearchPath = testEnvironment.preIncludeSearchPath(); EXPECT_CALL(mockPrecompiledHeaderStorage, fetchSystemPrecompiledHeaderPath(Eq(1))) .WillOnce(Return(ClangBackEnd::FilePath{"/path/to/pch"})); @@ -316,6 +320,7 @@ TEST_F(PchTaskQueue, DeleteProjectPchEntryInDatabaseIfNoPchIsGenerated) auto tasks = queue.createProjectTasks({projectTask1}); auto projectTask = projectTask1; projectTask.systemPchPath = "/path/to/pch"; + projectTask.preIncludeSearchPath = testEnvironment.preIncludeSearchPath(); EXPECT_CALL(mockPrecompiledHeaderStorage, fetchSystemPrecompiledHeaderPath(Eq(1))) .WillOnce(Return(ClangBackEnd::FilePath{"/path/to/pch"})); @@ -355,8 +360,10 @@ TEST_F(PchTaskQueue, CreateSystemTaskFromPchTask) MockPchCreator mockPchCreator; ClangBackEnd::ProjectPartPch projectPartPch{{}, "/path/to/pch", 99}; auto tasks = queue.createSystemTasks({systemTask4}); + auto systemTask = systemTask4; + systemTask.preIncludeSearchPath = testEnvironment.preIncludeSearchPath(); - EXPECT_CALL(mockPchCreator, generatePch(Eq(systemTask4))); + EXPECT_CALL(mockPchCreator, generatePch(Eq(systemTask))); EXPECT_CALL(mockPchCreator, projectPartPch()).WillOnce(ReturnRef(projectPartPch)); EXPECT_CALL(mockPrecompiledHeaderStorage, insertSystemPrecompiledHeaders(UnorderedElementsAre(1, 3), Eq("/path/to/pch"), 99)); @@ -370,8 +377,10 @@ TEST_F(PchTaskQueue, DeleteSystemPchEntryInDatabaseIfNoPchIsGenerated) MockPchCreator mockPchCreator; ClangBackEnd::ProjectPartPch projectPartPch{{}, "", 0}; auto tasks = queue.createSystemTasks({systemTask4}); + auto systemTask = systemTask4; + systemTask.preIncludeSearchPath = testEnvironment.preIncludeSearchPath(); - EXPECT_CALL(mockPchCreator, generatePch(Eq(systemTask4))); + EXPECT_CALL(mockPchCreator, generatePch(Eq(systemTask))); EXPECT_CALL(mockPchCreator, projectPartPch()).WillOnce(ReturnRef(projectPartPch)); EXPECT_CALL(mockPrecompiledHeaderStorage, deleteSystemPrecompiledHeaders(UnorderedElementsAre(1, 3))); diff --git a/tests/unit/unittest/projectupdater-test.cpp b/tests/unit/unittest/projectupdater-test.cpp index 21ee3f5781..494eed5713 100644 --- a/tests/unit/unittest/projectupdater-test.cpp +++ b/tests/unit/unittest/projectupdater-test.cpp @@ -351,7 +351,6 @@ TEST_F(ProjectUpdater, ToolChainArguments) ASSERT_THAT(arguments, ElementsAre(QString{"-m32"}, - QString{"-fPIC"}, QString{"extraflags"}, QString{"-include"}, QString{"config.h"})); diff --git a/tests/unit/unittest/skippedsourceranges-test.cpp b/tests/unit/unittest/skippedsourceranges-test.cpp index 083f795ec9..fd95dc4779 100644 --- a/tests/unit/unittest/skippedsourceranges-test.cpp +++ b/tests/unit/unittest/skippedsourceranges-test.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "googletest.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -89,7 +89,7 @@ struct Data { ClangBackEnd::UnsavedFiles unsavedFiles; ClangBackEnd::Documents documents{unsavedFiles}; Utf8String filePath = Utf8StringLiteral(TESTDATA_DIR"/skippedsourceranges.cpp"); - Utf8StringVector compilationArguments{TestEnvironment::addPlatformArguments( + Utf8StringVector compilationArguments{UnitTest::addPlatformArguments( {Utf8StringLiteral("-std=c++11"), {}, Utf8StringLiteral("-DBLAH")})}; Document document{filePath, compilationArguments, {}, documents}; TranslationUnit translationUnit{filePath, diff --git a/tests/unit/unittest/sourcerange-test.cpp b/tests/unit/unittest/sourcerange-test.cpp index c66b9854db..1b2b44a8f9 100644 --- a/tests/unit/unittest/sourcerange-test.cpp +++ b/tests/unit/unittest/sourcerange-test.cpp @@ -25,7 +25,7 @@ #include "googletest.h" #include "rundocumentparse-utility.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -75,7 +75,7 @@ struct Data { ClangBackEnd::Documents documents{unsavedFiles}; Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/diagnostic_source_range.cpp")}; Document document{filePath, - {TestEnvironment::addPlatformArguments({Utf8StringLiteral("-pedantic")})}, + {UnitTest::addPlatformArguments({Utf8StringLiteral("-pedantic")})}, {}, documents}; UnitTest::RunDocumentParse _1{document}; diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp index c1373e03c4..3594323532 100644 --- a/tests/unit/unittest/symbolindexer-test.cpp +++ b/tests/unit/unittest/symbolindexer-test.cpp @@ -34,6 +34,7 @@ #include "mocksqlitetransactionbackend.h" #include "mocksymbolscollector.h" #include "mocksymbolstorage.h" +#include "testenvironment.h" #include #include @@ -254,6 +255,7 @@ protected: NiceMock> mockSetProgressCallback; ClangBackEnd::ProgressCounter progressCounter{mockSetProgressCallback.AsStdFunction()}; NiceMock mockModifiedTimeChecker; + TestEnvironment testEnvironment; ClangBackEnd::SymbolIndexer indexer{indexerQueue, mockSymbolStorage, mockBuildDependenciesStorage, @@ -263,7 +265,8 @@ protected: fileStatusCache, mockSqliteTransactionBackend, mockProjectPartsStorage, - mockModifiedTimeChecker}; + mockModifiedTimeChecker, + testEnvironment}; SymbolIndexerTaskQueue indexerQueue{indexerScheduler, progressCounter}; Scheduler indexerScheduler{collectorManger, indexerQueue, @@ -290,8 +293,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesInCollector) "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -324,8 +327,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithPrecompiledHeaderInColl "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -362,8 +365,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsAddFilesWithoutPrecompiledHeaderInC "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -402,7 +405,7 @@ TEST_F(SymbolIndexer, UpdateProjectPartsDoesNotCallAddFilesInCollectorForEmptyEv TEST_F(SymbolIndexer, UpdateProjectPartsCallscollectSymbolsInCollector) { - EXPECT_CALL(mockCollector, collectSymbols()).Times(2);; + EXPECT_CALL(mockCollector, collectSymbols()).Times(2); indexer.updateProjectParts({projectPart1, projectPart2}); } @@ -453,8 +456,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsInOrder) "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -492,8 +495,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasN "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -534,8 +537,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasE "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -565,8 +568,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasE "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -608,8 +611,8 @@ TEST_F(SymbolIndexer, "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -639,8 +642,8 @@ TEST_F(SymbolIndexer, "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -670,8 +673,8 @@ TEST_F(SymbolIndexer, "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -707,8 +710,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasO "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -738,8 +741,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasO "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -769,8 +772,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsProjectAndSystemPchPathsAndHasO "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -806,8 +809,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsSystemPchPathsAndHasErrorWithPr "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -847,8 +850,8 @@ TEST_F(SymbolIndexer, UpdateProjectPartsCallsGetsNoPchPathsAndHasErrors) "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -931,7 +934,8 @@ TEST_F(SymbolIndexer, CallSetNotifier) fileStatusCache, mockSqliteTransactionBackend, mockProjectPartsStorage, - mockModifiedTimeChecker}; + mockModifiedTimeChecker, + testEnvironment}; } TEST_F(SymbolIndexer, PathChangedCallsFetchProjectPartArtefactInStorage) @@ -1013,8 +1017,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathCallsInOrder) "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1073,8 +1077,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasNoError "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1118,8 +1122,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasErrorWi "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1149,8 +1153,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasErrorWi "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1194,8 +1198,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasErrorWi "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1225,8 +1229,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasErrorWi "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1256,8 +1260,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasErrorWi "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1296,8 +1300,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasOnlyErr "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1327,8 +1331,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasOnlyErr "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1358,8 +1362,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsProjectAndSystemPchPathsAndHasOnlyErr "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1398,8 +1402,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsSystemPchPathsAndHasErrorWithProjectP "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1442,8 +1446,8 @@ TEST_F(SymbolIndexer, PathsChangedCallsGetsNoPchPathsAndHasErrors) "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1482,8 +1486,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsUsingPrecompiledHeader) "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", @@ -1521,8 +1525,8 @@ TEST_F(SymbolIndexer, UpdateChangedPathIsNotUsingPrecompiledHeaderIfItNotExists) "-nostdinc++", "-DBAR=1", "-DFOO=1", - "-I", - toNativePath(resourcePath()), + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), "-I", toNativePath("/project/includes"), "-I", diff --git a/tests/unit/unittest/symbolindexing-test.cpp b/tests/unit/unittest/symbolindexing-test.cpp index 6e094951f3..67411efd37 100644 --- a/tests/unit/unittest/symbolindexing-test.cpp +++ b/tests/unit/unittest/symbolindexing-test.cpp @@ -24,6 +24,7 @@ ****************************************************************************/ #include "googletest.h" +#include "testenvironment.h" #include #include @@ -85,7 +86,12 @@ protected: ClangBackEnd::GeneratedFiles generatedFiles; NiceMock> mockSetProgressCallback; ClangBackEnd::ProjectPartsStorage projectPartStorage{database}; - ClangBackEnd::SymbolIndexing indexing{database, filePathCache, generatedFiles, mockSetProgressCallback.AsStdFunction()}; + TestEnvironment testEnvironment; + ClangBackEnd::SymbolIndexing indexing{database, + filePathCache, + generatedFiles, + mockSetProgressCallback.AsStdFunction(), + testEnvironment}; StatementFactory queryFactory{database}; Query query{queryFactory}; PathString main1Path = TESTDATA_DIR "/symbolindexing_main1.cpp"; diff --git a/tests/unit/unittest/testenvironment.h b/tests/unit/unittest/testenvironment.h index a9529c58d5..1e6c7da862 100644 --- a/tests/unit/unittest/testenvironment.h +++ b/tests/unit/unittest/testenvironment.h @@ -27,36 +27,24 @@ #include -#include -#include +#include #include -#include class TestEnvironment final : public ClangBackEnd::Environment { public: - TestEnvironment() { - temporaryDirectory.setAutoRemove(true); - } - QString pchBuildDirectory() const override - { - return temporaryDirectory.path(); - } - - uint hardwareConcurrency() const - { - return 2; - } + TestEnvironment() { temporaryDirectory.setAutoRemove(true); } - static QVector addPlatformArguments(std::initializer_list arguments = {}) + Utils::PathString pchBuildDirectory() const override { return temporaryDirectory.path(); } + uint hardwareConcurrency() const { return 2; } + ClangBackEnd::NativeFilePathView preIncludeSearchPath() const override { - QVector result{arguments}; - if (Utils::HostOsInfo::isWindowsHost()) - result.append(Utf8StringLiteral("-fno-delayed-template-parsing")); - return result; + return includeSearchPath; } private: QTemporaryDir temporaryDirectory; + ClangBackEnd::NativeFilePath includeSearchPath{ + ClangBackEnd::FilePath{TESTDATA_DIR "/preincludes"}}; }; diff --git a/tests/unit/unittest/token-test.cpp b/tests/unit/unittest/token-test.cpp index 3f7c39ea5f..f5f8a36e3a 100644 --- a/tests/unit/unittest/token-test.cpp +++ b/tests/unit/unittest/token-test.cpp @@ -25,7 +25,7 @@ #include "googletest.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -55,7 +55,7 @@ struct Data { ClangBackEnd::Documents documents{unsavedFiles}; Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/token.cpp")}; Utf8StringVector compilationArguments{ - TestEnvironment::addPlatformArguments({Utf8StringLiteral("-std=c++11")})}; + UnitTest::addPlatformArguments({Utf8StringLiteral("-std=c++11")})}; Document document{filePath, compilationArguments, {}, documents}; TranslationUnit translationUnit{filePath, filePath, diff --git a/tests/unit/unittest/tokenprocessor-test.cpp b/tests/unit/unittest/tokenprocessor-test.cpp index c96650472d..285c6d3446 100644 --- a/tests/unit/unittest/tokenprocessor-test.cpp +++ b/tests/unit/unittest/tokenprocessor-test.cpp @@ -24,7 +24,7 @@ ****************************************************************************/ #include "googletest.h" -#include "testenvironment.h" +#include "unittest-utility-functions.h" #include #include @@ -128,7 +128,7 @@ struct Data { ClangBackEnd::Documents documents{unsavedFiles}; Utf8String filePath{Utf8StringLiteral(TESTDATA_DIR"/highlightingmarks.cpp")}; Document document{filePath, - TestEnvironment::addPlatformArguments( + UnitTest::addPlatformArguments( {Utf8StringLiteral("-std=c++14"), Utf8StringLiteral("-I" TESTDATA_DIR)}), {}, diff --git a/tests/unit/unittest/unittest-utility-functions.h b/tests/unit/unittest/unittest-utility-functions.h index 6d68c1adfc..5102769e78 100644 --- a/tests/unit/unittest/unittest-utility-functions.h +++ b/tests/unit/unittest/unittest-utility-functions.h @@ -25,10 +25,12 @@ #pragma once +#include #include - #include +#include + inline bool operator==(const QString &first, const char *second) { @@ -42,4 +44,12 @@ Utils::PathString temporaryDirPath() { return Utils::PathString::fromQString(Utils::TemporaryDirectory::masterDirectoryPath()); } + +inline QVector addPlatformArguments(std::initializer_list arguments = {}) +{ + QVector result{arguments}; + if (Utils::HostOsInfo::isWindowsHost()) + result.append(Utf8StringLiteral("-fno-delayed-template-parsing")); + return result; +} } // namespace UnitTest -- cgit v1.2.1