[PATCH v4 7/8] t4205: refactor %(trailers) tests

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx>
---
 t/t4205-log-pretty-formats.sh | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 18aa1b5889..83ea85eb45 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -539,25 +539,29 @@ cat >trailers <<EOF
 Signed-off-by: A U Thor <author@xxxxxxxxxxx>
 Acked-by: A U Thor <author@xxxxxxxxxxx>
 [ v2 updated patch description ]
-Signed-off-by: A U Thor <author@xxxxxxxxxxx>
+Signed-off-by: A U Thor
+  <author@xxxxxxxxxxx>
 EOF
 
-test_expect_success 'pretty format %(trailers) shows trailers' '
+test_expect_success 'set up trailer tests' '
 	echo "Some contents" >trailerfile &&
 	git add trailerfile &&
-	git commit -F - <<-EOF &&
+	git commit -F - <<-EOF
 	trailers: this commit message has trailers
 
 	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)
 	EOF
-	git log --no-walk --pretty="%(trailers)" >actual &&
-	cat >expect <<-EOF &&
-	$(cat trailers)
+'
 
-	EOF
+test_expect_success 'pretty format %(trailers) shows trailers' '
+	git log --no-walk --pretty="%(trailers)" >actual &&
+	{
+		cat trailers &&
+		echo
+	} >expect &&
 	test_cmp expect actual
 '
 
-- 
2.14.1.352.ge5efb0d3f3




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux