Skip to content

Commit

Permalink
t5800: factor out some ref tests
Browse files Browse the repository at this point in the history
These are a little hard to read, and I'm about to add more
just like them. Plus the failure output is nicer if we use
test_cmp than a comparison with "test".

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jul 19, 2011
1 parent 2faa152 commit 5cf5ade
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions t/t5800-remote-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ then
test_set_prereq PYTHON_24
fi

compare_refs() {
git --git-dir="$1/.git" rev-parse --verify $2 >expect &&
git --git-dir="$3/.git" rev-parse --verify $4 >actual &&
test_cmp expect actual
}

test_expect_success PYTHON_24 'setup repository' '
git init --bare server/.git &&
git clone server public &&
Expand Down Expand Up @@ -59,8 +65,7 @@ test_expect_success PYTHON_24 'pushing to local repo' '
echo content >>file &&
git commit -a -m three &&
git push) &&
HEAD=$(git --git-dir=localclone/.git rev-parse --verify HEAD) &&
test $HEAD = $(git --git-dir=server/.git rev-parse --verify HEAD)
compare_refs localclone HEAD server HEAD
'

test_expect_success PYTHON_24 'synch with changes from localclone' '
Expand All @@ -73,8 +78,7 @@ test_expect_success PYTHON_24 'pushing remote local repo' '
echo content >>file &&
git commit -a -m four &&
git push) &&
HEAD=$(git --git-dir=clone/.git rev-parse --verify HEAD) &&
test $HEAD = $(git --git-dir=server/.git rev-parse --verify HEAD)
compare_refs clone HEAD server HEAD
'

test_done

0 comments on commit 5cf5ade

Please sign in to comment.