summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-01-10 20:36:42 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-01-10 20:36:42 +0000
commit217c714a6779841ae06f420f384b87e12454b1a1 (patch)
treee1f04f8e004152d94b03fea99e9ea66ccd505e72 /unittests
parentd91c160b0a330ca95e09acc90764160406ecba85 (diff)
downloadllvm-217c714a6779841ae06f420f384b87e12454b1a1.tar.gz
llvm-217c714a6779841ae06f420f384b87e12454b1a1.tar.bz2
llvm-217c714a6779841ae06f420f384b87e12454b1a1.tar.xz
Remove remove_all. A compiler has no need for recursively deleting a directory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198955 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/FileOutputBufferTest.cpp7
-rw-r--r--unittests/Support/LockFileManagerTest.cpp3
-rw-r--r--unittests/Support/Path.cpp17
3 files changed, 22 insertions, 5 deletions
diff --git a/unittests/Support/FileOutputBufferTest.cpp b/unittests/Support/FileOutputBufferTest.cpp
index 5e873193f2..b81bdb579d 100644
--- a/unittests/Support/FileOutputBufferTest.cpp
+++ b/unittests/Support/FileOutputBufferTest.cpp
@@ -56,6 +56,7 @@ TEST(FileOutputBuffer, Test) {
uint64_t File1Size;
ASSERT_NO_ERROR(fs::file_size(Twine(File1), File1Size));
ASSERT_EQ(File1Size, 8192ULL);
+ ASSERT_NO_ERROR(fs::remove(File1.str()));
// TEST 2: Verify abort case.
SmallString<128> File2(TestDirectory);
@@ -71,6 +72,7 @@ TEST(FileOutputBuffer, Test) {
bool Exists = false;
ASSERT_NO_ERROR(fs::exists(Twine(File2), Exists));
EXPECT_FALSE(Exists);
+ ASSERT_NO_ERROR(fs::remove(File2.str()));
// TEST 3: Verify sizing down case.
SmallString<128> File3(TestDirectory);
@@ -94,6 +96,7 @@ TEST(FileOutputBuffer, Test) {
uint64_t File3Size;
ASSERT_NO_ERROR(fs::file_size(Twine(File3), File3Size));
ASSERT_EQ(File3Size, 5000ULL);
+ ASSERT_NO_ERROR(fs::remove(File3.str()));
// TEST 4: Verify file can be made executable.
SmallString<128> File4(TestDirectory);
@@ -112,9 +115,9 @@ TEST(FileOutputBuffer, Test) {
ASSERT_NO_ERROR(fs::status(Twine(File4), Status));
bool IsExecutable = (Status.permissions() & fs::owner_exe);
EXPECT_TRUE(IsExecutable);
+ ASSERT_NO_ERROR(fs::remove(File4.str()));
// Clean up.
- uint32_t RemovedCount;
- ASSERT_NO_ERROR(fs::remove_all(TestDirectory.str(), RemovedCount));
+ ASSERT_NO_ERROR(fs::remove(TestDirectory.str()));
}
} // anonymous namespace
diff --git a/unittests/Support/LockFileManagerTest.cpp b/unittests/Support/LockFileManagerTest.cpp
index 3c84f4dcfe..1f949a369e 100644
--- a/unittests/Support/LockFileManagerTest.cpp
+++ b/unittests/Support/LockFileManagerTest.cpp
@@ -40,7 +40,8 @@ TEST(LockFileManagerTest, Basic) {
// Now that the lock is out of scope, the file should be gone.
EXPECT_FALSE(sys::fs::exists(StringRef(LockedFile)));
- sys::fs::remove_all(StringRef(TmpDir));
+ EC = sys::fs::remove(StringRef(TmpDir));
+ ASSERT_FALSE(EC);
}
} // end anonymous namespace
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index 031624162d..f71c7c5640 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -225,8 +225,7 @@ protected:
}
virtual void TearDown() {
- uint32_t removed;
- ASSERT_NO_ERROR(fs::remove_all(TestDirectory.str(), removed));
+ ASSERT_NO_ERROR(fs::remove(TestDirectory.str()));
}
};
@@ -414,6 +413,18 @@ TEST_F(FileSystemTest, DirectoryIteration) {
ASSERT_LT(a0, aa1);
ASSERT_LT(a0, ab1);
ASSERT_LT(z0, za1);
+
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0/aa1"));
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0/ab1"));
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/a0"));
+ ASSERT_NO_ERROR(
+ fs::remove(Twine(TestDirectory) + "/recursive/dontlookhere/da1"));
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/dontlookhere"));
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/pop/p1"));
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/pop"));
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/z0/za1"));
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive/z0"));
+ ASSERT_NO_ERROR(fs::remove(Twine(TestDirectory) + "/recursive"));
}
const char archive[] = "!<arch>\x0A";
@@ -479,6 +490,7 @@ TEST_F(FileSystemTest, Magic) {
ASSERT_NO_ERROR(fs::has_magic(file_pathname.c_str(), magic, res));
EXPECT_TRUE(res);
EXPECT_EQ(i->magic, fs::identify_magic(magic));
+ ASSERT_NO_ERROR(fs::remove(Twine(file_pathname)));
}
}
@@ -509,6 +521,7 @@ TEST_F(FileSystemTest, CarriageReturn) {
MemoryBuffer::getFile(FilePathname.c_str(), Buf);
EXPECT_EQ(Buf->getBuffer(), "\n");
}
+ ASSERT_NO_ERROR(fs::remove(Twine(FilePathname)));
}
#endif