Skip to content

Commit b7446fc

Browse files
rybakgitster
authored andcommitted
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 bf72ac1 (t4150: tests for am --[no-]scissors, 2015-07-19) Signed-off-by: Andrei Rybak <[email protected]> Reviewed-by: Paul Tan <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a42a58d commit b7446fc

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

t/t4150-am.sh

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,15 @@ test_expect_success 'setup: messages' '
6969
7070
EOF
7171
72-
cat >scissors-msg <<-\EOF &&
73-
Test git-am with scissors line
72+
cat >msg-without-scissors-line <<-\EOF &&
73+
Test that git-am --scissors cuts at the scissors line
7474
7575
This line should be included in the commit message.
7676
EOF
7777
78-
cat - scissors-msg >no-scissors-msg <<-\EOF &&
78+
printf "Subject: " >subject-prefix &&
79+
80+
cat - subject-prefix msg-without-scissors-line >msg-with-scissors-line <<-\EOF &&
7981
This line should not be included in the commit message with --scissors enabled.
8082
8183
- - >8 - - remove everything above this line - - >8 - -
@@ -148,18 +150,17 @@ test_expect_success setup '
148150
} >patch1-hg.eml &&
149151
150152
151-
echo scissors-file >scissors-file &&
152-
git add scissors-file &&
153-
git commit -F scissors-msg &&
154-
git tag scissors &&
155-
git format-patch --stdout scissors^ >scissors-patch.eml &&
153+
echo file >file &&
154+
git add file &&
155+
git commit -F msg-without-scissors-line &&
156+
git tag expected-for-scissors &&
156157
git reset --hard HEAD^ &&
157158
158-
echo no-scissors-file >no-scissors-file &&
159-
git add no-scissors-file &&
160-
git commit -F no-scissors-msg &&
161-
git tag no-scissors &&
162-
git format-patch --stdout no-scissors^ >no-scissors-patch.eml &&
159+
echo file >file &&
160+
git add file &&
161+
git commit -F msg-with-scissors-line &&
162+
git tag expected-for-no-scissors &&
163+
git format-patch --stdout expected-for-no-scissors^ >patch-with-scissors-line.eml &&
163164
git reset --hard HEAD^ &&
164165
165166
sed -n -e "3,\$p" msg >file &&
@@ -416,21 +417,21 @@ test_expect_success 'am --scissors cuts the message at the scissors line' '
416417
rm -fr .git/rebase-apply &&
417418
git reset --hard &&
418419
git checkout second &&
419-
git am --scissors scissors-patch.eml &&
420+
git am --scissors patch-with-scissors-line.eml &&
420421
test_path_is_missing .git/rebase-apply &&
421-
git diff --exit-code scissors &&
422-
test_cmp_rev scissors HEAD
422+
git diff --exit-code expected-for-scissors &&
423+
test_cmp_rev expected-for-scissors HEAD
423424
'
424425

425426
test_expect_success 'am --no-scissors overrides mailinfo.scissors' '
426427
rm -fr .git/rebase-apply &&
427428
git reset --hard &&
428429
git checkout second &&
429430
test_config mailinfo.scissors true &&
430-
git am --no-scissors no-scissors-patch.eml &&
431+
git am --no-scissors patch-with-scissors-line.eml &&
431432
test_path_is_missing .git/rebase-apply &&
432-
git diff --exit-code no-scissors &&
433-
test_cmp_rev no-scissors HEAD
433+
git diff --exit-code expected-for-no-scissors &&
434+
test_cmp_rev expected-for-no-scissors HEAD
434435
'
435436

436437
test_expect_success 'setup: new author and committer' '

0 commit comments

Comments
 (0)