r354296 - [clang][test] Fix FileManagerTest.getFileDontOpenRealPath for Windows

Jan Korous via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 18 15:12:29 PST 2019


Author: jkorous
Date: Mon Feb 18 15:12:29 2019
New Revision: 354296

URL: http://llvm.org/viewvc/llvm-project?rev=354296&view=rev
Log:
[clang][test] Fix FileManagerTest.getFileDontOpenRealPath for Windows

Modified:
    cfe/trunk/unittests/Basic/FileManagerTest.cpp

Modified: cfe/trunk/unittests/Basic/FileManagerTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/FileManagerTest.cpp?rev=354296&r1=354295&r2=354296&view=diff
==============================================================================
--- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original)
+++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Mon Feb 18 15:12:29 2019
@@ -362,17 +362,21 @@ TEST_F(FileManagerTest, getFileDontOpenR
   FileSystemOptions Opts;
   FileManager Manager(Opts, FS);
 
+  // Inject fake files into the file system.
   auto statCache = llvm::make_unique<FakeStatCache>();
-  statCache->InjectDirectory("/tmp/abc", 42);
-  SmallString<64> Path("/tmp/abc/foo.cpp");
-  statCache->InjectFile(Path.str().str().c_str(), 43);
-  manager.setStatCache(std::move(statCache));
+  statCache->InjectDirectory("/tmp", 42);
+  statCache->InjectFile("/tmp/test", 43);
 
-  const FileEntry *file = manager.getFile(Path, /*openFile=*/false);
+  Manager.setStatCache(std::move(statCache));
 
+  // Check for real path.
+  const FileEntry *file = Manager.getFile("/tmp/test", /*OpenFile=*/false);
   ASSERT_TRUE(file != nullptr);
+  ASSERT_TRUE(file->isValid());
+  SmallString<64> ExpectedResult = CustomWorkingDir;
 
-  ASSERT_EQ(file->tryGetRealPathName(), Path);
+  llvm::sys::path::append(ExpectedResult, "tmp", "test");
+  EXPECT_EQ(file->tryGetRealPathName(), ExpectedResult);
 }
 
 } // anonymous namespace




More information about the cfe-commits mailing list