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>

Jeff King committed Aug 15, 2017 at 06:24 UTC cc1735c4a3cf3377289640ce1af6b4c4523bee11
1 file changed +12 -8
t/t4205-log-pretty-formats.sh
+12 -8
@@ -539,25 +539,29 @@ cat >trailers <<EOF
539 Signed-off-by: A U Thor <author@example.com>
540 Acked-by: A U Thor <author@example.com>
541 [ v2 updated patch description ]
542 -Signed-off-by: A U Thor <author@example.com>
542 +Signed-off-by: A U Thor
543 + <author@example.com>
544 EOF
545
545 -test_expect_success 'pretty format %(trailers) shows trailers' '
546 +test_expect_success 'set up trailer tests' '
547 echo "Some contents" >trailerfile &&
548 git add trailerfile &&
548 - git commit -F - <<-EOF &&
549 + git commit -F - <<-EOF
550 trailers: this commit message has trailers
551
552 This commit is a test commit with trailers at the end. We parse this
552 - message and display the trailers using %bT
553 + message and display the trailers using %(trailers).
554
555 $(cat trailers)
556 EOF
556 - git log --no-walk --pretty="%(trailers)" >actual &&
557 - cat >expect <<-EOF &&
558 - $(cat trailers)
557 +'
558
560 - EOF
559 +test_expect_success 'pretty format %(trailers) shows trailers' '
560 + git log --no-walk --pretty="%(trailers)" >actual &&
561 + {
562 + cat trailers &&
563 + echo
564 + } >expect &&
565 test_cmp expect actual
566 '
567