git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Nguyễn Thái Ngọc Duy" <pclouds@gmail.com>,
	"Martin Ågren" <martin.agren@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>,
	"Johannes Sixt" <j6t@kdbg.org>,
	"Stefan Beller" <sbeller@google.com>
Subject: [PATCH v4 16/28] t4008: abstract away SHA-1-specific constants
Date: Mon, 21 May 2018 02:01:35 +0000	[thread overview]
Message-ID: <20180521020147.648496-17-sandals@crustytoothpaste.net> (raw)
In-Reply-To: <20180521020147.648496-1-sandals@crustytoothpaste.net>

Adjust the test so that it computes variables for blobs instead of using
hard-coded hashes.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4008-diff-break-rewrite.sh | 59 +++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 27 deletions(-)

diff --git a/t/t4008-diff-break-rewrite.sh b/t/t4008-diff-break-rewrite.sh
index 9dd1bc5e16..b1ccd4102e 100755
--- a/t/t4008-diff-break-rewrite.sh
+++ b/t/t4008-diff-break-rewrite.sh
@@ -27,29 +27,32 @@ Further, with -B and -M together, these should turn into two renames.
 test_expect_success setup '
 	cat "$TEST_DIRECTORY"/diff-lib/README >file0 &&
 	cat "$TEST_DIRECTORY"/diff-lib/COPYING >file1 &&
+	blob0_id=$(git hash-object file0) &&
+	blob1_id=$(git hash-object file1) &&
 	git update-index --add file0 file1 &&
 	git tag reference $(git write-tree)
 '
 
 test_expect_success 'change file1 with copy-edit of file0 and remove file0' '
 	sed -e "s/git/GIT/" file0 >file1 &&
+	blob2_id=$(git hash-object file1) &&
 	rm -f file0 &&
 	git update-index --remove file0 file1
 '
 
 test_expect_success 'run diff with -B (#1)' '
 	git diff-index -B --cached reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 000000 548142c327a6790ff8821d67c2ee1eff7a656b52 0000000000000000000000000000000000000000 D	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec M100	file1
+	cat >expect <<-EOF &&
+	:100644 000000 $blob0_id $ZERO_OID D	file0
+	:100644 100644 $blob1_id $blob2_id M100	file1
 	EOF
 	compare_diff_raw expect current
 '
 
 test_expect_success 'run diff with -B and -M (#2)' '
 	git diff-index -B -M reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec R100	file0	file1
+	cat >expect <<-EOF &&
+	:100644 100644 $blob0_id $blob2_id R100	file0	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -66,18 +69,18 @@ test_expect_success 'swap file0 and file1' '
 
 test_expect_success 'run diff with -B (#3)' '
 	git diff-index -B reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 6ff87c4664981e4397625791c8ea3bbb5f2279a3 M100	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M100	file1
+	cat >expect <<-EOF &&
+	:100644 100644 $blob0_id $blob1_id M100	file0
+	:100644 100644 $blob1_id $blob0_id M100	file1
 	EOF
 	compare_diff_raw expect current
 '
 
 test_expect_success 'run diff with -B and -M (#4)' '
 	git diff-index -B -M reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 6ff87c4664981e4397625791c8ea3bbb5f2279a3 R100	file1	file0
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 548142c327a6790ff8821d67c2ee1eff7a656b52 R100	file0	file1
+	cat >expect <<-EOF &&
+	:100644 100644 $blob1_id $blob1_id R100	file1	file0
+	:100644 100644 $blob0_id $blob0_id R100	file0	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -85,14 +88,15 @@ test_expect_success 'run diff with -B and -M (#4)' '
 test_expect_success 'make file0 into something completely different' '
 	rm -f file0 &&
 	test_ln_s_add frotz file0 &&
+	slink_id=$(printf frotz | git hash-object --stdin) &&
 	git update-index file1
 '
 
 test_expect_success 'run diff with -B (#5)' '
 	git diff-index -B reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M100	file1
+	cat >expect <<-EOF &&
+	:100644 120000 $blob0_id $slink_id T	file0
+	:100644 100644 $blob1_id $blob0_id M100	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -103,9 +107,9 @@ test_expect_success 'run diff with -B -M (#6)' '
 	# file0 changed from regular to symlink.  file1 is the same as the preimage
 	# of file0.  Because the change does not make file0 disappear, file1 is
 	# denoted as a copy of file0
-	cat >expect <<-\EOF &&
-	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 548142c327a6790ff8821d67c2ee1eff7a656b52 C	file0	file1
+	cat >expect <<-EOF &&
+	:100644 120000 $blob0_id $slink_id T	file0
+	:100644 100644 $blob0_id $blob0_id C	file0	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -115,9 +119,9 @@ test_expect_success 'run diff with -M (#7)' '
 
 	# This should not mistake file0 as the copy source of new file1
 	# due to type differences.
-	cat >expect <<-\EOF &&
-	:100644 120000 548142c327a6790ff8821d67c2ee1eff7a656b52 67be421f88824578857624f7b3dc75e99a8a1481 T	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 548142c327a6790ff8821d67c2ee1eff7a656b52 M	file1
+	cat >expect <<-EOF &&
+	:100644 120000 $blob0_id $slink_id T	file0
+	:100644 100644 $blob1_id $blob0_id M	file1
 	EOF
 	compare_diff_raw expect current
 '
@@ -128,25 +132,26 @@ test_expect_success 'file1 edited to look like file0 and file0 rename-edited to
 	git checkout-index -f -u -a &&
 	sed -e "s/git/GIT/" file0 >file1 &&
 	sed -e "s/git/GET/" file0 >file2 &&
+	blob3_id=$(git hash-object file2) &&
 	rm -f file0 &&
 	git update-index --add --remove file0 file1 file2
 '
 
 test_expect_success 'run diff with -B (#8)' '
 	git diff-index -B reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 000000 548142c327a6790ff8821d67c2ee1eff7a656b52 0000000000000000000000000000000000000000 D	file0
-	:100644 100644 6ff87c4664981e4397625791c8ea3bbb5f2279a3 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec M100	file1
-	:000000 100644 0000000000000000000000000000000000000000 69a939f651686f56322566e2fd76715947a24162 A	file2
+	cat >expect <<-EOF &&
+	:100644 000000 $blob0_id $ZERO_OID D	file0
+	:100644 100644 $blob1_id $blob2_id M100	file1
+	:000000 100644 $ZERO_OID $blob3_id A	file2
 	EOF
 	compare_diff_raw expect current
 '
 
 test_expect_success 'run diff with -B -C (#9)' '
 	git diff-index -B -C reference >current &&
-	cat >expect <<-\EOF &&
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 2fbedd0b5d4b8126e4750c3bee305e8ff79f80ec C095	file0	file1
-	:100644 100644 548142c327a6790ff8821d67c2ee1eff7a656b52 69a939f651686f56322566e2fd76715947a24162 R095	file0	file2
+	cat >expect <<-EOF &&
+	:100644 100644 $blob0_id $blob2_id C095	file0	file1
+	:100644 100644 $blob0_id $blob3_id R095	file0	file2
 	EOF
 	compare_diff_raw expect current
 '

  parent reply	other threads:[~2018-05-21  2:03 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16  1:56 [PATCH v3 00/28] Hash-independent tests brian m. carlson
2018-05-16  1:56 ` [PATCH v3 01/28] t/test-lib: add an SHA1 prerequisite brian m. carlson
2018-05-16  1:56 ` [PATCH v3 02/28] t/test-lib: introduce ZERO_OID brian m. carlson
2018-05-16  1:56 ` [PATCH v3 03/28] t: switch $_z40 to $ZERO_OID brian m. carlson
2018-05-16  1:56 ` [PATCH v3 04/28] t/test-lib: introduce OID_REGEX brian m. carlson
2018-05-16  1:56 ` [PATCH v3 05/28] t: switch $_x40 to $OID_REGEX brian m. carlson
2018-05-16  1:56 ` [PATCH v3 06/28] t0000: annotate with SHA1 prerequisite brian m. carlson
2018-05-16  1:56 ` [PATCH v3 07/28] t1007: " brian m. carlson
2018-05-16 16:56   ` Stefan Beller
2018-05-16 23:10     ` brian m. carlson
2018-05-16  1:56 ` [PATCH v3 08/28] t1512: skip test if not using SHA-1 brian m. carlson
2018-05-16  1:56 ` [PATCH v3 09/28] t4044: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 10/28] t: skip pack tests " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 11/28] t2203: abstract away SHA-1-specific constants brian m. carlson
2018-05-16  1:56 ` [PATCH v3 12/28] t3103: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 13/28] t3702: " brian m. carlson
2018-05-16 17:18   ` Stefan Beller
2018-05-16 23:46     ` brian m. carlson
2018-05-16  1:56 ` [PATCH v3 14/28] t3905: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 15/28] t4007: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 16/28] t4008: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 17/28] t4014: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 18/28] t4020: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 19/28] t4022: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 20/28] t4029: fix test indentation brian m. carlson
2018-05-16  1:56 ` [PATCH v3 21/28] t4029: abstract away SHA-1-specific constants brian m. carlson
2018-05-16  1:56 ` [PATCH v3 22/28] t4030: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 23/28] t/lib-diff-alternative: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 24/28] t4205: sort log output in a hash-independent way brian m. carlson
2018-05-16  1:56 ` [PATCH v3 25/28] t4042: abstract away SHA-1-specific constants brian m. carlson
2018-05-16  1:56 ` [PATCH v3 26/28] t4045: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 27/28] t4208: " brian m. carlson
2018-05-16  1:56 ` [PATCH v3 28/28] t5300: " brian m. carlson
2018-05-21  2:01 ` [PATCH v4 00/28] Hash-independent tests brian m. carlson
2018-05-21  2:01   ` [PATCH v4 01/28] t/test-lib: add an SHA1 prerequisite brian m. carlson
2018-05-21  2:01   ` [PATCH v4 02/28] t/test-lib: introduce ZERO_OID brian m. carlson
2018-05-21  2:01   ` [PATCH v4 03/28] t: switch $_z40 to $ZERO_OID brian m. carlson
2018-05-21  2:01   ` [PATCH v4 04/28] t/test-lib: introduce OID_REGEX brian m. carlson
2018-05-21  2:01   ` [PATCH v4 05/28] t: switch $_x40 to $OID_REGEX brian m. carlson
2018-05-21  2:01   ` [PATCH v4 06/28] t0000: annotate with SHA1 prerequisite brian m. carlson
2018-05-21  2:01   ` [PATCH v4 07/28] t1007: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 08/28] t1512: skip test if not using SHA-1 brian m. carlson
2018-05-21  2:01   ` [PATCH v4 09/28] t4044: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 10/28] t: skip pack tests " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 11/28] t2203: abstract away SHA-1-specific constants brian m. carlson
2018-05-21  2:01   ` [PATCH v4 12/28] t3103: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 13/28] t3702: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 14/28] t3905: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 15/28] t4007: " brian m. carlson
2018-05-21  2:01   ` brian m. carlson [this message]
2018-05-21  2:01   ` [PATCH v4 17/28] t4014: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 18/28] t4020: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 19/28] t4022: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 20/28] t4029: fix test indentation brian m. carlson
2018-05-21  2:01   ` [PATCH v4 21/28] t4029: abstract away SHA-1-specific constants brian m. carlson
2018-05-21  2:01   ` [PATCH v4 22/28] t4030: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 23/28] t/lib-diff-alternative: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 24/28] t4205: sort log output in a hash-independent way brian m. carlson
2018-05-21  2:01   ` [PATCH v4 25/28] t4042: abstract away SHA-1-specific constants brian m. carlson
2018-05-21  2:01   ` [PATCH v4 26/28] t4045: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 27/28] t4208: " brian m. carlson
2018-05-21  2:01   ` [PATCH v4 28/28] t5300: " brian m. carlson
2018-05-21 13:17   ` [PATCH v4 00/28] Hash-independent tests Ben Peart
2018-05-21 23:08     ` brian m. carlson

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20180521020147.648496-17-sandals@crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=martin.agren@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=sbeller@google.com \
    --cc=sunshine@sunshineco.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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).