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

[PATCH v2] t5607: avoid using prerequisites to select algorithm

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Aug 11, 2021, 23:16 UTC
Message-ID
<20210811231644.570030-1-sandals@crustytoothpaste.net>
In-Reply-To
<YRRZ7E6W+xV2f/CG@camp.crustytoothpaste.net>

In this test, we currently use the SHA1 prerequisite to specify the algorithm we're using to test, since SHA-256 bundles are always v3, whereas SHA-1 bundles default to v2, and as a result the default output differs.

However, this causes a problem if we run with GIT_TEST_FAIL_PREREQS set, since that means that we'll unexpectedly fail the SHA1 prerequisite, resulting in incorrect expected output. Let's fix this by checking against the built-in data called "algo", which tells us which algorithm is in use. This should work in any situation, making our test a little more robust.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t5607-clone-bundle.sh | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/t/t5607-clone-bundle.sh b/t/t5607-clone-bundle.sh
index ed0d911e95..51705aa86a 100755
--- a/t/t5607-clone-bundle.sh
+++ b/t/t5607-clone-bundle.sh
@@ -91,7 +91,8 @@ test_expect_success 'ridiculously long subject in boundary' '
 
 	git fetch long-subject-bundle.bdl &&
 
-	if ! test_have_prereq SHA1
+	algo=$(test_oid algo) &&
+	if test "$algo" != sha1
 	then
 		echo "@object-format=sha256"
 	fi >expect &&
@@ -100,7 +101,7 @@ test_expect_success 'ridiculously long subject in boundary' '
 	$(git rev-parse HEAD) HEAD
 	EOF
 
-	if test_have_prereq SHA1
+	if test "$algo" = sha1
 	then
 		head -n 3 long-subject-bundle.bdl
 	else
Previous: brian m. carlsonNext: Jeff King
Message 4 of 5 in “t5607 fail with GIT_TEST_FAIL_PREREQS enabled”
  1. Son Luong NgocAug 11, 2021
  2. Jeff KingAug 11, 2021
  3. brian m. carlsonAug 11, 2021
  4. t5607: avoid using prerequisites to select algorithmbrian m. carlson, Aug 11, 2021
  5. Jeff KingAug 11, 2021

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.