Merge branch 'tb/maint-t9200-case-insensitive'
[gitweb.git] / t / t0060-path-utils.sh
index d91e5167503d2cecc2ae2d83a20b1ba1a71a5b0f..4ef2345982fe0e0c175ed67edcb20b04c81b9680 100755 (executable)
@@ -140,11 +140,47 @@ test_expect_success 'strip_path_suffix' '
                c:/msysgit/libexec//git-core libexec/git-core)
 '
 
-test_expect_failure 'absolute path rejects the empty string' '
+test_expect_success 'absolute path rejects the empty string' '
        test_must_fail test-path-utils absolute_path ""
 '
 
-test_expect_success SYMLINKS 'real path works as expected' '
+test_expect_success 'real path rejects the empty string' '
+       test_must_fail test-path-utils real_path ""
+'
+
+test_expect_success POSIX 'real path works on absolute paths 1' '
+       nopath="hopefully-absent-path" &&
+       test "/" = "$(test-path-utils real_path "/")" &&
+       test "/$nopath" = "$(test-path-utils real_path "/$nopath")"
+'
+
+test_expect_success 'real path works on absolute paths 2' '
+       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 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 &&
        mkdir second &&