aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/VirtualFileSystemTest.cpp
diff options
context:
space:
mode:
authorPaul Pluzhnikov <ppluzhnikov@google.com>2022-06-02 10:30:24 -0700
committerReid Kleckner <rnk@google.com>2022-06-02 11:07:44 -0700
commit35ab2a11bb55c39ef9fe389aeacc14bb55c5a12d (patch)
treeca1c351b0e8af4fea1547b6531824c19da711da9 /llvm/unittests/Support/VirtualFileSystemTest.cpp
parente4870c835791faa7b71f66820fdb6bcdcec636d7 (diff)
downloadllvm-35ab2a11bb55c39ef9fe389aeacc14bb55c5a12d.zip
llvm-35ab2a11bb55c39ef9fe389aeacc14bb55c5a12d.tar.gz
llvm-35ab2a11bb55c39ef9fe389aeacc14bb55c5a12d.tar.bz2
Fix a buglet in remove_dots().
The function promises to canonicalize the path, but neglected to do so for the root component. For example, calling remove_dots("/tmp/foo.c", Style::windows_backslash) resulted in "/tmp\foo.c". Now it produces "\tmp\foo.c". Also fix FIXME in the corresponding test. Reviewed By: rnk Differential Revision: https://reviews.llvm.org/D126412
Diffstat (limited to 'llvm/unittests/Support/VirtualFileSystemTest.cpp')
-rw-r--r--llvm/unittests/Support/VirtualFileSystemTest.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/unittests/Support/VirtualFileSystemTest.cpp b/llvm/unittests/Support/VirtualFileSystemTest.cpp
index 52eba15..e32b3d2 100644
--- a/llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ b/llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -199,7 +199,7 @@ class ErrorDummyFileSystem : public DummyFileSystem {
};
/// Replace back-slashes by front-slashes.
-std::string getPosixPath(std::string S) {
+std::string getPosixPath(const Twine &S) {
SmallString<128> Result;
llvm::sys::path::native(S, Result, llvm::sys::path::Style::posix);
return std::string(Result.str());
@@ -923,11 +923,11 @@ TEST(ProxyFileSystemTest, Basic) {
auto PWD = PFS.getCurrentWorkingDirectory();
ASSERT_FALSE(PWD.getError());
- ASSERT_EQ("/", *PWD);
+ ASSERT_EQ("/", getPosixPath(*PWD));
SmallString<16> Path;
ASSERT_FALSE(PFS.getRealPath("a", Path));
- ASSERT_EQ("/a", Path);
+ ASSERT_EQ("/a", getPosixPath(Path));
bool Local = true;
ASSERT_FALSE(PFS.isLocal("/a", Local));
@@ -1343,7 +1343,8 @@ TEST_F(InMemoryFileSystemTest, UniqueID) {
EXPECT_NE(FS.status("/a")->getUniqueID(), FS.status("/e")->getUniqueID());
// Recreating the "same" FS yields the same UniqueIDs.
- vfs::InMemoryFileSystem FS2;
+ // Note: FS2 should match FS with respect to path normalization.
+ vfs::InMemoryFileSystem FS2(/*UseNormalizedPath=*/false);
ASSERT_TRUE(FS2.addFile("/a/b", 0, MemoryBuffer::getMemBuffer("text")));
EXPECT_EQ(FS.status("/a/b")->getUniqueID(),
FS2.status("/a/b")->getUniqueID());