Skip to content

Commit

Permalink
Use prerequisite tags to skip tests that depend on symbolic links
Browse files Browse the repository at this point in the history
Many tests depend on that symbolic links work.  This introduces a check
that sets the prerequisite tag SYMLINKS if the file system supports
symbolic links.  Since so many tests have to check for this prerequisite,
we do the check in test-lib.sh, so that we don't need to repeat the test
in many scripts.

To check for 'ln -s' failures, you can use a FAT partition on Linux:

$ mkdosfs -C git-on-fat 1000000
$ sudo mount -o loop,uid=j6t,gid=users,shortname=winnt git-on-fat /mnt

Clone git to /mnt and

$ GIT_SKIP_TESTS='t0001.1[34] t0010 t1301 t403[34] t4129.[47] t5701.7
          t7701.3 t9100 t9101.26 t9119 t9124.[67] t9200.10 t9600.6' \
        make test

(These additionally skipped tests depend on POSIX permissions that FAT on
Linux does not provide.)

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
  • Loading branch information
Johannes Sixt committed Mar 22, 2009
1 parent 7b7247b commit 704a314
Show file tree
Hide file tree
Showing 32 changed files with 211 additions and 76 deletions.
43 changes: 31 additions & 12 deletions t/t0000-basic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,31 @@ test_expect_success \
'test "$tree" = 4b825dc642cb6eb9a060e54bf8d69288fbee4904'

# Various types of objects
# Some filesystems do not support symblic links; on such systems
# some expected values are different
mkdir path2 path3 path3/subp3
for p in path0 path2/file2 path3/file3 path3/subp3/file3
paths='path0 path2/file2 path3/file3 path3/subp3/file3'
for p in $paths
do
echo "hello $p" >$p
ln -s "hello $p" ${p}sym
done
if test_have_prereq SYMLINKS
then
for p in $paths
do
ln -s "hello $p" ${p}sym
done
expectfilter=cat
expectedtree=087704a96baf1c2d1c869a8b084481e121c88b5b
expectedptree1=21ae8269cacbe57ae09138dcc3a2887f904d02b3
expectedptree2=3c5e5399f3a333eddecce7a9b9465b63f65f51e2
else
expectfilter='grep -v sym'
expectedtree=8e18edf7d7edcf4371a3ac6ae5f07c2641db7c46
expectedptree1=cfb8591b2f65de8b8cc1020cd7d9e67e7793b325
expectedptree2=ce580448f0148b985a513b693fdf7d802cacb44f
fi

test_expect_success \
'adding various types of objects with git update-index --add.' \
'find path* ! -type d -print | xargs git update-index --add'
Expand All @@ -130,7 +149,7 @@ test_expect_success \
'showing stage with git ls-files --stage' \
'git ls-files --stage >current'

cat >expected <<\EOF
$expectfilter >expected <<\EOF
100644 f87290f8eb2cbbea7857214459a0739927eab154 0 path0
120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0 path0sym
100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0 path2/file2
Expand All @@ -149,7 +168,7 @@ test_expect_success \
'tree=$(git write-tree)'
test_expect_success \
'validate object ID for a known tree.' \
'test "$tree" = 087704a96baf1c2d1c869a8b084481e121c88b5b'
'test "$tree" = "$expectedtree"'

test_expect_success \
'showing tree with git ls-tree' \
Expand All @@ -160,7 +179,7 @@ cat >expected <<\EOF
040000 tree 58a09c23e2ca152193f2786e06986b7b6712bdbe path2
040000 tree 21ae8269cacbe57ae09138dcc3a2887f904d02b3 path3
EOF
test_expect_success \
test_expect_success SYMLINKS \
'git ls-tree output for a known tree.' \
'test_cmp expected current'

Expand All @@ -169,7 +188,7 @@ test_expect_success \
test_expect_success \
'showing tree with git ls-tree -r' \
'git ls-tree -r $tree >current'
cat >expected <<\EOF
$expectfilter >expected <<\EOF
100644 blob f87290f8eb2cbbea7857214459a0739927eab154 path0
120000 blob 15a98433ae33114b085f3eb3bb03b832b3180a01 path0sym
100644 blob 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 path2/file2
Expand Down Expand Up @@ -200,7 +219,7 @@ cat >expected <<\EOF
100644 blob 00fb5908cb97c2564a9783c0c64087333b3b464f path3/subp3/file3
120000 blob 6649a1ebe9e9f1c553b66f5a6e74136a07ccc57c path3/subp3/file3sym
EOF
test_expect_success \
test_expect_success SYMLINKS \
'git ls-tree -r output for a known tree.' \
'test_cmp expected current'

Expand All @@ -209,14 +228,14 @@ test_expect_success \
'ptree=$(git write-tree --prefix=path3)'
test_expect_success \
'validate object ID for a known tree.' \
'test "$ptree" = 21ae8269cacbe57ae09138dcc3a2887f904d02b3'
'test "$ptree" = "$expectedptree1"'

test_expect_success \
'writing partial tree out with git write-tree --prefix.' \
'ptree=$(git write-tree --prefix=path3/subp3)'
test_expect_success \
'validate object ID for a known tree.' \
'test "$ptree" = 3c5e5399f3a333eddecce7a9b9465b63f65f51e2'
'test "$ptree" = "$expectedptree2"'

cat >badobjects <<EOF
100644 blob 1000000000000000000000000000000000000000 dir/file1
Expand Down Expand Up @@ -249,7 +268,7 @@ test_expect_success \
newtree=$(git write-tree) &&
test "$newtree" = "$tree"'

cat >expected <<\EOF
$expectfilter >expected <<\EOF
:100644 100644 f87290f8eb2cbbea7857214459a0739927eab154 0000000000000000000000000000000000000000 M path0
:120000 120000 15a98433ae33114b085f3eb3bb03b832b3180a01 0000000000000000000000000000000000000000 M path0sym
:100644 100644 3feff949ed00a62d9f7af97c15cd8a30595e7ac7 0000000000000000000000000000000000000000 M path2/file2
Expand All @@ -272,7 +291,7 @@ test_expect_success \
'git diff-files >current && cmp -s current /dev/null'

################################################################
P=087704a96baf1c2d1c869a8b084481e121c88b5b
P=$expectedtree
test_expect_success \
'git commit-tree records the correct tree in a commit.' \
'commit0=$(echo NO | git commit-tree $P) &&
Expand Down Expand Up @@ -308,7 +327,7 @@ test_expect_success 'update-index D/F conflict' '
test $numpath0 = 1
'

test_expect_success 'absolute path works as expected' '
test_expect_success SYMLINKS 'absolute path works as expected' '
mkdir first &&
ln -s ../.git first/.git &&
mkdir second &&
Expand Down
6 changes: 3 additions & 3 deletions t/t0055-beyond-symlinks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ test_description='update-index and add refuse to add beyond symlinks'

. ./test-lib.sh

test_expect_success setup '
test_expect_success SYMLINKS setup '
>a &&
mkdir b &&
ln -s b c &&
>c/d &&
git update-index --add a b/d
'

test_expect_success 'update-index --add beyond symlinks' '
test_expect_success SYMLINKS 'update-index --add beyond symlinks' '
test_must_fail git update-index --add c/d &&
! ( git ls-files | grep c/d )
'

test_expect_success 'add beyond symlinks' '
test_expect_success SYMLINKS 'add beyond symlinks' '
test_must_fail git add c/d &&
! ( git ls-files | grep c/d )
'
Expand Down
6 changes: 3 additions & 3 deletions t/t1004-read-tree-m-u-wf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ test_expect_success '3-way not overwriting local changes (their side)' '
'

test_expect_success 'funny symlink in work tree' '
test_expect_success SYMLINKS 'funny symlink in work tree' '
git reset --hard &&
git checkout -b sym-b side-b &&
Expand All @@ -177,7 +177,7 @@ test_expect_success 'funny symlink in work tree' '
'

test_expect_success 'funny symlink in work tree, un-unlink-able' '
test_expect_success SYMLINKS 'funny symlink in work tree, un-unlink-able' '
rm -fr a b &&
git reset --hard &&
Expand All @@ -189,7 +189,7 @@ test_expect_success 'funny symlink in work tree, un-unlink-able' '
'

# clean-up from the above test
chmod a+w a
chmod a+w a 2>/dev/null
rm -fr a b

test_expect_success 'D/F setup' '
Expand Down
2 changes: 1 addition & 1 deletion t/t1020-subdirectory.sh
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ test_expect_success 'no file/rev ambiguity check inside a bare repo' '
cd foo.git && git show -s HEAD
'

test_expect_success 'detection should not be fooled by a symlink' '
test_expect_success SYMLINKS 'detection should not be fooled by a symlink' '
cd "$HERE" &&
rm -fr foo.git &&
git clone -s .git another &&
Expand Down
2 changes: 1 addition & 1 deletion t/t1300-repo-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ echo >>result

test_expect_success '--null --get-regexp' 'cmp result expect'

test_expect_success 'symlinked configuration' '
test_expect_success SYMLINKS 'symlinked configuration' '
ln -s notyet myconfig &&
GIT_CONFIG=myconfig git config test.frotz nitfol &&
Expand Down
6 changes: 3 additions & 3 deletions t/t2001-checkout-cache-clash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ test_expect_success \
'git read-tree -m $tree1 && git checkout-index -f -a'
test_debug 'show_files $tree1'

ln -s path0 path1
test_expect_success \
test_expect_success SYMLINKS \
'git update-index --add a symlink.' \
'git update-index --add path1'
'ln -s path0 path1 &&
git update-index --add path1'
test_expect_success \
'writing tree out with git write-tree' \
'tree3=$(git write-tree)'
Expand Down
8 changes: 4 additions & 4 deletions t/t2003-checkout-cache-mkdir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test_expect_success \
echo rezrov >path1/file1 &&
git update-index --add path0 path1/file1'

test_expect_success \
test_expect_success SYMLINKS \
'have symlink in place where dir is expected.' \
'rm -fr path0 path1 &&
mkdir path2 &&
Expand Down Expand Up @@ -59,7 +59,7 @@ test_expect_success \
test ! -f path1/file1'

# Linus fix #1
test_expect_success \
test_expect_success SYMLINKS \
'use --prefix=tmp/orary/ where tmp is a symlink' \
'rm -fr path0 path1 path2 tmp* &&
mkdir tmp1 tmp1/orary &&
Expand All @@ -71,7 +71,7 @@ test_expect_success \
test -h tmp'

# Linus fix #2
test_expect_success \
test_expect_success SYMLINKS \
'use --prefix=tmp/orary- where tmp is a symlink' \
'rm -fr path0 path1 path2 tmp* &&
mkdir tmp1 &&
Expand All @@ -82,7 +82,7 @@ test_expect_success \
test -h tmp'

# Linus fix #3
test_expect_success \
test_expect_success SYMLINKS \
'use --prefix=tmp- where tmp-path1 is a symlink' \
'rm -fr path0 path1 path2 tmp* &&
mkdir tmp1 &&
Expand Down
2 changes: 1 addition & 1 deletion t/t2004-checkout-cache-temp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ test_expect_success \
test $(cat ../$s1) = tree1asubdir/path5)
)'

test_expect_success \
test_expect_success SYMLINKS \
'checkout --temp symlink' '
rm -f path* .merge_* out .git/index &&
ln -s b a &&
Expand Down
6 changes: 6 additions & 0 deletions t/t2007-checkout-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ test_description='git checkout to switch between branches with symlink<->dir'

. ./test-lib.sh

if ! test_have_prereq SYMLINKS
then
say "symbolic links not supported - skipping tests"
test_done
fi

test_expect_success setup '
mkdir frotz &&
Expand Down
14 changes: 12 additions & 2 deletions t/t2100-update-cache-badpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ All of the attempts should fail.

mkdir path2 path3
date >path0
ln -s xyzzy path1
if test_have_prereq SYMLINKS
then
ln -s xyzzy path1
else
date > path1
fi
date >path2/file2
date >path3/file3

Expand All @@ -38,7 +43,12 @@ rm -fr path?

mkdir path0 path1
date >path2
ln -s frotz path3
if test_have_prereq SYMLINKS
then
ln -s frotz path3
else
date > path3
fi
date >path0/file0
date >path1/file1

Expand Down
2 changes: 1 addition & 1 deletion t/t2200-add-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test_expect_success 'change gets noticed' '
'

test_expect_success 'replace a file with a symlink' '
test_expect_success SYMLINKS 'replace a file with a symlink' '
rm foo &&
ln -s top foo &&
Expand Down
16 changes: 13 additions & 3 deletions t/t2201-add-update-typechange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ test_expect_success setup '
_empty=$(git hash-object --stdin <xyzzy) &&
>yomin &&
>caskly &&
ln -s frotz nitfol &&
if test_have_prereq SYMLINKS; then
ln -s frotz nitfol &&
T_letter=T
else
printf %s frotz > nitfol &&
T_letter=M
fi &&
mkdir rezrov &&
>rezrov/bozbar &&
git add caskly xyzzy yomin nitfol rezrov/bozbar &&
Expand All @@ -29,7 +35,11 @@ test_expect_success modify '
>nitfol &&
# rezrov/bozbar disappears
rm -fr rezrov &&
ln -s xyzzy rezrov &&
if test_have_prereq SYMLINKS; then
ln -s xyzzy rezrov
else
printf %s xyzzy > rezrov
fi &&
# xyzzy disappears (not a submodule)
mkdir xyzzy &&
echo gnusto >xyzzy/bozbar &&
Expand Down Expand Up @@ -71,7 +81,7 @@ test_expect_success modify '
s/blob/000000/
}
/ nitfol/{
s/ nitfol/ $_z40 T&/
s/ nitfol/ $_z40 $T_letter&/
s/blob/100644/
}
/ rezrov.bozbar/{
Expand Down
14 changes: 7 additions & 7 deletions t/t2300-cd-to-toplevel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test_description='cd_to_toplevel'
. ./test-lib.sh

test_cd_to_toplevel () {
test_expect_success "$2" '
test_expect_success $3 "$2" '
(
cd '"'$1'"' &&
. git-sh-setup &&
Expand All @@ -24,14 +24,14 @@ test_cd_to_toplevel repo 'at physical root'

test_cd_to_toplevel repo/sub/dir 'at physical subdir'

ln -s repo symrepo
test_cd_to_toplevel symrepo 'at symbolic root'
ln -s repo symrepo 2>/dev/null
test_cd_to_toplevel symrepo 'at symbolic root' SYMLINKS

ln -s repo/sub/dir subdir-link
test_cd_to_toplevel subdir-link 'at symbolic subdir'
ln -s repo/sub/dir subdir-link 2>/dev/null
test_cd_to_toplevel subdir-link 'at symbolic subdir' SYMLINKS

cd repo
ln -s sub/dir internal-link
test_cd_to_toplevel internal-link 'at internal symbolic subdir'
ln -s sub/dir internal-link 2>/dev/null
test_cd_to_toplevel internal-link 'at internal symbolic subdir' SYMLINKS

test_done
7 changes: 6 additions & 1 deletion t/t3000-ls-files-others.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ filesystem.
. ./test-lib.sh

date >path0
ln -s xyzzy path1
if test_have_prereq SYMLINKS
then
ln -s xyzzy path1
else
date > path1
fi
mkdir path2 path3
date >path2/file2
date >path2-junk
Expand Down
Loading

0 comments on commit 704a314

Please sign in to comment.