aboutsummaryrefslogtreecommitdiffstats
path: root/unittests/Support/Path.cpp
diff options
context:
space:
mode:
authorMichael J. Spencer <bigcheesegs@gmail.com>2011-01-05 16:39:05 +0000
committerMichael J. Spencer <bigcheesegs@gmail.com>2011-01-05 16:39:05 +0000
commit2558516859ac52a17c85afff01073303bd522979 (patch)
tree75d147b551ec0c0a5cf4b7b745453ce7cb388475 /unittests/Support/Path.cpp
parentda7c1cab8c083e3370cc94a23bc396cd75b7f2a7 (diff)
downloadexternal_llvm-2558516859ac52a17c85afff01073303bd522979.tar.gz
external_llvm-2558516859ac52a17c85afff01073303bd522979.tar.bz2
external_llvm-2558516859ac52a17c85afff01073303bd522979.zip
UnitTests/PathV2: Setup a test fixture to make tracking created file system
entities easier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122880 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Support/Path.cpp')
-rw-r--r--unittests/Support/Path.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index a4fb518255..132d43950b 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -123,7 +123,29 @@ TEST(Support, Path) {
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 @@ TEST(Support, Path) {
// 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) {