mirror of
https://github.com/git/git
synced 2024-11-05 18:59:29 +00:00
82ebb0b6ec
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>
72 lines
1.3 KiB
Bash
Executable file
72 lines
1.3 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='git am running from a subdirectory'
|
|
|
|
. ./test-lib.sh
|
|
|
|
test_expect_success setup '
|
|
echo hello >world &&
|
|
git add world &&
|
|
test_tick &&
|
|
git commit -m initial &&
|
|
git tag initial &&
|
|
echo goodbye >world &&
|
|
git add world &&
|
|
test_tick &&
|
|
git commit -m second &&
|
|
git format-patch --stdout HEAD^ >patchfile &&
|
|
: >expect
|
|
'
|
|
|
|
test_expect_success 'am regularly from stdin' '
|
|
git checkout initial &&
|
|
git am <patchfile &&
|
|
git diff master >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'am regularly from file' '
|
|
git checkout initial &&
|
|
git am patchfile &&
|
|
git diff master >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'am regularly from stdin in subdirectory' '
|
|
rm -fr subdir &&
|
|
git checkout initial &&
|
|
(
|
|
mkdir -p subdir &&
|
|
cd subdir &&
|
|
git am <../patchfile
|
|
) &&
|
|
git diff master>actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'am regularly from file in subdirectory' '
|
|
rm -fr subdir &&
|
|
git checkout initial &&
|
|
(
|
|
mkdir -p subdir &&
|
|
cd subdir &&
|
|
git am ../patchfile
|
|
) &&
|
|
git diff master >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_expect_success 'am regularly from file in subdirectory with full path' '
|
|
rm -fr subdir &&
|
|
git checkout initial &&
|
|
P=$(pwd) &&
|
|
(
|
|
mkdir -p subdir &&
|
|
cd subdir &&
|
|
git am "$P/patchfile"
|
|
) &&
|
|
git diff master >actual &&
|
|
test_cmp expect actual
|
|
'
|
|
|
|
test_done
|