Merge branch 'jk/test-without-readlink-1'

Some test scripts assumed that readlink(1) was universally
installed and available, which is not the case.

* jk/test-without-readlink-1:
  t: use portable wrapper for readlink(1)
This commit is contained in:
Junio C Hamano 2021-07-08 13:15:02 -07:00
commit 62473695d2
3 changed files with 9 additions and 3 deletions

View File

@ -253,7 +253,7 @@ test_expect_success SYMLINKS 'pack symlinked packed-refs' '
git for-each-ref >all-refs-packed && git for-each-ref >all-refs-packed &&
test_cmp all-refs-before all-refs-packed && test_cmp all-refs-before all-refs-packed &&
test -h .git/packed-refs && test -h .git/packed-refs &&
test "$(readlink .git/packed-refs)" = "my-deviant-packed-refs" test "$(test_readlink .git/packed-refs)" = "my-deviant-packed-refs"
' '
test_done test_done

View File

@ -263,7 +263,7 @@ test_expect_success SYMLINKS 'ensure p4 symlink parsed correctly' '
( (
cd "$git" && cd "$git" &&
test -L symlink && test -L symlink &&
test $(readlink symlink) = symlink-target test $(test_readlink symlink) = symlink-target
) )
' '
@ -329,7 +329,7 @@ test_expect_success SYMLINKS 'empty symlink target' '
git p4 clone --dest="$git" //depot@all && git p4 clone --dest="$git" //depot@all &&
( (
cd "$git" && cd "$git" &&
test $(readlink empty-symlink) = target2 test $(test_readlink empty-symlink) = target2
) )
' '

View File

@ -1708,3 +1708,9 @@ test_region () {
return 0 return 0
} }
# Print the destination of symlink(s) provided as arguments. Basically
# the same as the readlink command, but it's not available everywhere.
test_readlink () {
perl -le 'print readlink($_) for @ARGV' "$@"
}