kadircet created this revision. kadircet added a reviewer: sammccall. Herald added a project: All. kadircet requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
Make use of a physical copy, rather than real FS in unittests that change working-directory to get rid of the side effect of changing cwd for the whole process. It's triggering crashes depending on the test order. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D152265 Files: clang/unittests/Serialization/ModuleCacheTest.cpp clang/unittests/Serialization/NoCommentsTest.cpp clang/unittests/Serialization/VarDeclConstantInitTest.cpp Index: clang/unittests/Serialization/VarDeclConstantInitTest.cpp =================================================================== --- clang/unittests/Serialization/VarDeclConstantInitTest.cpp +++ clang/unittests/Serialization/VarDeclConstantInitTest.cpp @@ -94,6 +94,7 @@ CompilerInstance::createDiagnostics(new DiagnosticOptions()); CreateInvocationOptions CIOpts; CIOpts.Diags = Diags; + CIOpts.VFS = llvm::vfs::createPhysicalFileSystem(); std::string CacheBMIPath = llvm::Twine(TestDir + "/Cached.pcm").str(); const char *Args[] = { Index: clang/unittests/Serialization/NoCommentsTest.cpp =================================================================== --- clang/unittests/Serialization/NoCommentsTest.cpp +++ clang/unittests/Serialization/NoCommentsTest.cpp @@ -89,9 +89,9 @@ CIOpts.Diags = Diags; std::string CacheBMIPath = llvm::Twine(TestDir + "/Comments.pcm").str(); - const char *Args[] = { - "clang++", "-std=c++20", "--precompile", "-working-directory", - TestDir.c_str(), "Comments.cppm", "-o", CacheBMIPath.c_str()}; + std::string CCPMPath = llvm::Twine(TestDir).concat("/Comments.cppm").str(); + const char *Args[] = {"clang++", "-std=c++20", "--precompile", + CCPMPath.c_str(), "-o", CacheBMIPath.c_str()}; std::shared_ptr<CompilerInvocation> Invocation = createInvocation(Args, CIOpts); ASSERT_TRUE(Invocation); Index: clang/unittests/Serialization/ModuleCacheTest.cpp =================================================================== --- clang/unittests/Serialization/ModuleCacheTest.cpp +++ clang/unittests/Serialization/ModuleCacheTest.cpp @@ -14,6 +14,7 @@ #include "clang/Lex/HeaderSearch.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" @@ -98,6 +99,7 @@ CompilerInstance::createDiagnostics(new DiagnosticOptions()); CreateInvocationOptions CIOpts; CIOpts.Diags = Diags; + CIOpts.VFS = llvm::vfs::createPhysicalFileSystem(); // First run should pass with no errors const char *Args[] = {"clang", "-fmodules", "-Fframeworks",
Index: clang/unittests/Serialization/VarDeclConstantInitTest.cpp =================================================================== --- clang/unittests/Serialization/VarDeclConstantInitTest.cpp +++ clang/unittests/Serialization/VarDeclConstantInitTest.cpp @@ -94,6 +94,7 @@ CompilerInstance::createDiagnostics(new DiagnosticOptions()); CreateInvocationOptions CIOpts; CIOpts.Diags = Diags; + CIOpts.VFS = llvm::vfs::createPhysicalFileSystem(); std::string CacheBMIPath = llvm::Twine(TestDir + "/Cached.pcm").str(); const char *Args[] = { Index: clang/unittests/Serialization/NoCommentsTest.cpp =================================================================== --- clang/unittests/Serialization/NoCommentsTest.cpp +++ clang/unittests/Serialization/NoCommentsTest.cpp @@ -89,9 +89,9 @@ CIOpts.Diags = Diags; std::string CacheBMIPath = llvm::Twine(TestDir + "/Comments.pcm").str(); - const char *Args[] = { - "clang++", "-std=c++20", "--precompile", "-working-directory", - TestDir.c_str(), "Comments.cppm", "-o", CacheBMIPath.c_str()}; + std::string CCPMPath = llvm::Twine(TestDir).concat("/Comments.cppm").str(); + const char *Args[] = {"clang++", "-std=c++20", "--precompile", + CCPMPath.c_str(), "-o", CacheBMIPath.c_str()}; std::shared_ptr<CompilerInvocation> Invocation = createInvocation(Args, CIOpts); ASSERT_TRUE(Invocation); Index: clang/unittests/Serialization/ModuleCacheTest.cpp =================================================================== --- clang/unittests/Serialization/ModuleCacheTest.cpp +++ clang/unittests/Serialization/ModuleCacheTest.cpp @@ -14,6 +14,7 @@ #include "clang/Lex/HeaderSearch.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/VirtualFileSystem.h" #include "llvm/Support/raw_ostream.h" #include "gtest/gtest.h" @@ -98,6 +99,7 @@ CompilerInstance::createDiagnostics(new DiagnosticOptions()); CreateInvocationOptions CIOpts; CIOpts.Diags = Diags; + CIOpts.VFS = llvm::vfs::createPhysicalFileSystem(); // First run should pass with no errors const char *Args[] = {"clang", "-fmodules", "-Fframeworks",
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits