1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 11:02:59 +02:00

SupportTests::HomeDirectory: Don't try tests when $HOME is undefined.

Lit sanitizes env vars. $HOME is not exported in Lit tests.

llvm-svn: 250505
This commit is contained in:
NAKAMURA Takumi 2015-10-16 09:40:01 +00:00
parent 56bba74d41
commit 996d217689

View File

@ -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 {