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>
@ -57,7 +57,7 @@ test_expect_success 'cross renames to be detected for regular files' '
@@ -57,7 +57,7 @@ test_expect_success 'cross renames to be detected for regular files' '
echo "R100 foo bar"
echo "R100 bar foo"
} | sort >expect &&
diff -u expect actual
test_cmp expect actual
'
@ -68,7 +68,7 @@ test_expect_success 'cross renames to be detected for typechange' '
@@ -68,7 +68,7 @@ test_expect_success 'cross renames to be detected for typechange' '
echo "R100 foo bar"
echo "R100 bar foo"
} | sort >expect &&
diff -u expect actual
test_cmp expect actual
'
@ -79,7 +79,7 @@ test_expect_success 'moves and renames' '
@@ -79,7 +79,7 @@ test_expect_success 'moves and renames' '
@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
@@ -37,7 +37,7 @@ test_expect_success 'hunk header truncation with an overly long line' '
@ -22,14 +22,14 @@ test_expect_success 'am regularly from stdin' '
@@ -22,14 +22,14 @@ test_expect_success 'am regularly from stdin' '
git checkout initial &&
git am <patchfile &&
git diff master >actual &&
diff -u expect actual
test_cmp expect actual
'
test_expect_success 'am regularly from file' '
git checkout initial &&
git am patchfile &&
git diff master >actual &&
diff -u expect actual
test_cmp expect actual
'
test_expect_success 'am regularly from stdin in subdirectory' '
@ -41,7 +41,7 @@ test_expect_success 'am regularly from stdin in subdirectory' '
@@ -41,7 +41,7 @@ test_expect_success 'am regularly from stdin in subdirectory' '
git am <../patchfile
) &&
git diff master>actual &&
diff -u expect actual
test_cmp expect actual
'
test_expect_success 'am regularly from file in subdirectory' '
@ -53,7 +53,7 @@ test_expect_success 'am regularly from file in subdirectory' '
@@ -53,7 +53,7 @@ test_expect_success 'am regularly from file in subdirectory' '
git am ../patchfile
) &&
git diff master >actual &&
diff -u expect actual
test_cmp expect actual
'
test_expect_success 'am regularly from file in subdirectory with full path' '
@ -66,7 +66,7 @@ test_expect_success 'am regularly from file in subdirectory with full path' '
@@ -66,7 +66,7 @@ test_expect_success 'am regularly from file in subdirectory with full path' '
@ -249,7 +249,7 @@ test_expect_success 'bundle should record HEAD correctly' '
@@ -249,7 +249,7 @@ test_expect_success 'bundle should record HEAD correctly' '
@ -31,7 +31,7 @@ test_expect_failure 'one is ancestor of others and should not be shown' '
@@ -31,7 +31,7 @@ test_expect_failure 'one is ancestor of others and should not be shown' '
@ -25,7 +25,7 @@ test_expect_success 'subtree available and works like recursive' '
@@ -25,7 +25,7 @@ test_expect_success 'subtree available and works like recursive' '
git merge -s subtree side &&
for i in mundo $s world; do echo $i; done >expect &&
@ -83,13 +83,13 @@ test_expect_success "checkout with unrelated dirty tree without -m" '
@@ -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" '
@ -178,7 +178,7 @@ If you want to create a new branch from this checkout, you may do so
@@ -178,7 +178,7 @@ If you want to create a new branch from this checkout, you may do so
@ -301,12 +301,12 @@ test_expect_success 'same tree (merge and amend merge)' '
@@ -301,12 +301,12 @@ test_expect_success 'same tree (merge and amend merge)' '
git merge -s ours side -m "empty ok" &&
git diff HEAD^ HEAD >actual &&
: >expected &&
diff -u expected actual &&
test_cmp expected actual &&
git commit --amend -m "empty really ok" &&
git diff HEAD^ HEAD >actual &&
: >expected &&
diff -u expected actual
test_cmp expected actual
'
@ -323,7 +323,7 @@ test_expect_success 'amend using the message from another commit' '
@@ -323,7 +323,7 @@ test_expect_success 'amend using the message from another commit' '
git commit --allow-empty --amend -C "$old" &&
git show --pretty="format:%ad %s" "$old" >expected &&
git show --pretty="format:%ad %s" HEAD >actual &&
diff -u expected actual
test_cmp expected actual
'
@ -341,7 +341,7 @@ test_expect_success 'amend using the message from a commit named with tag' '
@@ -341,7 +341,7 @@ test_expect_success 'amend using the message from a commit named with tag' '
git commit --allow-empty --amend -C tagged-old &&
git show --pretty="format:%ad %s" "$old" >expected &&
@ -257,8 +257,8 @@ test_expect_success '-w option should work with relative GIT_DIR' '
@@ -257,8 +257,8 @@ test_expect_success '-w option should work with relative GIT_DIR' '
@ -293,7 +293,7 @@ test_expect_success 'commit a file with leading spaces in the name' '
@@ -293,7 +293,7 @@ test_expect_success 'commit a file with leading spaces in the name' '