summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Zhang <jerry@skydio.com>2022-02-02 04:20:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2022-02-02 19:24:15 (GMT)
commit56fa5ac39a8601d965127abebbc533f29eaef751 (patch)
tree9733071d9705d500c5c55f1f0d20969965797d72
parent4c53a8c20f8984adb226293a3ffd7b88c3f4ac1a (diff)
downloadgit-56fa5ac39a8601d965127abebbc533f29eaef751.zip
git-56fa5ac39a8601d965127abebbc533f29eaef751.tar.gz
git-56fa5ac39a8601d965127abebbc533f29eaef751.tar.bz2
patch-id: fix antipatterns in tests
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>
-rwxr-xr-xt/t4204-patch-id.sh64
1 files changed, 31 insertions, 33 deletions
diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
index 80f4a65..2bc940a 100755
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
@@ -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