t4150: fix broken test for am --scissors
Tests for "git am --[no-]scissors" [1] work in the following way:
1. Create files with commit messages
2. Use these files to create expected commits
3. Generate eml file with patch from expected commits
4. Create commits using git am with these eml files
5. Compare these commits with expected
The test for "git am --scissors" is supposed to take an e-mail with a
scissors line and in-body "Subject:" header and demonstrate that the
subject line from the e-mail itself is overridden by the in-body header
and that only text below the scissors line is included in the commit
message of the commit created by the invocation of "git am --scissors".
However, the setup of the test incorrectly uses a commit without the
scissors line and without the in-body header in the commit message,
producing eml file not suitable for testing of "git am --scissors".
This can be checked by intentionally breaking is_scissors_line function
in mailinfo.c, for example, by changing string ">8", which is used by
the test. With such change the test should fail, but does not.
Fix broken test by generating eml file with scissors line and in-body
header "Subject:". Since the two tests for --scissors and --no-scissors
options are there to test cutting or keeping the commit message, update
both tests to change the test file in the same way, which allows us to
generate only one eml file to be passed to git am. To clarify the
intention of the test, give files and tags more explicit names.
[1]: introduced in bf72ac17d
(t4150: tests for am --[no-]scissors,
2015-07-19)
Signed-off-by: Andrei Rybak <rybak.a.v@gmail.com>
Reviewed-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
a42a58d7b6
commit
b7446fcfdf
@ -69,13 +69,15 @@ test_expect_success 'setup: messages' '
|
|||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat >scissors-msg <<-\EOF &&
|
cat >msg-without-scissors-line <<-\EOF &&
|
||||||
Test git-am with scissors line
|
Test that git-am --scissors cuts at the scissors line
|
||||||
|
|
||||||
This line should be included in the commit message.
|
This line should be included in the commit message.
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
cat - scissors-msg >no-scissors-msg <<-\EOF &&
|
printf "Subject: " >subject-prefix &&
|
||||||
|
|
||||||
|
cat - subject-prefix msg-without-scissors-line >msg-with-scissors-line <<-\EOF &&
|
||||||
This line should not be included in the commit message with --scissors enabled.
|
This line should not be included in the commit message with --scissors enabled.
|
||||||
|
|
||||||
- - >8 - - remove everything above this line - - >8 - -
|
- - >8 - - remove everything above this line - - >8 - -
|
||||||
@ -148,18 +150,17 @@ test_expect_success setup '
|
|||||||
} >patch1-hg.eml &&
|
} >patch1-hg.eml &&
|
||||||
|
|
||||||
|
|
||||||
echo scissors-file >scissors-file &&
|
echo file >file &&
|
||||||
git add scissors-file &&
|
git add file &&
|
||||||
git commit -F scissors-msg &&
|
git commit -F msg-without-scissors-line &&
|
||||||
git tag scissors &&
|
git tag expected-for-scissors &&
|
||||||
git format-patch --stdout scissors^ >scissors-patch.eml &&
|
|
||||||
git reset --hard HEAD^ &&
|
git reset --hard HEAD^ &&
|
||||||
|
|
||||||
echo no-scissors-file >no-scissors-file &&
|
echo file >file &&
|
||||||
git add no-scissors-file &&
|
git add file &&
|
||||||
git commit -F no-scissors-msg &&
|
git commit -F msg-with-scissors-line &&
|
||||||
git tag no-scissors &&
|
git tag expected-for-no-scissors &&
|
||||||
git format-patch --stdout no-scissors^ >no-scissors-patch.eml &&
|
git format-patch --stdout expected-for-no-scissors^ >patch-with-scissors-line.eml &&
|
||||||
git reset --hard HEAD^ &&
|
git reset --hard HEAD^ &&
|
||||||
|
|
||||||
sed -n -e "3,\$p" msg >file &&
|
sed -n -e "3,\$p" msg >file &&
|
||||||
@ -416,10 +417,10 @@ test_expect_success 'am --scissors cuts the message at the scissors line' '
|
|||||||
rm -fr .git/rebase-apply &&
|
rm -fr .git/rebase-apply &&
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
git checkout second &&
|
git checkout second &&
|
||||||
git am --scissors scissors-patch.eml &&
|
git am --scissors patch-with-scissors-line.eml &&
|
||||||
test_path_is_missing .git/rebase-apply &&
|
test_path_is_missing .git/rebase-apply &&
|
||||||
git diff --exit-code scissors &&
|
git diff --exit-code expected-for-scissors &&
|
||||||
test_cmp_rev scissors HEAD
|
test_cmp_rev expected-for-scissors HEAD
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'am --no-scissors overrides mailinfo.scissors' '
|
test_expect_success 'am --no-scissors overrides mailinfo.scissors' '
|
||||||
@ -427,10 +428,10 @@ test_expect_success 'am --no-scissors overrides mailinfo.scissors' '
|
|||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
git checkout second &&
|
git checkout second &&
|
||||||
test_config mailinfo.scissors true &&
|
test_config mailinfo.scissors true &&
|
||||||
git am --no-scissors no-scissors-patch.eml &&
|
git am --no-scissors patch-with-scissors-line.eml &&
|
||||||
test_path_is_missing .git/rebase-apply &&
|
test_path_is_missing .git/rebase-apply &&
|
||||||
git diff --exit-code no-scissors &&
|
git diff --exit-code expected-for-no-scissors &&
|
||||||
test_cmp_rev no-scissors HEAD
|
test_cmp_rev expected-for-no-scissors HEAD
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success 'setup: new author and committer' '
|
test_expect_success 'setup: new author and committer' '
|
||||||
|
Reference in New Issue
Block a user