On Fri, Dec 7, 2018 at 6:52 PM Stella Stamenova via cfe-commits <cfe-commits@lists.llvm.org> wrote: > > Author: stella.stamenova > Date: Fri Dec 7 15:50:05 2018 > New Revision: 348665 > > URL: http://llvm.org/viewvc/llvm-project?rev=348665&view=rev > Log: > [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 > > 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=348665&r1=348664&r2=348665&view=diff > ============================================================================== > --- cfe/trunk/unittests/Basic/FileManagerTest.cpp (original) > +++ cfe/trunk/unittests/Basic/FileManagerTest.cpp Fri Dec 7 15:50:05 2018 > @@ -351,22 +351,34 @@ TEST_F(FileManagerTest, makeAbsoluteUses > > // getVirtualFile should always fill the real path. > TEST_F(FileManagerTest, getVirtualFileFillsRealPathName) { > + SmallString<64> CustomWorkingDir; > +#ifdef _WIN32 > + CustomWorkingDir = "C:/"; > +#else > + CustomWorkingDir = "/"; > +#endif
Unfortunately, this is still an issue -- you cannot assume that C:\ is the correct drive letter on Windows. For instance, this unit test fails for me because it turns out to be D:\ on my system. ~Aaron > + > + 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); > } > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits