completion: refactor __gitcomp related tests
[gitweb.git] / t / t0060-path-utils.sh
index 3121691c6f34f03b9b17e9e0717283f60b5e2255..4ef2345982fe0e0c175ed67edcb20b04c81b9680 100755 (executable)
@@ -148,16 +148,38 @@ test_expect_success 'real path rejects the empty string' '
        test_must_fail test-path-utils real_path ""
 '
 
-test_expect_failure POSIX 'real path works on absolute paths' '
+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 "/$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 &&