diff options
author | Simon Atanasyan <simon@atanasyan.com> | 2018-11-20 21:13:51 +0000 |
---|---|---|
committer | Simon Atanasyan <simon@atanasyan.com> | 2018-11-20 21:13:51 +0000 |
commit | 13cacb274ad5ff44d6ba56b454bbd6a276fda0d8 (patch) | |
tree | bf65967e65ff440380ca98927f628bc455ccb605 /llvm/unittests/Support/Path.cpp | |
parent | 02e1f1915f94413a64efd295fa3dc63d40046fcf (diff) | |
download | bcm5719-llvm-13cacb274ad5ff44d6ba56b454bbd6a276fda0d8.tar.gz bcm5719-llvm-13cacb274ad5ff44d6ba56b454bbd6a276fda0d8.zip |
[unittests] Fix ExpandTilde test to match handling home dirs with trailing slash
The `expandTildeExpr` routine just replaces a tilde by a home dir path.
If the home dir has a trailing slash, the result of substitution will
contain double slashes. For example, `HOME=/foo/ ~/bar` gives `/foo//bar`.
That corresponds to (at least) Bash behaviour because the following
command `$HOME=/foo/ echo ~/bar` prints `/foo//bar`.
The `ExpandTilde` test constructs a path expected as the `fs::expand_tilde`
call result by calling `path::append` and the expected path has a single
slash. This patch fixes that and allows to pass the unittest on hosts where
the `HOME` is `/`.
Differential Revision: http://reviews.llvm.org/D54752
llvm-svn: 347346
Diffstat (limited to 'llvm/unittests/Support/Path.cpp')
-rw-r--r-- | llvm/unittests/Support/Path.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp index 3a9d3187fd0..40faa669f87 100644 --- a/llvm/unittests/Support/Path.cpp +++ b/llvm/unittests/Support/Path.cpp @@ -543,11 +543,11 @@ TEST_F(FileSystemTest, ExpandTilde) { fs::expand_tilde("~", Actual); EXPECT_EQ(Expected, Actual); - path::append(Expected, "foo"); - #ifdef _WIN32 + Expected += "\\foo"; fs::expand_tilde("~\\foo", Actual); #else + Expected += "/foo"; fs::expand_tilde("~/foo", Actual); #endif |