From bef2236283c333f17613b2ea4904878228fedb6e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Fri, 31 Jan 2014 23:46:06 +0000 Subject: Introduce llvm::sys::path::home_directory. This will be used by the line editor library to derive a default path to the history file. Differential Revision: http://llvm-reviews.chandlerc.com/D2199 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200594 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Support/Path.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'unittests') diff --git a/unittests/Support/Path.cpp b/unittests/Support/Path.cpp index f71c7c5640..197e1c2f86 100644 --- a/unittests/Support/Path.cpp +++ b/unittests/Support/Path.cpp @@ -210,6 +210,19 @@ TEST(Support, AbsolutePathIteratorWin32) { } #endif // LLVM_ON_WIN32 +TEST(Support, HomeDirectory) { +#ifdef LLVM_ON_UNIX + // This test only makes sense on Unix if $HOME is set. + if (::getenv("HOME")) { +#endif + SmallString<128> HomeDir; + EXPECT_TRUE(path::home_directory(HomeDir)); + EXPECT_FALSE(HomeDir.empty()); +#ifdef LLVM_ON_UNIX + } +#endif +} + class FileSystemTest : public testing::Test { protected: /// Unique temporary directory in which all created filesystem entities must -- cgit v1.2.3