t4205: refactor %(trailers) tests

We currently have one test for %(trailers). In preparation
for more, let's refactor a few bits:

  - move the commit creation to its own setup step so it can
    be reused by multiple tests

  - add a trailer with whitespace continuation (to confirm
    that it is left untouched)

  - fix the sample text which claims the placeholder is %bT.
    This was switched long ago to %(trailers)

  - replace one "cat" with an "echo" when generating the
    expected output. This saves a process (and sets a better
    pattern for future tests to follow).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Jeff King 2017-08-15 06:24:39 -04:00 committed by Junio C Hamano
parent a388b10fc1
commit cc1735c4a3
1 changed files with 12 additions and 8 deletions

View File

@ -539,25 +539,29 @@ cat >trailers <<EOF
Signed-off-by: A U Thor <author@example.com> Signed-off-by: A U Thor <author@example.com>
Acked-by: A U Thor <author@example.com> Acked-by: A U Thor <author@example.com>
[ v2 updated patch description ] [ v2 updated patch description ]
Signed-off-by: A U Thor <author@example.com> Signed-off-by: A U Thor
<author@example.com>
EOF EOF


test_expect_success 'pretty format %(trailers) shows trailers' ' test_expect_success 'set up trailer tests' '
echo "Some contents" >trailerfile && echo "Some contents" >trailerfile &&
git add trailerfile && git add trailerfile &&
git commit -F - <<-EOF && git commit -F - <<-EOF
trailers: this commit message has trailers trailers: this commit message has trailers


This commit is a test commit with trailers at the end. We parse this This commit is a test commit with trailers at the end. We parse this
message and display the trailers using %bT message and display the trailers using %(trailers).


$(cat trailers) $(cat trailers)
EOF EOF
'

test_expect_success 'pretty format %(trailers) shows trailers' '
git log --no-walk --pretty="%(trailers)" >actual && git log --no-walk --pretty="%(trailers)" >actual &&
cat >expect <<-EOF && {
$(cat trailers) cat trailers &&

echo
EOF } >expect &&
test_cmp expect actual test_cmp expect actual
' '