Skip to content

Commit 56fa5ac

Browse files
jerry-skydiogitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c53a8c commit 56fa5ac

File tree

1 file changed

+31
-33
lines changed

1 file changed

+31
-33
lines changed

t/t4204-patch-id.sh

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -166,40 +166,38 @@ test_expect_success 'patch-id respects config from subdir' '
166166
)
167167
'
168168

169-
cat >nonl <<\EOF
170-
diff --git i/a w/a
171-
index e69de29..2e65efe 100644
172-
--- i/a
173-
+++ w/a
174-
@@ -0,0 +1 @@
175-
+a
176-
\ No newline at end of file
177-
diff --git i/b w/b
178-
index e69de29..6178079 100644
179-
--- i/b
180-
+++ w/b
181-
@@ -0,0 +1 @@
182-
+b
183-
EOF
184-
185-
cat >withnl <<\EOF
186-
diff --git i/a w/a
187-
index e69de29..7898192 100644
188-
--- i/a
189-
+++ w/a
190-
@@ -0,0 +1 @@
191-
+a
192-
diff --git i/b w/b
193-
index e69de29..6178079 100644
194-
--- i/b
195-
+++ w/b
196-
@@ -0,0 +1 @@
197-
+b
198-
EOF
199-
200169
test_expect_success 'patch-id handles no-nl-at-eof markers' '
201-
cat nonl | calc_patch_id nonl &&
202-
cat withnl | calc_patch_id withnl &&
170+
cat >nonl <<-\EOF &&
171+
diff --git i/a w/a
172+
index e69de29..2e65efe 100644
173+
--- i/a
174+
+++ w/a
175+
@@ -0,0 +1 @@
176+
+a
177+
\ No newline at end of file
178+
diff --git i/b w/b
179+
index e69de29..6178079 100644
180+
--- i/b
181+
+++ w/b
182+
@@ -0,0 +1 @@
183+
+b
184+
EOF
185+
cat >withnl <<-\EOF &&
186+
diff --git i/a w/a
187+
index e69de29..7898192 100644
188+
--- i/a
189+
+++ w/a
190+
@@ -0,0 +1 @@
191+
+a
192+
diff --git i/b w/b
193+
index e69de29..6178079 100644
194+
--- i/b
195+
+++ w/b
196+
@@ -0,0 +1 @@
197+
+b
198+
EOF
199+
calc_patch_id nonl <nonl &&
200+
calc_patch_id withnl <withnl &&
203201
test_cmp patch-id_nonl patch-id_withnl
204202
'
205203
test_done

0 commit comments

Comments
 (0)