Skip to content

Commit 476e7c4

Browse files
committed
[clang][test] Use a physical copy of FS
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. Differential Revision: https://reviews.llvm.org/D152265
1 parent c6f5f6a commit 476e7c4

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

clang/unittests/Serialization/ModuleCacheTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "clang/Lex/HeaderSearch.h"
1515
#include "llvm/ADT/SmallString.h"
1616
#include "llvm/Support/FileSystem.h"
17+
#include "llvm/Support/VirtualFileSystem.h"
1718
#include "llvm/Support/raw_ostream.h"
1819

1920
#include "gtest/gtest.h"
@@ -98,6 +99,7 @@ TEST_F(ModuleCacheTest, CachedModuleNewPath) {
9899
CompilerInstance::createDiagnostics(new DiagnosticOptions());
99100
CreateInvocationOptions CIOpts;
100101
CIOpts.Diags = Diags;
102+
CIOpts.VFS = llvm::vfs::createPhysicalFileSystem();
101103

102104
// First run should pass with no errors
103105
const char *Args[] = {"clang", "-fmodules", "-Fframeworks",

clang/unittests/Serialization/NoCommentsTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void foo() {}
8787
CompilerInstance::createDiagnostics(new DiagnosticOptions());
8888
CreateInvocationOptions CIOpts;
8989
CIOpts.Diags = Diags;
90+
CIOpts.VFS = llvm::vfs::createPhysicalFileSystem();
9091

9192
std::string CacheBMIPath = llvm::Twine(TestDir + "/Comments.pcm").str();
9293
const char *Args[] = {

clang/unittests/Serialization/VarDeclConstantInitTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export namespace Fibonacci
9494
CompilerInstance::createDiagnostics(new DiagnosticOptions());
9595
CreateInvocationOptions CIOpts;
9696
CIOpts.Diags = Diags;
97+
CIOpts.VFS = llvm::vfs::createPhysicalFileSystem();
9798

9899
std::string CacheBMIPath = llvm::Twine(TestDir + "/Cached.pcm").str();
99100
const char *Args[] = {

0 commit comments

Comments
 (0)