r211633 - Fix test issues from r211623 and remove test-only API

Ben Langmuir blangmuir at apple.com
Tue Jun 24 14:08:13 PDT 2014


Author: benlangmuir
Date: Tue Jun 24 16:08:13 2014
New Revision: 211633

URL: http://llvm.org/viewvc/llvm-project?rev=211633&view=rev
Log:
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

Modified:
    cfe/trunk/include/clang/Basic/VirtualFileSystem.h
    cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=211633&r1=211632&r2=211633&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Tue Jun 24 16:08:13 2014
@@ -147,15 +147,6 @@ public:
   bool operator!=(const directory_iterator &RHS) const {
     return !(*this == RHS);
   }
-
-  /// For testing only. Directory iteration does not always succeed!
-  directory_iterator &operator++() {
-    std::error_code EC;
-    increment(EC);
-    if (EC)
-      llvm::report_fatal_error("directory iteration failed!");
-    return *this;
-  }
 };
 
 /// \brief The virtual file system interface.

Modified: cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp?rev=211633&r1=211632&r2=211633&view=diff
==============================================================================
--- cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp (original)
+++ cfe/trunk/unittests/Basic/VirtualFileSystemTest.cpp Tue Jun 24 16:08:13 2014
@@ -296,11 +296,12 @@ TEST(VirtualFileSystemTest, BasicRealFSI
   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, HiddenInIter
     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





More information about the cfe-commits mailing list