t5516: refactor oddball tests

t5516 sets up some utility functions for starting each test
with a clean slate. However, there were a few tests added
that do not use these functions, but instead make their own
repositories.

Let's bring these in line with the rest of the tests. Not
only do we reduce the number of lines, but these tests will
benefit from any further enhancements to the utility
scripts.

The conversion is pretty straightforward. Most of the tests
created a parent/child clone relationship, for which we now
use 'testrepo' as the parent.  One test looked in testrepo,
but relied on previous tests to have set it up; it now sets
up testrepo explicitly, which makes it a bit more robust to
changes in the script, as well.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jeff King 2008-11-07 17:20:33 -05:00 committed by Junio C Hamano
parent bc9c0248a5
commit b2dc968e60

View File

@ -39,6 +39,11 @@ mk_test () {
)
}
mk_child() {
rm -rf "$1" &&
git clone testrepo "$1"
}
check_push_result () {
(
cd testrepo &&
@ -425,13 +430,10 @@ test_expect_success 'push with dry-run' '
test_expect_success 'push updates local refs' '
rm -rf parent child &&
mkdir parent &&
(cd parent && git init &&
echo one >foo && git add foo && git commit -m one) &&
git clone parent child &&
mk_test heads/master &&
mk_child child &&
(cd child &&
echo two >foo && git commit -a -m two &&
git pull .. master &&
git push &&
test $(git rev-parse master) = $(git rev-parse remotes/origin/master))
@ -439,15 +441,10 @@ test_expect_success 'push updates local refs' '
test_expect_success 'push updates up-to-date local refs' '
rm -rf parent child &&
mkdir parent &&
(cd parent && git init &&
echo one >foo && git add foo && git commit -m one) &&
git clone parent child1 &&
git clone parent child2 &&
(cd child1 &&
echo two >foo && git commit -a -m two &&
git push) &&
mk_test heads/master &&
mk_child child1 &&
mk_child child2 &&
(cd child1 && git pull .. master && git push) &&
(cd child2 &&
git pull ../child1 master &&
git push &&
@ -457,11 +454,8 @@ test_expect_success 'push updates up-to-date local refs' '
test_expect_success 'push preserves up-to-date packed refs' '
rm -rf parent child &&
mkdir parent &&
(cd parent && git init &&
echo one >foo && git add foo && git commit -m one) &&
git clone parent child &&
mk_test heads/master &&
mk_child child &&
(cd child &&
git push &&
! test -f .git/refs/remotes/origin/master)
@ -470,15 +464,13 @@ test_expect_success 'push preserves up-to-date packed refs' '
test_expect_success 'push does not update local refs on failure' '
rm -rf parent child &&
mkdir parent &&
(cd parent && git init &&
echo one >foo && git add foo && git commit -m one &&
echo exit 1 >.git/hooks/pre-receive &&
chmod +x .git/hooks/pre-receive) &&
git clone parent child &&
mk_test heads/master &&
mk_child child &&
mkdir testrepo/.git/hooks &&
echo exit 1 >testrepo/.git/hooks/pre-receive &&
chmod +x testrepo/.git/hooks/pre-receive &&
(cd child &&
echo two >foo && git commit -a -m two &&
git pull .. master
test_must_fail git push &&
test $(git rev-parse master) != \
$(git rev-parse remotes/origin/master))
@ -487,7 +479,7 @@ test_expect_success 'push does not update local refs on failure' '
test_expect_success 'allow deleting an invalid remote ref' '
pwd &&
mk_test heads/master &&
rm -f testrepo/.git/objects/??/* &&
git push testrepo :refs/heads/master &&
(cd testrepo && test_must_fail git rev-parse --verify refs/heads/master)