diff options
Diffstat (limited to 't')
-rwxr-xr-x | t/t0000-basic.sh | 18 | ||||
-rwxr-xr-x | t/t0060-path-utils.sh | 59 |
2 files changed, 59 insertions, 18 deletions
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index ccb5435b2a..ae6a3f0777 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -450,24 +450,6 @@ test_expect_success 'update-index D/F conflict' ' test $numpath0 = 1 ' -test_expect_success SYMLINKS 'real path works as expected' ' - mkdir first && - ln -s ../.git first/.git && - mkdir second && - ln -s ../first second/other && - mkdir third && - dir="$(cd .git; pwd -P)" && - dir2=third/../second/other/.git && - test "$dir" = "$(test-path-utils real_path $dir2)" && - file="$dir"/index && - test "$file" = "$(test-path-utils real_path $dir2/index)" && - basename=blub && - test "$dir/$basename" = "$(cd .git && test-path-utils real_path "$basename")" && - ln -s ../first/file .git/syml && - sym="$(cd first; pwd -P)"/file && - test "$sym" = "$(test-path-utils real_path "$dir2/syml")" -' - test_expect_success 'very long name in the index handled sanely' ' a=a && # 1 diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh index 53cf1f8dc4..4ef2345982 100755 --- a/t/t0060-path-utils.sh +++ b/t/t0060-path-utils.sh @@ -139,4 +139,63 @@ test_expect_success 'strip_path_suffix' ' test c:/msysgit = $(test-path-utils strip_path_suffix \ c:/msysgit/libexec//git-core libexec/git-core) ' + +test_expect_success 'absolute path rejects the empty string' ' + test_must_fail test-path-utils absolute_path "" +' + +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 && + ln -s ../first second/other && + mkdir third && + dir="$(cd .git; pwd -P)" && + dir2=third/../second/other/.git && + test "$dir" = "$(test-path-utils real_path $dir2)" && + file="$dir"/index && + test "$file" = "$(test-path-utils real_path $dir2/index)" && + basename=blub && + test "$dir/$basename" = "$(cd .git && test-path-utils real_path "$basename")" && + ln -s ../first/file .git/syml && + sym="$(cd first; pwd -P)"/file && + test "$sym" = "$(test-path-utils real_path "$dir2/syml")" +' + test_done |