[v2,10/22] t4211: make test hash independent
diff mbox series

Message ID 20200125230035.136348-11-sandals@crustytoothpaste.net
State New
Headers show
Series
  • SHA-256 test fixes, part 8
Related show

Commit Message

brian m. carlson Jan. 25, 2020, 11 p.m. UTC
This test uses several test files that contain hard-coded SHA-1 object
IDs. Replace these values with generic ones of the correct size so that
the test works with either SHA-1 or SHA-256.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t4211-line-log.sh | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Johannes Schindelin Jan. 26, 2020, 10:13 p.m. UTC | #1
Hi brian,

On Sat, 25 Jan 2020, brian m. carlson wrote:

> This test uses several test files that contain hard-coded SHA-1 object
> IDs. Replace these values with generic ones of the correct size so that
> the test works with either SHA-1 or SHA-256.
>
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---

An alternative would be, of course, to change the files in t/t4211/ to
have SHA-256 variants, and then to implement a helper to replace those by
SHA-1 variants when needed.

It would be quite a bit more work (and I'd be willing to carry at least
some of it), but I think it would be worth it, in order to keep the
associated safety against regressions. Would you agree?

Ciao,
Dscho

>  t/t4211-line-log.sh | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
> index 8319163744..2cbfd8dd9e 100755
> --- a/t/t4211-line-log.sh
> +++ b/t/t4211-line-log.sh
> @@ -8,10 +8,20 @@ test_expect_success 'setup (import history)' '
>  	git reset --hard
>  '
>
> +process_output () {
> +	x07="$_x05[0-9a-f][0-9a-f]"
> +	sed -e "s/commit $OID_REGEX/commit $ZERO_OID/" \
> +	    -e "s/commit $_x40$/commit $ZERO_OID/" \
> +	    -e "s/Merge: $x07 $x07$/Merge: 0000000 0000000/" \
> +	    "$1"
> +}
> +
>  canned_test_1 () {
>  	test_expect_$1 "$2" "
> -		git log $2 >actual &&
> -		test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$3 actual
> +		git log $2 >result &&
> +		process_output result >actual &&
> +		process_output \"\$TEST_DIRECTORY\"/t4211/expect.$3 >expected &&
> +		test_cmp expected actual
>  	"
>  }
>
>

Patch
diff mbox series

diff --git a/t/t4211-line-log.sh b/t/t4211-line-log.sh
index 8319163744..2cbfd8dd9e 100755
--- a/t/t4211-line-log.sh
+++ b/t/t4211-line-log.sh
@@ -8,10 +8,20 @@  test_expect_success 'setup (import history)' '
 	git reset --hard
 '
 
+process_output () {
+	x07="$_x05[0-9a-f][0-9a-f]"
+	sed -e "s/commit $OID_REGEX/commit $ZERO_OID/" \
+	    -e "s/commit $_x40$/commit $ZERO_OID/" \
+	    -e "s/Merge: $x07 $x07$/Merge: 0000000 0000000/" \
+	    "$1"
+}
+
 canned_test_1 () {
 	test_expect_$1 "$2" "
-		git log $2 >actual &&
-		test_cmp \"\$TEST_DIRECTORY\"/t4211/expect.$3 actual
+		git log $2 >result &&
+		process_output result >actual &&
+		process_output \"\$TEST_DIRECTORY\"/t4211/expect.$3 >expected &&
+		test_cmp expected actual
 	"
 }