[llvm-commits] [llvm] r122880 - /llvm/trunk/unittests/Support/Path.cpp

Michael J. Spencer bigcheesegs at gmail.com
Wed Jan 5 08:39:05 PST 2011


Author: mspencer
Date: Wed Jan  5 10:39:05 2011
New Revision: 122880

URL: http://llvm.org/viewvc/llvm-project?rev=122880&view=rev
Log:
UnitTests/PathV2: Setup a test fixture to make tracking created file system
entities easier.

Modified:
    llvm/trunk/unittests/Support/Path.cpp

Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=122880&r1=122879&r2=122880&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Wed Jan  5 10:39:05 2011
@@ -123,7 +123,29 @@
 
     path::native(*i, temp_store);
   }
+}
+
+class FileSystemTest : public testing::Test {
+protected:
+  /// Unique temporary directory in which all created filesystem entities must
+  /// be placed. It is recursively removed at the end of each test.
+  SmallString<128> TestDirectory;
+
+  virtual void SetUp() {
+    /*int fd;
+    ASSERT_NO_ERROR(
+      fs::unique_file("%%-%%-%%-%%/test-directory.anchor", fd, TestDirectory));
+    // We don't care about this specific file.
+    ::close(fd);*/
+  }
 
+  virtual void TearDown() {
+    /*uint32_t removed;
+    ASSERT_NO_ERROR(fs::remove_all(TestDirectory.str(), removed));*/
+  }
+};
+
+TEST_F(FileSystemTest, TempFiles) {
   // Create a temp file.
   int FileDescriptor;
   SmallString<64> TempPath;
@@ -175,7 +197,9 @@
   // Make sure Temp1 doesn't exist.
   ASSERT_NO_ERROR(fs::exists(Twine(TempPath), TempFileExists));
   EXPECT_FALSE(TempFileExists);
+}
 
+TEST_F(FileSystemTest, DirectoryIteration) {
   error_code ec;
   for (fs::directory_iterator i(".", ec), e; i != e; i.increment(ec)) {
     if (ec) {





More information about the llvm-commits mailing list