diff options
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r-- | llvm/unittests/Support/Path.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index c18eb929e91..854b69b6825 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -516,6 +516,8 @@ TEST_F(FileSystemTest, RealPath) { EXPECT_EQ(Expected, Actual); SmallString<64> HomeDir; + + // This can fail if $HOME is not set and getpwuid fails. bool Result = llvm::sys::path::home_directory(HomeDir); if (Result) { ASSERT_NO_ERROR(fs::real_path(HomeDir, Expected)); @@ -528,6 +530,25 @@ TEST_F(FileSystemTest, RealPath) { ASSERT_NO_ERROR(fs::remove_directories(Twine(TestDirectory) + "/test1")); } +TEST_F(FileSystemTest, ExpandTilde) { + SmallString<64> Expected; + SmallString<64> Actual; + SmallString<64> HomeDir; + + // This can fail if $HOME is not set and getpwuid fails. + bool Result = llvm::sys::path::home_directory(HomeDir); + if (Result) { + fs::expand_tilde(HomeDir, Expected); + + fs::expand_tilde("~", Actual); + EXPECT_EQ(Expected, Actual); + + path::append(Expected, "foo"); + fs::expand_tilde("~/foo", Actual); + EXPECT_EQ(Expected, Actual); + } +} + #ifdef LLVM_ON_UNIX TEST_F(FileSystemTest, RealPathNoReadPerm) { SmallString<64> Expanded; |