summaryrefslogtreecommitdiffstats
path: root/unittests
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2018-07-26 23:21:51 +0000
committerReid Kleckner <rnk@google.com>2018-07-26 23:21:51 +0000
commit40a54a7b6f9cd658e4cef7739b794f9025ab98ca (patch)
tree79a2769ebca90d618311d741c5d85a32af29a5f6 /unittests
parent3eabc0d428ed870967574f5cca3771d2beb14777 (diff)
Revert r338057 "[VirtualFileSystem] InMemoryFileSystem::status: Return a Status with the requested name"
This broke clang/test/PCH/case-insensitive-include.c on Windows. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338084 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Basic/VirtualFileSystemTest.cpp59
-rw-r--r--unittests/Driver/ToolChainTest.cpp2
2 files changed, 11 insertions, 50 deletions
diff --git a/unittests/Basic/VirtualFileSystemTest.cpp b/unittests/Basic/VirtualFileSystemTest.cpp
index a9b39b5b13..c795be07ac 100644
--- a/unittests/Basic/VirtualFileSystemTest.cpp
+++ b/unittests/Basic/VirtualFileSystemTest.cpp
@@ -13,7 +13,6 @@
#include "llvm/Support/Errc.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/Path.h"
#include "llvm/Support/SourceMgr.h"
#include "gtest/gtest.h"
#include <map>
@@ -152,13 +151,6 @@ public:
addEntry(Path, S);
}
};
-
-/// Replace back-slashes by front-slashes.
-std::string getPosixPath(std::string S) {
- SmallString<128> Result;
- llvm::sys::path::native(S, Result, llvm::sys::path::Style::posix);
- return Result.str();
-};
} // end anonymous namespace
TEST(VirtualFileSystemTest, StatusQueries) {
@@ -790,9 +782,7 @@ TEST_F(InMemoryFileSystemTest, DirectoryIteration) {
I = FS.dir_begin("/b", EC);
ASSERT_FALSE(EC);
- // When on Windows, we end up with "/b\\c" as the name. Convert to Posix
- // path for the sake of the comparison.
- ASSERT_EQ("/b/c", getPosixPath(I->getName()));
+ ASSERT_EQ("/b/c", I->getName());
I.increment(EC);
ASSERT_FALSE(EC);
ASSERT_EQ(vfs::directory_iterator(), I);
@@ -804,19 +794,23 @@ TEST_F(InMemoryFileSystemTest, WorkingDirectory) {
auto Stat = FS.status("/b/c");
ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString();
- ASSERT_EQ("/b/c", Stat->getName());
+ ASSERT_EQ("c", Stat->getName());
ASSERT_EQ("/b", *FS.getCurrentWorkingDirectory());
Stat = FS.status("c");
ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n" << FS.toString();
+ auto ReplaceBackslashes = [](std::string S) {
+ std::replace(S.begin(), S.end(), '\\', '/');
+ return S;
+ };
NormalizedFS.setCurrentWorkingDirectory("/b/c");
NormalizedFS.setCurrentWorkingDirectory(".");
- ASSERT_EQ("/b/c",
- getPosixPath(NormalizedFS.getCurrentWorkingDirectory().get()));
+ ASSERT_EQ("/b/c", ReplaceBackslashes(
+ NormalizedFS.getCurrentWorkingDirectory().get()));
NormalizedFS.setCurrentWorkingDirectory("..");
- ASSERT_EQ("/b",
- getPosixPath(NormalizedFS.getCurrentWorkingDirectory().get()));
+ ASSERT_EQ("/b", ReplaceBackslashes(
+ NormalizedFS.getCurrentWorkingDirectory().get()));
}
#if !defined(_WIN32)
@@ -925,39 +919,6 @@ TEST_F(InMemoryFileSystemTest, AddDirectoryThenAddChild) {
ASSERT_TRUE(Stat->isRegularFile());
}
-// Test that the name returned by status() is in the same form as the path that
-// was requested (to match the behavior of RealFileSystem).
-TEST_F(InMemoryFileSystemTest, StatusName) {
- NormalizedFS.addFile("/a/b/c", 0, MemoryBuffer::getMemBuffer("abc"),
- /*User=*/None,
- /*Group=*/None, sys::fs::file_type::regular_file);
- NormalizedFS.setCurrentWorkingDirectory("/a/b");
-
- // Access using InMemoryFileSystem::status.
- auto Stat = NormalizedFS.status("../b/c");
- ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n"
- << NormalizedFS.toString();
- ASSERT_TRUE(Stat->isRegularFile());
- ASSERT_EQ("../b/c", Stat->getName());
-
- // Access using InMemoryFileAdaptor::status.
- auto File = NormalizedFS.openFileForRead("../b/c");
- ASSERT_FALSE(File.getError()) << File.getError() << "\n"
- << NormalizedFS.toString();
- Stat = (*File)->status();
- ASSERT_FALSE(Stat.getError()) << Stat.getError() << "\n"
- << NormalizedFS.toString();
- ASSERT_TRUE(Stat->isRegularFile());
- ASSERT_EQ("../b/c", Stat->getName());
-
- // Access using a directory iterator.
- std::error_code EC;
- clang::vfs::directory_iterator It = NormalizedFS.dir_begin("../b", EC);
- // When on Windows, we end up with "../b\\c" as the name. Convert to Posix
- // path for the sake of the comparison.
- ASSERT_EQ("../b/c", getPosixPath(It->getName()));
-}
-
// NOTE: in the tests below, we use '//root/' as our root directory, since it is
// a legal *absolute* path on Windows as well as *nix.
class VFSFromYAMLTest : public ::testing::Test {
diff --git a/unittests/Driver/ToolChainTest.cpp b/unittests/Driver/ToolChainTest.cpp
index 0d4c545bd7..d4198eaeb1 100644
--- a/unittests/Driver/ToolChainTest.cpp
+++ b/unittests/Driver/ToolChainTest.cpp
@@ -113,7 +113,7 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) {
std::replace(S.begin(), S.end(), '\\', '/');
#endif
EXPECT_EQ("Found candidate GCC installation: "
- "/home/test/bin/../lib/gcc/arm-linux-gnueabi/4.6.1\n"
+ "/home/test/lib/gcc/arm-linux-gnueabi/4.6.1\n"
"Selected GCC installation: "
"/home/test/bin/../lib/gcc/arm-linux-gnueabi/4.6.1\n"
"Candidate multilib: .;@m32\n"