summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Support/Path.cpp
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2015-10-16 09:40:01 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2015-10-16 09:40:01 +0000
commitcc275e428dd2a4a2401992a857f1610d7dbff993 (patch)
tree64c9dbb720f9c69ed95a3e3ab511009a79f69060 /llvm/unittests/Support/Path.cpp
parent6d5d5bdfaf82b5137832fc7befd525518b645aee (diff)
downloadbcm5719-llvm-cc275e428dd2a4a2401992a857f1610d7dbff993.tar.gz
bcm5719-llvm-cc275e428dd2a4a2401992a857f1610d7dbff993.zip
SupportTests::HomeDirectory: Don't try tests when $HOME is undefined.
Lit sanitizes env vars. $HOME is not exported in Lit tests. llvm-svn: 250505
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r--llvm/unittests/Support/Path.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index e8cd98b8cfa..044e80fe363 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -300,19 +300,22 @@ TEST(Support, AbsolutePathIteratorEnd) {
}
TEST(Support, HomeDirectory) {
+ std::string expected;
#ifdef LLVM_ON_WIN32
wchar_t *path = ::_wgetenv(L"USERPROFILE");
auto pathLen = ::wcslen(path);
ArrayRef<char> ref{reinterpret_cast<char *>(path), pathLen * sizeof(wchar_t)};
- std::string expected;
convertUTF16ToUTF8String(ref, expected);
#else
- std::string expected{::getenv("HOME")};
+ if (char const *home = ::getenv("HOME"))
+ expected = home;
#endif
- SmallString<128> HomeDir;
- auto status = path::home_directory(HomeDir);
- EXPECT_TRUE(status ^ HomeDir.empty());
- EXPECT_EQ(expected, HomeDir);
+ if (expected.length() > 0) {
+ SmallString<128> HomeDir;
+ auto status = path::home_directory(HomeDir);
+ EXPECT_TRUE(status ^ HomeDir.empty());
+ EXPECT_EQ(expected, HomeDir);
+ }
}
class FileSystemTest : public testing::Test {
OpenPOWER on IntegriCloud