[PATCH] D54752: [unittests] Fix ExpandTilde test to match handling home dirs with trailing slash
Simon Atanasyan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 20 05:49:42 PST 2018
atanasyan created this revision.
atanasyan added reviewers: zturner, JDevlieghere, Bigcheese, sammccall.
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 slash. 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 `/`.
Repository:
rL LLVM
https://reviews.llvm.org/D54752
Files:
unittests/Support/Path.cpp
Index: unittests/Support/Path.cpp
===================================================================
--- unittests/Support/Path.cpp
+++ unittests/Support/Path.cpp
@@ -543,11 +543,11 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54752.174756.patch
Type: text/x-patch
Size: 460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181120/3fd0fdea/attachment.bin>
More information about the llvm-commits
mailing list