diff options
author | Stella Stamenova <stilis@microsoft.com> | 2018-12-07 23:50:05 +0000 |
---|---|---|
committer | Stella Stamenova <stilis@microsoft.com> | 2018-12-07 23:50:05 +0000 |
commit | 0ef54dbd64550d1304dfe886eada6513b12c23b7 (patch) | |
tree | c9748cfebcedcafb972f72958a5473cc17e17563 /clang/unittests | |
parent | edddab9fac0909909fdf60c1920027b98fc5d8e8 (diff) |
[tests] Fix the FileManagerTest getVirtualFile test on Windows
Summary: The test passes on Windows only when it is executed on the C: drive. If the build and tests run on a different drive, the test is currently failing.
Reviewers: kadircet, asmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D55451
llvm-svn: 348665
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Basic/FileManagerTest.cpp | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp index f0b143de79b8..c0efaf4fc40c 100644 --- a/clang/unittests/Basic/FileManagerTest.cpp +++ b/clang/unittests/Basic/FileManagerTest.cpp @@ -351,22 +351,34 @@ TEST_F(FileManagerTest, makeAbsoluteUsesVFS) { // getVirtualFile should always fill the real path. TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) { + SmallString<64> CustomWorkingDir; +#ifdef _WIN32 + CustomWorkingDir = "C:/"; +#else + CustomWorkingDir = "/"; +#endif + + auto FS = IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem>( + new llvm::vfs::InMemoryFileSystem); + // setCurrentworkingdirectory must finish without error. + ASSERT_TRUE(!FS->setCurrentWorkingDirectory(CustomWorkingDir)); + + FileSystemOptions Opts; + FileManager Manager(Opts, FS); + // Inject fake files into the file system. auto statCache = llvm::make_unique<FakeStatCache>(); statCache->InjectDirectory("/tmp", 42); statCache->InjectFile("/tmp/test", 43); - manager.addStatCache(std::move(statCache)); + + Manager.addStatCache(std::move(statCache)); // Check for real path. - const FileEntry *file = manager.getVirtualFile("/tmp/test", 123, 1); + const FileEntry *file = Manager.getVirtualFile("/tmp/test", 123, 1); ASSERT_TRUE(file != nullptr); ASSERT_TRUE(file->isValid()); - SmallString<64> ExpectedResult; -#ifdef _WIN32 - ExpectedResult = "C:/"; -#else - ExpectedResult = "/"; -#endif + SmallString<64> ExpectedResult = CustomWorkingDir; + llvm::sys::path::append(ExpectedResult, "tmp", "test"); EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult); } |