summaryrefslogtreecommitdiff
path: root/unittests/Basic
diff options
context:
space:
mode:
authorStella Stamenova <stilis@microsoft.com>2018-12-07 23:50:05 +0000
committerStella Stamenova <stilis@microsoft.com>2018-12-07 23:50:05 +0000
commit6eb1b99fab69df06bb933996b663227ca6b50ea6 (patch)
treee285a9eb2407c98f87d9ba276c04ebf404cd5854 /unittests/Basic
parentcad7d397bbc434a6cd05c4a3c5f9b3f20e97de7e (diff)
downloadclang-6eb1b99fab69df06bb933996b663227ca6b50ea6.tar.gz
[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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348665 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Basic')
-rw-r--r--unittests/Basic/FileManagerTest.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/unittests/Basic/FileManagerTest.cpp b/unittests/Basic/FileManagerTest.cpp
index f0b143de79..c0efaf4fc4 100644
--- a/unittests/Basic/FileManagerTest.cpp
+++ b/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);
}