summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2013-06-27 03:45:31 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2013-06-27 03:45:31 +0000
commit08ddd12e444880b4d570ac42a42414a227022190 (patch)
treed47e948fb007aea27ccdfd68c38dd88a2df19026 /unittests
parente2b9912a7877d0c73e0c5863ae2ea668edca1de4 (diff)
downloadllvm-08ddd12e444880b4d570ac42a42414a227022190.tar.gz
llvm-08ddd12e444880b4d570ac42a42414a227022190.tar.bz2
llvm-08ddd12e444880b4d570ac42a42414a227022190.tar.xz
Add a convenience createUniqueDirectory function.
There are a few valid situation where we care about the structure inside a directory, but not about the directory itself. A simple example is for unit testing directory traversal. PathV1 had a function like this, add one to V2 and port existing users of the created temp file and delete it hack to using it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185059 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Support/FileOutputBufferTest.cpp6
-rw-r--r--unittests/Support/Path.cpp6
2 files changed, 2 insertions, 10 deletions
diff --git a/unittests/Support/FileOutputBufferTest.cpp b/unittests/Support/FileOutputBufferTest.cpp
index c7ca1ab6a6..5e873193f2 100644
--- a/unittests/Support/FileOutputBufferTest.cpp
+++ b/unittests/Support/FileOutputBufferTest.cpp
@@ -30,12 +30,8 @@ TEST(FileOutputBuffer, Test) {
// Create unique temporary directory for these tests
SmallString<128> TestDirectory;
{
- int fd;
ASSERT_NO_ERROR(
- fs::unique_file("FileOutputBuffer-test-%%-%%-%%-%%/dir", fd,
- TestDirectory));
- ::close(fd);
- TestDirectory = path::parent_path(TestDirectory);
+ fs::createUniqueDirectory("FileOutputBuffer-test", TestDirectory));
}
// TEST 1: Verify commit case.
diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp
index d5591ea1bd..ce335ccc6b 100644
--- a/unittests/Support/Path.cpp
+++ b/unittests/Support/Path.cpp
@@ -147,13 +147,9 @@ protected:
SmallString<128> TestDirectory;
virtual void SetUp() {
- int fd;
ASSERT_NO_ERROR(
- fs::unique_file("file-system-test-%%-%%-%%-%%/test-directory.anchor", fd,
- TestDirectory));
+ fs::createUniqueDirectory("file-system-test", TestDirectory));
// We don't care about this specific file.
- ::close(fd);
- TestDirectory = path::parent_path(TestDirectory);
errs() << "Test Directory: " << TestDirectory << '\n';
errs().flush();
}