All of lore.kernel.org
 help / color / mirror / Atom feed
From: Elijah Newren <newren@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, Elijah Newren <newren@gmail.com>
Subject: [PATCH 4/5] t6036, t6042: prefer test_cmp to sequences of test
Date: Thu, 24 May 2018 00:04:38 -0700	[thread overview]
Message-ID: <20180524070439.6367-5-newren@gmail.com> (raw)
In-Reply-To: <20180524070439.6367-1-newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 t/t6036-recursive-corner-cases.sh    | 109 +++++++++++++++++----------
 t/t6042-merge-rename-corner-cases.sh |  94 ++++++++++++++---------
 2 files changed, 130 insertions(+), 73 deletions(-)

diff --git a/t/t6036-recursive-corner-cases.sh b/t/t6036-recursive-corner-cases.sh
index b716155723..e5f167a06e 100755
--- a/t/t6036-recursive-corner-cases.sh
+++ b/t/t6036-recursive-corner-cases.sh
@@ -72,11 +72,14 @@ test_expect_success 'merge simple rename+criss-cross with no modifications' '
 		git ls-files -o >out &&
 		test_line_count = 3 out &&
 
-		test $(git rev-parse :2:three) = $(git rev-parse L2:three) &&
-		test $(git rev-parse :3:three) = $(git rev-parse R2:three) &&
-
-		test $(git rev-parse L2:three) = $(git hash-object three~HEAD) &&
-		test $(git rev-parse R2:three) = $(git hash-object three~R2^0)
+		git rev-parse >expect       \
+			L2:three   R2:three \
+			L2:three   R2:three &&
+		git rev-parse   >actual     \
+			:2:three   :3:three &&
+		git hash-object >>actual    \
+			three~HEAD three~R2^0
+		test_cmp expect actual
 	)
 '
 
@@ -145,11 +148,14 @@ test_expect_success 'merge criss-cross + rename merges with basic modification'
 		git ls-files -o >out &&
 		test_line_count = 3 out &&
 
-		test $(git rev-parse :2:three) = $(git rev-parse L2:three) &&
-		test $(git rev-parse :3:three) = $(git rev-parse R2:three) &&
-
-		test $(git rev-parse L2:three) = $(git hash-object three~HEAD) &&
-		test $(git rev-parse R2:three) = $(git hash-object three~R2^0)
+		git rev-parse >expect       \
+			L2:three   R2:three \
+			L2:three   R2:three &&
+		git rev-parse   >actual     \
+			:2:three   :3:three &&
+		git hash-object >>actual    \
+			three~HEAD three~R2^0
+		test_cmp expect actual
 	)
 '
 
@@ -224,19 +230,23 @@ test_expect_success 'git detects differently handled merges conflict' '
 		git ls-files -o >out &&
 		test_line_count = 1 out &&
 
-		test $(git rev-parse :2:new_a) = $(git rev-parse D:new_a) &&
-		test $(git rev-parse :3:new_a) = $(git rev-parse E:new_a) &&
+		git rev-parse >expect       \
+			D:new_a  E:new_a &&
+		git rev-parse   >actual     \
+			:2:new_a :3:new_a &&
+		test_cmp expect actual
 
-		git cat-file -p B:new_a >>merged &&
-		git cat-file -p C:new_a >>merge-me &&
+		git cat-file -p B:new_a >ours &&
+		git cat-file -p C:new_a >theirs &&
 		>empty &&
 		test_must_fail git merge-file \
 			-L "Temporary merge branch 2" \
 			-L "" \
 			-L "Temporary merge branch 1" \
-			merged empty merge-me &&
-		sed -e "s/^\([<=>]\)/\1\1\1/" merged >merged-internal &&
-		test $(git rev-parse :1:new_a) = $(git hash-object merged-internal)
+			ours empty theirs &&
+		sed -e "s/^\([<=>]\)/\1\1\1/" ours >expect &&
+		git cat-file -p :1:new_a >actual &&
+		test_cmp expect actual
 	)
 '
 
@@ -311,8 +321,11 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete' '
 		git ls-files -u >out &&
 		test_line_count = 2 out &&
 
-		test $(git rev-parse :1:file) = $(git rev-parse master:file) &&
-		test $(git rev-parse :2:file) = $(git rev-parse B:file)
+		git rev-parse >expect       \
+			master:file  B:file &&
+		git rev-parse   >actual      \
+			:1:file      :2:file &&
+		test_cmp expect actual
 	)
 '
 
@@ -330,8 +343,11 @@ test_expect_success 'git detects conflict merging criss-cross+modify/delete, rev
 		git ls-files -u >out &&
 		test_line_count = 2 out &&
 
-		test $(git rev-parse :1:file) = $(git rev-parse master:file) &&
-		test $(git rev-parse :3:file) = $(git rev-parse B:file)
+		git rev-parse >expect       \
+			master:file  B:file &&
+		git rev-parse   >actual      \
+			:1:file      :3:file &&
+		test_cmp expect actual
 	)
 '
 
@@ -443,8 +459,11 @@ test_expect_success 'merge of D & E1 fails but has appropriate contents' '
 		git ls-files -o >out &&
 		test_line_count = 1 out &&
 
-		test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
-		test $(git rev-parse :2:a) = $(git rev-parse B:a)
+		git rev-parse >expect    \
+			A:ignore-me  B:a &&
+		git rev-parse   >actual   \
+			:0:ignore-me :2:a &&
+		test_cmp expect actual
 	)
 '
 
@@ -463,8 +482,11 @@ test_expect_success 'merge of E1 & D fails but has appropriate contents' '
 		git ls-files -o >out &&
 		test_line_count = 1 out &&
 
-		test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
-		test $(git rev-parse :3:a) = $(git rev-parse B:a)
+		git rev-parse >expect    \
+			A:ignore-me  B:a &&
+		git rev-parse   >actual   \
+			:0:ignore-me :3:a &&
+		test_cmp expect actual
 	)
 '
 
@@ -483,10 +505,11 @@ test_expect_success 'merge of D & E2 fails but has appropriate contents' '
 		git ls-files -o >out &&
 		test_line_count = 2 out &&
 
-		test $(git rev-parse :2:a) = $(git rev-parse B:a) &&
-		test $(git rev-parse :3:a/file) = $(git rev-parse E2:a/file) &&
-		test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
-		test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
+		git rev-parse >expect    \
+			B:a   E2:a/file  c:a/file   A:ignore-me &&
+		git rev-parse   >actual   \
+			:2:a  :3:a/file  :1:a/file  :0:ignore-me &&
+		test_cmp expect actual
 
 		test_path_is_file a~HEAD
 	)
@@ -507,10 +530,11 @@ test_expect_success 'merge of E2 & D fails but has appropriate contents' '
 		git ls-files -o >out &&
 		test_line_count = 2 out &&
 
-		test $(git rev-parse :3:a) = $(git rev-parse B:a) &&
-		test $(git rev-parse :2:a/file) = $(git rev-parse E2:a/file) &&
-		test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
-		test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
+		git rev-parse >expect    \
+			B:a   E2:a/file  c:a/file   A:ignore-me &&
+		git rev-parse   >actual   \
+			:3:a  :2:a/file  :1:a/file  :0:ignore-me &&
+		test_cmp expect actual
 
 		test_path_is_file a~D^0
 	)
@@ -688,9 +712,15 @@ test_expect_failure 'detect rename/rename/add-source for virtual merge-base' '
 		git ls-files -o >out &&
 		test_line_count = 1 out &&
 
-		test $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&
-		test $(git rev-parse HEAD:c) = $(git rev-parse A:a) &&
-		test "$(cat a)" = "$(printf "1\n2\n3\n4\n5\n6\n7\n8\n")"
+		printf "1\n2\n3\n4\n5\n6\n7\n8\n" >correct &&
+		git rev-parse >expect \
+			A:a   A:a     \
+			correct       &&
+		git rev-parse   >actual  \
+			:0:b  :0:c       &&
+		git hash-object >>actual \
+			a                &&
+		test_cmp expect actual
 	)
 '
 
@@ -765,8 +795,11 @@ test_expect_success 'virtual merge base handles rename/rename(1to2)/add-dest' '
 		git ls-files -o >out &&
 		test_line_count = 1 out &&
 
-		test $(git rev-parse HEAD:a) = $(git rev-parse A:a) &&
-		test $(git rev-parse HEAD:c) = $(git rev-parse E:c)
+		git rev-parse >expect \
+			A:a   E:c     &&
+		git rev-parse   >actual \
+			:0:a  :0:c      &&
+		test_cmp expect actual
 	)
 '
 
diff --git a/t/t6042-merge-rename-corner-cases.sh b/t/t6042-merge-rename-corner-cases.sh
index 90225b8bcd..1cbd946fc2 100755
--- a/t/t6042-merge-rename-corner-cases.sh
+++ b/t/t6042-merge-rename-corner-cases.sh
@@ -80,8 +80,11 @@ test_expect_failure 'rename/modify/add-source conflict resolvable' '
 
 		git merge -s recursive C^0 &&
 
-		test $(git rev-parse B:a) = $(git rev-parse b) &&
-		test $(git rev-parse C:a) = $(git rev-parse a)
+		git rev-parse >expect \
+			B:a   C:a     &&
+		git rev-parse >actual \
+			b     c       &&
+		test_cmp expect actual
 	)
 '
 
@@ -124,8 +127,11 @@ test_expect_failure 'conflict caused if rename not detected' '
 		test_line_count = 1 out &&
 
 		test_line_count = 6 c &&
-		test $(git rev-parse HEAD:a) = $(git rev-parse B:a) &&
-		test $(git rev-parse HEAD:b) = $(git rev-parse A:b)
+		git rev-parse >expect \
+			B:a   A:b     &&
+		git rev-parse >actual \
+			:0:a  :0:b    &&
+		test_cmp expect actual
 	)
 '
 
@@ -216,8 +222,11 @@ test_expect_failure 'detect rename/add-source and preserve all data' '
 		test_path_is_file a &&
 		test_path_is_file b &&
 
-		test $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&
-		test $(git rev-parse HEAD:a) = $(git rev-parse C:a)
+		git rev-parse >expect \
+			A:a   C:a     &&
+		git rev-parse >actual \
+			:0:b  :0:a    &&
+		test_cmp expect actual
 	)
 '
 
@@ -239,8 +248,11 @@ test_expect_failure 'detect rename/add-source and preserve all data, merge other
 		test_path_is_file a &&
 		test_path_is_file b &&
 
-		test $(git rev-parse HEAD:b) = $(git rev-parse A:a) &&
-		test $(git rev-parse HEAD:a) = $(git rev-parse C:a)
+		git rev-parse >expect \
+			A:a   C:a     &&
+		git rev-parse >actual \
+			:0:b  :0:a    &&
+		test_cmp expect actual
 	)
 '
 
@@ -336,9 +348,11 @@ test_expect_success 'rename/directory conflict + content merge conflict' '
 			left base right &&
 		test_cmp left newfile~HEAD &&
 
-		test $(git rev-parse :1:newfile) = $(git rev-parse base:file) &&
-		test $(git rev-parse :2:newfile) = $(git rev-parse left-conflict:newfile) &&
-		test $(git rev-parse :3:newfile) = $(git rev-parse right:file) &&
+		git rev-parse >expect                                 \
+			base:file   left-conflict:newfile  right:file &&
+		git rev-parse >actual                                 \
+			:1:newfile  :2:newfile             :3:newfile &&
+		test_cmp expect actual
 
 		test_path_is_file newfile/realfile &&
 		test_path_is_file newfile~HEAD
@@ -458,8 +472,11 @@ test_expect_success 'handle rename/rename (2to1) conflict correctly' '
 		test_path_is_file c~HEAD &&
 		test_path_is_file c~C^0 &&
 
-		test $(git hash-object c~HEAD) = $(git rev-parse C:a) &&
-		test $(git hash-object c~C^0) = $(git rev-parse B:b)
+		git rev-parse >expect   \
+			C:a     B:b     &&
+		git hash-object >actual \
+			c~HEAD  c~C^0   &&
+		test_cmp expect actual
 	)
 '
 
@@ -505,13 +522,15 @@ test_expect_success 'merge has correct working tree contents' '
 		git ls-files -o >out &&
 		test_line_count = 1 out &&
 
-		test $(git rev-parse :1:a) = $(git rev-parse A:a) &&
-		test $(git rev-parse :3:b) = $(git rev-parse A:a) &&
-		test $(git rev-parse :2:c) = $(git rev-parse A:a) &&
-
 		test_path_is_missing a &&
-		test $(git hash-object b) = $(git rev-parse A:a) &&
-		test $(git hash-object c) = $(git rev-parse A:a)
+		git rev-parse >expect   \
+			A:a   A:a   A:a \
+			A:a   A:a       &&
+		git rev-parse >actual    \
+			:1:a  :3:b  :2:c &&
+		git hash-object >>actual \
+			b     c          &&
+		test_cmp expect actual
 	)
 '
 
@@ -557,10 +576,11 @@ test_expect_failure 'detect conflict with rename/rename(1to2)/add-source merge'
 		git ls-files -o >out &&
 		test_line_count = 1 out &&
 
-		test $(git rev-parse 3:a) = $(git rev-parse C:a) &&
-		test $(git rev-parse 1:a) = $(git rev-parse A:a) &&
-		test $(git rev-parse 2:b) = $(git rev-parse B:b) &&
-		test $(git rev-parse 3:c) = $(git rev-parse C:c) &&
+		git rev-parse >expect         \
+			C:a   A:a   B:b   C:C &&
+		git rev-parse >actual          \
+			:3:a  :1:a  :2:b  :3:c &&
+		test_cmp expect actual
 
 		test_path_is_file a &&
 		test_path_is_file b &&
@@ -605,8 +625,11 @@ test_expect_failure 'rename/rename/add-source still tracks new a file' '
 		git ls-files -o >out &&
 		test_line_count = 1 out &&
 
-		test $(git rev-parse HEAD:a) = $(git rev-parse C:a) &&
-		test $(git rev-parse HEAD:b) = $(git rev-parse A:a)
+		git rev-parse >expect \
+			C:a   A:a     &&
+		git rev-parse >actual \
+			:0:a  :0:b    &&
+		test_cmp expect actual
 	)
 '
 
@@ -653,16 +676,17 @@ test_expect_success 'rename/rename/add-dest merge still knows about conflicting
 		git ls-files -o >out &&
 		test_line_count = 5 out &&
 
-		test $(git rev-parse :1:a) = $(git rev-parse A:a) &&
-		test $(git rev-parse :2:b) = $(git rev-parse C:b) &&
-		test $(git rev-parse :3:b) = $(git rev-parse B:b) &&
-		test $(git rev-parse :2:c) = $(git rev-parse C:c) &&
-		test $(git rev-parse :3:c) = $(git rev-parse B:c) &&
-
-		test $(git hash-object c~HEAD) = $(git rev-parse C:c) &&
-		test $(git hash-object c~B\^0) = $(git rev-parse B:c) &&
-		test $(git hash-object b~HEAD) = $(git rev-parse C:b) &&
-		test $(git hash-object b~B\^0) = $(git rev-parse B:b) &&
+		git rev-parse >expect               \
+			A:a   C:b   B:b   C:c   B:c &&
+		git rev-parse >actual                \
+			:1:a  :2:b  :3:b  :2:c  :3:c &&
+		test_cmp expect actual
+
+		git rev-parse >expect               \
+			C:c     B:c     C:b     B:b &&
+		git hash-object >actual                \
+			c~HEAD  c~B\^0  b~HEAD  b~B\^0 &&
+		test_cmp expect actual
 
 		test_path_is_missing b &&
 		test_path_is_missing c
-- 
2.17.0.1.gda85003413


  parent reply	other threads:[~2018-05-24  7:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-24  7:04 [PATCH 0/5] Modernize some testcases for merge-recursive corner cases Elijah Newren
2018-05-24  7:04 ` [PATCH 1/5] t6036, t6042: use test_create_repo to keep tests independent Elijah Newren
2018-05-24  7:04 ` [PATCH 2/5] t6036, t6042: use test_line_count instead of wc -l Elijah Newren
2018-05-24 10:05   ` SZEDER Gábor
2018-05-24 10:36     ` SZEDER Gábor
2018-05-24 17:03     ` Elijah Newren
2018-05-25  1:17     ` Junio C Hamano
2018-05-26  0:44       ` Elijah Newren
2018-05-24  7:04 ` [PATCH 3/5] t6036, t6042: prefer test_path_is_file, test_path_is_missing Elijah Newren
2018-05-24  7:04 ` Elijah Newren [this message]
2018-05-24  7:04 ` [PATCH 5/5] t6036: prefer test_when_finished to manual cleanup in following test Elijah Newren

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180524070439.6367-5-newren@gmail.com \
    --to=newren@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.