[PATCH] D55451: [tests] Fix the FileManagerTest getVirtualFile test on Windows
Stella Stamenova via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Dec 7 15:53:11 PST 2018
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rC348665: [tests] Fix the FileManagerTest getVirtualFile test on Windows (authored by stella.stamenova, committed by ).
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D55451/new/
https://reviews.llvm.org/D55451
Files:
unittests/Basic/FileManagerTest.cpp
Index: unittests/Basic/FileManagerTest.cpp
===================================================================
--- unittests/Basic/FileManagerTest.cpp
+++ unittests/Basic/FileManagerTest.cpp
@@ -351,22 +351,34 @@
// 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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55451.177346.patch
Type: text/x-patch
Size: 1568 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181207/70f7de74/attachment.bin>
More information about the cfe-commits
mailing list