t5003: check if unzip supports symlinks

Only add a symlink to the repository if both the filesystem and unzip support symlinks. To check the latter, add a ZIP file containing a symlink, created like this with InfoZIP zip 3.0: $ echo sample text >textfile $ ln -s textfile symlink $ zip -y infozip-symlinks.zip textfile symlink If we can extract it successfully, we add a symlink to the test repository for git archive --format=zip, or otherwise skip that step. Users can see the skipped test and perhaps run it again with a different unzip version. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Jan 6, 2013 at 18:59 UTC 55292ea25dca1f3273b4e59aa37ee66cae4aa343
2 files changed +19 -7
t/t5003-archive-zip.sh
+19 -7
@@ -12,6 +12,15 @@ test_lazy_prereq UNZIP '
12 test $? -ne 127
13 '
14
15 +test_lazy_prereq UNZIP_SYMLINKS '
16 + (
17 + mkdir unzip-symlinks &&
18 + cd unzip-symlinks &&
19 + "$GIT_UNZIP" "$TEST_DIRECTORY"/t5003/infozip-symlinks.zip &&
20 + test -h symlink
21 + )
22 +'
23 +
24 check_zip() {
25 zipfile=$1.zip
26 listfile=$1.lst
@@ -40,15 +49,18 @@ test_expect_success \
49 cp /bin/sh a/bin &&
50 printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
51 printf "A not substituted O" >a/substfile2 &&
43 - if test_have_prereq SYMLINKS; then
44 - ln -s a a/l1
45 - else
46 - printf %s a > a/l1
47 - fi &&
52 (p=long_path_to_a_file && cd a &&
53 for depth in 1 2 3 4 5; do mkdir $p && cd $p; done &&
50 - echo text >file_with_long_path) &&
51 - (cd a && find .) | sort >a.lst'
54 + echo text >file_with_long_path)
55 +'
56 +
57 +test_expect_success SYMLINKS,UNZIP_SYMLINKS 'add symlink' '
58 + ln -s a a/symlink_to_a
59 +'
60 +
61 +test_expect_success 'prepare file list' '
62 + (cd a && find .) | sort >a.lst
63 +'
64
65 test_expect_success \
66 'add ignored file' \
t/t5003/infozip-symlinks.zip
Binary files /dev/null and b/t/t5003/infozip-symlinks.zip differ