t0060: verify that real_path() removes extra slashes

Adjusted for Windows by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael Haggerty committed Sep 7, 2012 at 00:41 UTC 379a03ad8194192ab7b2910ec3326a981971fda1
1 file changed +18
t/t0060-path-utils.sh
+18
@@ -158,6 +158,24 @@ test_expect_success POSIX 'real path works on absolute paths' '
158 test "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")"
159 '
160
161 +test_expect_success POSIX 'real path removes extra leading slashes' '
162 + nopath="hopefully-absent-path" &&
163 + test "/" = "$(test-path-utils real_path "///")" &&
164 + test "/$nopath" = "$(test-path-utils real_path "///$nopath")" &&
165 + # Find an existing top-level directory for the remaining tests:
166 + d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
167 + test "$d" = "$(test-path-utils real_path "//$d")" &&
168 + test "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")"
169 +'
170 +
171 +test_expect_success 'real path removes other extra slashes' '
172 + nopath="hopefully-absent-path" &&
173 + # Find an existing top-level directory for the remaining tests:
174 + d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
175 + test "$d" = "$(test-path-utils real_path "$d///")" &&
176 + test "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")"
177 +'
178 +
179 test_expect_success SYMLINKS 'real path works on symlinks' '
180 mkdir first &&
181 ln -s ../.git first/.git &&