summaryrefslogtreecommitdiff
path: root/t/t7201-co.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-03-12 17:36:36 -0400
committerJunio C Hamano <gitster@pobox.com>2008-03-13 00:57:52 -0700
commit82ebb0b6ec7470cab96a013d3d719c109003ef83 (patch)
tree8796598a518e972881afd729215c265924c04ddf /t/t7201-co.sh
parentb4ce54fc61e7c76e2d7f47c34733f0f0bbb6c4cd (diff)
downloadgit-82ebb0b6ec7470cab96a013d3d719c109003ef83.tar.gz
add test_cmp function for test scripts
Many scripts compare actual and expected output using "diff -u". This is nicer than "cmp" because the output shows how the two differ. However, not all versions of diff understand -u, leading to unnecessary test failure. This adds a test_cmp function to the test scripts and switches all "diff -u" invocations to use it. The function uses the contents of "$GIT_TEST_CMP" to compare its arguments; the default is "diff -u". On systems with a less-capable diff, you can do: GIT_TEST_CMP=cmp make test Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t7201-co.sh')
-rwxr-xr-xt/t7201-co.sh18
1 files changed, 9 insertions, 9 deletions
diff --git a/t/t7201-co.sh b/t/t7201-co.sh
index 63915cd87b..3111baa9e3 100755
--- a/t/t7201-co.sh
+++ b/t/t7201-co.sh
@@ -83,13 +83,13 @@ test_expect_success "checkout with unrelated dirty tree without -m" '
fill 0 1 2 3 4 5 6 7 8 >same &&
cp same kept
git checkout side >messages &&
- diff -u same kept
+ test_cmp same kept
(cat > messages.expect <<EOF
M same
EOF
) &&
touch messages.expect &&
- diff -u messages.expect messages
+ test_cmp messages.expect messages
'
test_expect_success "checkout -m with dirty tree" '
@@ -106,19 +106,19 @@ test_expect_success "checkout -m with dirty tree" '
M one
EOF
) &&
- diff -u expect.messages messages &&
+ test_cmp expect.messages messages &&
fill "M one" "A three" "D two" >expect.master &&
git diff --name-status master >current.master &&
- diff -u expect.master current.master &&
+ test_cmp expect.master current.master &&
fill "M one" >expect.side &&
git diff --name-status side >current.side &&
- diff -u expect.side current.side &&
+ test_cmp expect.side current.side &&
: >expect.index &&
git diff --cached >current.index &&
- diff -u expect.index current.index
+ test_cmp expect.index current.index
'
test_expect_success "checkout -m with dirty tree, renamed" '
@@ -136,7 +136,7 @@ test_expect_success "checkout -m with dirty tree, renamed" '
git checkout -m renamer &&
fill 1 3 4 5 7 8 >expect &&
- diff -u expect uno &&
+ test_cmp expect uno &&
! test -f one &&
git diff --cached >current &&
! test -s current
@@ -161,7 +161,7 @@ test_expect_success 'checkout -m with merge conflict' '
git diff master:one :3:uno |
sed -e "1,/^@@/d" -e "/^ /d" -e "s/^-/d/" -e "s/^+/a/" >current &&
fill d2 aT d7 aS >expect &&
- diff -u current expect &&
+ test_cmp current expect &&
git diff --cached two >current &&
! test -s current
'
@@ -178,7 +178,7 @@ If you want to create a new branch from this checkout, you may do so
HEAD is now at 7329388... Initial A one, A two
EOF
) &&
- diff -u messages.expect messages &&
+ test_cmp messages.expect messages &&
H=$(git rev-parse --verify HEAD) &&
M=$(git show-ref -s --verify refs/heads/master) &&
test "z$H" = "z$M" &&