git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH V4 1/2] patch-id: Fix antipatterns in tests

From
Jerry Zhang <jerry@skydio.com>
Date
Feb 2, 2022, 04:20 UTC
Message-ID
<20220202042015.10115-1-jerry@skydio.com>
In-Reply-To
<20220131235218.27392-1-jerry@skydio.com>

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>
---
V3->V4:
- Quote the EOF marker correctly
 t/t4204-patch-id.sh | 64 ++++++++++++++++++++++-----------------------
 1 file changed, 31 insertions(+), 33 deletions(-)
diff --git a/t/t4204-patch-id.sh b/t/t4204-patch-id.sh
index 80f4a65b28..2bc940a07e 100755
--- a/t/t4204-patch-id.sh
+++ b/t/t4204-patch-id.sh
@@ -164,42 +164,40 @@ test_expect_success 'patch-id respects config from subdir' '
 		cd subdir &&
 		test_patch_id irrelevant patchid.stable=true
 	)
 '
 
-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
-- 
2.32.0.1314.g6ed4fcc4cc
Previous: Junio C Hamano
Message 11 of 11 in “format-patch: Fix antipatterns in tests”
  1. 1/2 format-patch: Fix antipatterns in testsJerry Zhang, Jan 31, 2022
  2. 2/2 patch-id: fix scan_hunk_header on diffs with 1 line of before/afterJerry Zhang, Jan 31, 2022
  3. 2/2 patch-id: fix scan_hunk_header on diffs with 1 line of before/afterJerry Zhang, Jan 31, 2022
  4. 2/2 patch-id: fix scan_hunk_header on diffs with 1 line of before/afterJerry Zhang, Feb 2, 2022
  5. 1/2 patch-id: Fix antipatterns in testsJerry Zhang, Jan 31, 2022
  6. Junio C HamanoJan 31, 2022
  7. 1/2 patch-id: Fix antipatterns in testsJerry Zhang, Jan 31, 2022
  8. Johannes SixtFeb 1, 2022
  9. Junio C HamanoFeb 1, 2022
  10. Junio C HamanoFeb 1, 2022
  11. 1/2 patch-id: Fix antipatterns in testsJerry Zhang, Feb 2, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.