aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Basic/FileManagerTest.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2018-11-30 17:10:11 +0000
committerKadir Cetinkaya <kadircet@google.com>2018-11-30 17:10:11 +0000
commite9870c0c9145a2b261054348c7979333b8ed6655 (patch)
treef5a7a63a32ed572f52ab85696a0c71dcb619cb57 /clang/unittests/Basic/FileManagerTest.cpp
parent5399552da165f40f21910f088aa9270086dcc89a (diff)
downloadllvm-e9870c0c9145a2b261054348c7979333b8ed6655.zip
llvm-e9870c0c9145a2b261054348c7979333b8ed6655.tar.gz
llvm-e9870c0c9145a2b261054348c7979333b8ed6655.tar.bz2
[clang] Fill RealPathName for virtual files.
Summary: Absolute path information for virtual files were missing even if we have already stat'd the files. This patch puts that information for virtual files that can succesffully be stat'd. Reviewers: ilya-biryukov Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55054 llvm-svn: 348006
Diffstat (limited to 'clang/unittests/Basic/FileManagerTest.cpp')
-rw-r--r--clang/unittests/Basic/FileManagerTest.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/clang/unittests/Basic/FileManagerTest.cpp b/clang/unittests/Basic/FileManagerTest.cpp
index 7e1e37f3..78c9990 100644
--- a/clang/unittests/Basic/FileManagerTest.cpp
+++ b/clang/unittests/Basic/FileManagerTest.cpp
@@ -235,22 +235,18 @@ TEST_F(FileManagerTest, getFileDefersOpen) {
ASSERT_TRUE(file != nullptr);
ASSERT_TRUE(file->isValid());
// "real path name" reveals whether the file was actually opened.
- EXPECT_EQ("", file->tryGetRealPathName());
+ EXPECT_FALSE(file->isOpenForTests());
file = manager.getFile("/tmp/test", /*OpenFile=*/true);
ASSERT_TRUE(file != nullptr);
ASSERT_TRUE(file->isValid());
-#ifdef _WIN32
- EXPECT_EQ("/tmp\\test", file->tryGetRealPathName());
-#else
- EXPECT_EQ("/tmp/test", file->tryGetRealPathName());
-#endif
+ EXPECT_TRUE(file->isOpenForTests());
// However we should never try to open a file previously opened as virtual.
ASSERT_TRUE(manager.getVirtualFile("/tmp/testv", 5, 0));
ASSERT_TRUE(manager.getFile("/tmp/testv", /*OpenFile=*/false));
file = manager.getFile("/tmp/testv", /*OpenFile=*/true);
- EXPECT_EQ("", file->tryGetRealPathName());
+ EXPECT_FALSE(file->isOpenForTests());
}
// The following tests apply to Unix-like system only.
@@ -353,4 +349,19 @@ TEST_F(FileManagerTest, makeAbsoluteUsesVFS) {
EXPECT_EQ(Path, ExpectedResult);
}
+// getVirtualFile should always fill the real path.
+TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) {
+ // 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));
+
+ // Check for real path.
+ const FileEntry *file = manager.getVirtualFile("/tmp/test", 123, 1);
+ ASSERT_TRUE(file != nullptr);
+ ASSERT_TRUE(file->isValid());
+ EXPECT_EQ(file->tryGetRealPathName(), "/tmp/test");
+}
+
} // anonymous namespace