]> git.ipfire.org Git - thirdparty/git.git/commitdiff
patch-id: fix antipatterns in tests
authorJerry Zhang <jerry@skydio.com>
Wed, 2 Feb 2022 04:20:15 +0000 (20:20 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 2 Feb 2022 19:24:15 +0000 (11:24 -0800)
Clean up the tests for patch-id by moving file preparation
tasks inside the test body and redirecting files directly into
stdin instead of using 'cat'.

Signed-off-by: Jerry Zhang <jerry@skydio.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4204-patch-id.sh

index 80f4a65b285c55cfc7dce38fb115fb0190de97a2..2bc940a07edf8f97b7f468c1bd3eb27ecbabb076 100755 (executable)
@@ -166,40 +166,38 @@ test_expect_success 'patch-id respects config from subdir' '
        )
 '
 
-cat >nonl <<\EOF
-diff --git i/a w/a
-index e69de29..2e65efe 100644
---- i/a
-+++ w/a
-@@ -0,0 +1 @@
-+a
-\ No newline at end of file
-diff --git i/b w/b
-index e69de29..6178079 100644
---- i/b
-+++ w/b
-@@ -0,0 +1 @@
-+b
-EOF
-
-cat >withnl <<\EOF
-diff --git i/a w/a
-index e69de29..7898192 100644
---- i/a
-+++ w/a
-@@ -0,0 +1 @@
-+a
-diff --git i/b w/b
-index e69de29..6178079 100644
---- i/b
-+++ w/b
-@@ -0,0 +1 @@
-+b
-EOF
-
 test_expect_success 'patch-id handles no-nl-at-eof markers' '
-       cat nonl | calc_patch_id nonl &&
-       cat withnl | calc_patch_id withnl &&
+       cat >nonl <<-\EOF &&
+       diff --git i/a w/a
+       index e69de29..2e65efe 100644
+       --- i/a
+       +++ w/a
+       @@ -0,0 +1 @@
+       +a
+       \ No newline at end of file
+       diff --git i/b w/b
+       index e69de29..6178079 100644
+       --- i/b
+       +++ w/b
+       @@ -0,0 +1 @@
+       +b
+       EOF
+       cat >withnl <<-\EOF &&
+       diff --git i/a w/a
+       index e69de29..7898192 100644
+       --- i/a
+       +++ w/a
+       @@ -0,0 +1 @@
+       +a
+       diff --git i/b w/b
+       index e69de29..6178079 100644
+       --- i/b
+       +++ w/b
+       @@ -0,0 +1 @@
+       +b
+       EOF
+       calc_patch_id nonl <nonl &&
+       calc_patch_id withnl <withnl &&
        test_cmp patch-id_nonl patch-id_withnl
 '
 test_done