Skip to content

Commit

Permalink
tests: implicitly skip SYMLINKS tests using <prereq>
Browse files Browse the repository at this point in the history
Change the tests that skipped due to unavailable SYMLINKS support to
use the three-arg prereq form of test_expect_success.

Now we get an indication of how many tests that need symlinks are
being skipped on platforms that don't support them.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ævar Arnfjörð Bjarmason authored and Junio C Hamano committed Aug 18, 2010
1 parent e146d17 commit 41be8ea
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 90 deletions.
14 changes: 4 additions & 10 deletions t/t2007-checkout-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,7 @@ test_description='git checkout to switch between branches with symlink<->dir'

. ./test-lib.sh

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

test_expect_success setup '
test_expect_success SYMLINKS setup '
mkdir frotz &&
echo hello >frotz/filfre &&
Expand All @@ -38,18 +32,18 @@ test_expect_success setup '
'

test_expect_success 'switch from symlink to dir' '
test_expect_success SYMLINKS 'switch from symlink to dir' '
git checkout master
'

test_expect_success 'Remove temporary directories & switch to master' '
test_expect_success SYMLINKS 'Remove temporary directories & switch to master' '
rm -fr frotz xyzzy nitfol &&
git checkout -f master
'

test_expect_success 'switch from dir to symlink' '
test_expect_success SYMLINKS 'switch from dir to symlink' '
git checkout side
Expand Down
18 changes: 6 additions & 12 deletions t/t4011-diff-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ test_description='Test diff of symlinks.
. ./test-lib.sh
. "$TEST_DIRECTORY"/diff-lib.sh

if ! test_have_prereq SYMLINKS
then
skip_all='Symbolic links not supported, skipping tests.'
test_done
fi

cat > expected << EOF
diff --git a/frotz b/frotz
new file mode 120000
Expand All @@ -26,7 +20,7 @@ index 0000000..7c465af
\ No newline at end of file
EOF

test_expect_success \
test_expect_success SYMLINKS \
'diff new symlink' \
'ln -s xyzzy frotz &&
git update-index &&
Expand All @@ -35,7 +29,7 @@ test_expect_success \
GIT_DIFF_OPTS=--unified=0 git diff-index -M -p $tree > current &&
compare_diff_patch current expected'

test_expect_success \
test_expect_success SYMLINKS \
'diff unchanged symlink' \
'tree=$(git write-tree) &&
git update-index frotz &&
Expand All @@ -52,7 +46,7 @@ index 7c465af..0000000
\ No newline at end of file
EOF

test_expect_success \
test_expect_success SYMLINKS \
'diff removed symlink' \
'mv frotz frotz2 &&
git diff-index -M -p $tree > current &&
Expand All @@ -62,7 +56,7 @@ cat > expected << EOF
diff --git a/frotz b/frotz
EOF

test_expect_success \
test_expect_success SYMLINKS \
'diff identical, but newly created symlink' \
'ln -s xyzzy frotz &&
git diff-index -M -p $tree > current &&
Expand All @@ -80,14 +74,14 @@ index 7c465af..df1db54 120000
\ No newline at end of file
EOF

test_expect_success \
test_expect_success SYMLINKS \
'diff different symlink' \
'rm frotz &&
ln -s yxyyz frotz &&
git diff-index -M -p $tree > current &&
compare_diff_patch current expected'

test_expect_success \
test_expect_success SYMLINKS \
'diff symlinks with non-existing targets' \
'ln -s narf pinky &&
ln -s take\ over brain &&
Expand Down
14 changes: 4 additions & 10 deletions t/t4023-diff-rename-typechange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,7 @@ test_description='typechange rename detection'

. ./test-lib.sh

if ! test_have_prereq SYMLINKS
then
skip_all='Symbolic links not supported, skipping tests.'
test_done
fi

test_expect_success setup '
test_expect_success SYMLINKS setup '
rm -f foo bar &&
cat "$TEST_DIRECTORY"/../COPYING >foo &&
Expand Down Expand Up @@ -56,7 +50,7 @@ test_expect_success setup '
'

test_expect_success 'cross renames to be detected for regular files' '
test_expect_success SYMLINKS 'cross renames to be detected for regular files' '
git diff-tree five six -r --name-status -B -M | sort >actual &&
{
Expand All @@ -67,7 +61,7 @@ test_expect_success 'cross renames to be detected for regular files' '
'

test_expect_success 'cross renames to be detected for typechange' '
test_expect_success SYMLINKS 'cross renames to be detected for typechange' '
git diff-tree one two -r --name-status -B -M | sort >actual &&
{
Expand All @@ -78,7 +72,7 @@ test_expect_success 'cross renames to be detected for typechange' '
'

test_expect_success 'moves and renames' '
test_expect_success SYMLINKS 'moves and renames' '
git diff-tree three four -r --name-status -B -M | sort >actual &&
{
Expand Down
28 changes: 11 additions & 17 deletions t/t4114-apply-typechange.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ test_description='git apply should not get confused with type changes.

. ./test-lib.sh

if ! test_have_prereq SYMLINKS
then
skip_all='Symbolic links not supported, skipping tests.'
test_done
fi

test_expect_success 'setup repository and commits' '
test_expect_success SYMLINKS 'setup repository and commits' '
echo "hello world" > foo &&
echo "hi planet" > bar &&
git update-index --add foo bar &&
Expand Down Expand Up @@ -48,77 +42,77 @@ test_expect_success 'setup repository and commits' '
git branch foo-baz-renamed-from-foo
'

test_expect_success 'file renamed from foo to foo/baz' '
test_expect_success SYMLINKS 'file renamed from foo to foo/baz' '
git checkout -f initial &&
git diff-tree -M -p HEAD foo-baz-renamed-from-foo > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success 'file renamed from foo/baz to foo' '
test_expect_success SYMLINKS 'file renamed from foo/baz to foo' '
git checkout -f foo-baz-renamed-from-foo &&
git diff-tree -M -p HEAD initial > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success 'directory becomes file' '
test_expect_success SYMLINKS 'directory becomes file' '
git checkout -f foo-becomes-a-directory &&
git diff-tree -p HEAD initial > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success 'file becomes directory' '
test_expect_success SYMLINKS 'file becomes directory' '
git checkout -f initial &&
git diff-tree -p HEAD foo-becomes-a-directory > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success 'file becomes symlink' '
test_expect_success SYMLINKS 'file becomes symlink' '
git checkout -f initial &&
git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success 'symlink becomes file' '
test_expect_success SYMLINKS 'symlink becomes file' '
git checkout -f foo-symlinked-to-bar &&
git diff-tree -p HEAD foo-back-to-file > patch &&
git apply --index < patch
'
test_debug 'cat patch'

test_expect_success 'binary file becomes symlink' '
test_expect_success SYMLINKS 'binary file becomes symlink' '
git checkout -f foo-becomes-binary &&
git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch &&
git apply --index < patch
'
test_debug 'cat patch'

test_expect_success 'symlink becomes binary file' '
test_expect_success SYMLINKS 'symlink becomes binary file' '
git checkout -f foo-symlinked-to-bar &&
git diff-tree -p --binary HEAD foo-becomes-binary > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success 'symlink becomes directory' '
test_expect_success SYMLINKS 'symlink becomes directory' '
git checkout -f foo-symlinked-to-bar &&
git diff-tree -p HEAD foo-becomes-a-directory > patch &&
git apply --index < patch
'
test_debug 'cat patch'


test_expect_success 'directory becomes symlink' '
test_expect_success SYMLINKS 'directory becomes symlink' '
git checkout -f foo-becomes-a-directory &&
git diff-tree -p HEAD foo-symlinked-to-bar > patch &&
git apply --index < patch
Expand Down
12 changes: 3 additions & 9 deletions t/t4115-apply-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ test_description='git apply symlinks and partial files

. ./test-lib.sh

if ! test_have_prereq SYMLINKS
then
skip_all='Symbolic links not supported, skipping tests.'
test_done
fi

test_expect_success setup '
test_expect_success SYMLINKS setup '
ln -s path1/path2/path3/path4/path5 link1 &&
git add link? &&
Expand All @@ -34,7 +28,7 @@ test_expect_success setup '
'

test_expect_success 'apply symlink patch' '
test_expect_success SYMLINKS 'apply symlink patch' '
git checkout side &&
git apply patch &&
Expand All @@ -43,7 +37,7 @@ test_expect_success 'apply symlink patch' '
'

test_expect_success 'apply --index symlink patch' '
test_expect_success SYMLINKS 'apply --index symlink patch' '
git checkout -f side &&
git apply --index patch &&
Expand Down
12 changes: 3 additions & 9 deletions t/t4122-apply-symlink-inside.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@
test_description='apply to deeper directory without getting fooled with symlink'
. ./test-lib.sh

if ! test_have_prereq SYMLINKS
then
skip_all='Symbolic links not supported, skipping tests.'
test_done
fi

lecho () {
for l_
do
echo "$l_"
done
}

test_expect_success setup '
test_expect_success SYMLINKS setup '
mkdir -p arch/i386/boot arch/x86_64 &&
lecho 1 2 3 4 5 >arch/i386/boot/Makefile &&
Expand All @@ -37,7 +31,7 @@ test_expect_success setup '
'

test_expect_success apply '
test_expect_success SYMLINKS apply '
git checkout test &&
git diff --exit-code test &&
Expand All @@ -46,7 +40,7 @@ test_expect_success apply '
'

test_expect_success 'check result' '
test_expect_success SYMLINKS 'check result' '
git diff --exit-code master &&
git diff --exit-code --cached master &&
Expand Down
14 changes: 4 additions & 10 deletions t/t5522-pull-symlink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ test_description='pulling from symlinked subdir'

. ./test-lib.sh

if ! test_have_prereq SYMLINKS
then
skip_all='Symbolic links not supported, skipping tests.'
test_done
fi

# The scenario we are building:
#
# trash\ directory/
Expand All @@ -20,7 +14,7 @@ fi
#
# The working directory is subdir-link.

test_expect_success setup '
test_expect_success SYMLINKS setup '
mkdir subdir &&
echo file >subdir/file &&
git add subdir/file &&
Expand All @@ -36,7 +30,7 @@ test_expect_success setup '

# Demonstrate that things work if we just avoid the symlink
#
test_expect_success 'pulling from real subdir' '
test_expect_success SYMLINKS 'pulling from real subdir' '
(
echo real >subdir/file &&
git commit -m real subdir/file &&
Expand Down Expand Up @@ -64,7 +58,7 @@ test_expect_success 'pulling from real subdir' '
# directory. A POSIX shell's "cd" works a little differently
# than chdir() in C; "cd -P" is much closer to chdir().
#
test_expect_success 'pulling from symlinked subdir' '
test_expect_success SYMLINKS 'pulling from symlinked subdir' '
(
echo link >subdir/file &&
git commit -m link subdir/file &&
Expand All @@ -77,7 +71,7 @@ test_expect_success 'pulling from symlinked subdir' '
# Prove that the remote end really is a repo, and other commands
# work fine in this context. It's just that "git pull" breaks.
#
test_expect_success 'pushing from symlinked subdir' '
test_expect_success SYMLINKS 'pushing from symlinked subdir' '
(
cd subdir-link/ &&
echo push >file &&
Expand Down
Loading

0 comments on commit 41be8ea

Please sign in to comment.