t0060: verify that real_path() removes extra slashes
authorMichael Haggerty <mhagger@alum.mit.edu>
Thu, 6 Sep 2012 22:41:04 +0000 (00:41 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Sep 2012 23:19:58 +0000 (16:19 -0700)
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>
t/t0060-path-utils.sh

index 30361f94a43b875605bd1c51d99dc3dfbc674003..e40f764d54be4993df6e442b541756917f4289df 100755 (executable)
@@ -158,6 +158,24 @@ test_expect_success POSIX 'real path works on absolute paths' '
        test "$d/$nopath" = "$(test-path-utils real_path "$d/$nopath")"
 '
 
+test_expect_success POSIX 'real path removes extra leading slashes' '
+       nopath="hopefully-absent-path" &&
+       test "/" = "$(test-path-utils real_path "///")" &&
+       test "/$nopath" = "$(test-path-utils real_path "///$nopath")" &&
+       # Find an existing top-level directory for the remaining tests:
+       d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
+       test "$d" = "$(test-path-utils real_path "//$d")" &&
+       test "$d/$nopath" = "$(test-path-utils real_path "//$d/$nopath")"
+'
+
+test_expect_success 'real path removes other extra slashes' '
+       nopath="hopefully-absent-path" &&
+       # Find an existing top-level directory for the remaining tests:
+       d=$(pwd -P | sed -e "s|^\([^/]*/[^/]*\)/.*|\1|") &&
+       test "$d" = "$(test-path-utils real_path "$d///")" &&
+       test "$d/$nopath" = "$(test-path-utils real_path "$d///$nopath")"
+'
+
 test_expect_success SYMLINKS 'real path works on symlinks' '
        mkdir first &&
        ln -s ../.git first/.git &&