summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorBen Langmuir <blangmuir@apple.com>2014-06-24 21:08:13 +0000
committerBen Langmuir <blangmuir@apple.com>2014-06-24 21:08:13 +0000
commit93d4222c228925c5c97d0e0190d7e614db1778f3 (patch)
tree01ac22738110b4c8318a70ce130e7e013c38a274 /unittests
parentc16ee52c603fbc52fff5fc049b564a4e01e0e95f (diff)
downloadclang-93d4222c228925c5c97d0e0190d7e614db1778f3.tar.gz
clang-93d4222c228925c5c97d0e0190d7e614db1778f3.tar.bz2
clang-93d4222c228925c5c97d0e0190d7e614db1778f3.tar.xz
Fix test issues from r211623 and remove test-only API
1) missing iterator bits needed by libstdc++4.7 Using find_if was convenient, but since operator++ wasn't a good interface anyway, I just replaced with a range-based for loop and removed operator++ from the directory_iterator class. 2) stop relying on order of iterating real files git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211633 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Basic/VirtualFileSystemTest.cpp39
1 files changed, 21 insertions, 18 deletions
diff --git a/unittests/Basic/VirtualFileSystemTest.cpp b/unittests/Basic/VirtualFileSystemTest.cpp
index 63e9c42047..b0b3f87660 100644
--- a/unittests/Basic/VirtualFileSystemTest.cpp
+++ b/unittests/Basic/VirtualFileSystemTest.cpp
@@ -296,11 +296,12 @@ TEST(VirtualFileSystemTest, BasicRealFSIteration) {
I = FS->dir_begin(Twine(TestDirectory), EC);
ASSERT_FALSE(EC);
ASSERT_NE(vfs::directory_iterator(), I);
- EXPECT_TRUE(I->getName().endswith("a"));
+ // Check either a or c, since we can't rely on the iteration order.
+ EXPECT_TRUE(I->getName().endswith("a") || I->getName().endswith("c"));
I.increment(EC);
ASSERT_FALSE(EC);
ASSERT_NE(vfs::directory_iterator(), I);
- EXPECT_TRUE(I->getName().endswith("c"));
+ EXPECT_TRUE(I->getName().endswith("a") || I->getName().endswith("c"));
I.increment(EC);
EXPECT_EQ(vfs::directory_iterator(), I);
}
@@ -395,23 +396,25 @@ TEST(VirtualFileSystemTest, HiddenInIteration) {
checkContents(O->dir_begin("/", EC), Contents);
}
- // FIXME: broke gcc build
// Make sure we get the top-most entry
- // vfs::directory_iterator E;
- // {
- // auto I = std::find_if(O->dir_begin("/", EC), E, [](vfs::Status S){
- // return S.getName() == "/hiddenByUp";
- // });
- // ASSERT_NE(E, I);
- // EXPECT_EQ(sys::fs::owner_all, I->getPermissions());
- // }
- // {
- // auto I = std::find_if(O->dir_begin("/", EC), E, [](vfs::Status S){
- // return S.getName() == "/hiddenByMid";
- // });
- // ASSERT_NE(E, I);
- // EXPECT_EQ(sys::fs::owner_write, I->getPermissions());
- // }
+ {
+ std::error_code EC;
+ vfs::directory_iterator I = O->dir_begin("/", EC), E;
+ for ( ; !EC && I != E; I.increment(EC))
+ if (I->getName() == "/hiddenByUp")
+ break;
+ ASSERT_NE(E, I);
+ EXPECT_EQ(sys::fs::owner_all, I->getPermissions());
+ }
+ {
+ std::error_code EC;
+ vfs::directory_iterator I = O->dir_begin("/", EC), E;
+ for ( ; !EC && I != E; I.increment(EC))
+ if (I->getName() == "/hiddenByMid")
+ break;
+ ASSERT_NE(E, I);
+ EXPECT_EQ(sys::fs::owner_write, I->getPermissions());
+ }
}
// NOTE: in the tests below, we use '//root/' as our root directory, since it is