[llvm] r347346 - [unittests] Fix ExpandTilde test to match handling home dirs with trailing slash
Simon Atanasyan via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 20 13:13:52 PST 2018
Author: atanasyan
Date: Tue Nov 20 13:13:51 2018
New Revision: 347346
URL: http://llvm.org/viewvc/llvm-project?rev=347346&view=rev
Log:
[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
Modified:
llvm/trunk/unittests/Support/Path.cpp
Modified: llvm/trunk/unittests/Support/Path.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/Path.cpp?rev=347346&r1=347345&r2=347346&view=diff
==============================================================================
--- llvm/trunk/unittests/Support/Path.cpp (original)
+++ llvm/trunk/unittests/Support/Path.cpp Tue Nov 20 13:13:51 2018
@@ -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
More information about the llvm-commits
mailing list