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

[PATCH 06/10] t0027: make hash size independent

From
brian m. carlson <sandals@crustytoothpaste.net>
Date
Jun 9, 2019, 22:43 UTC
Message-ID
<20190609224400.41557-7-sandals@crustytoothpaste.net>
In-Reply-To
<20190609224400.41557-1-sandals@crustytoothpaste.net>

Several parts of this test generate files that have specific hard-coded object IDs in them. We don't really care about what the object ID in question is, so we turn them all to zeros.

However, because some of these values are fixed and some are generated, they can be of different lengths, which causes problems when running with SHA-256. Furthermore, some assertions in this test use only fixed object IDs and some use both fixed and generated ones, so converting only the expected results fixes some tests while breaking others. Convert both actual and expected object IDs to the all-zeros object ID of the appropriate length to ensure that the test passes when using SHA-256.

The astute observer will notice that both tr and sed are used here. Converting the tr call to a sed y/// command looks logical at first, but it isn't possible because POSIX doesn't allow escapes in y/// commands other than "\\" and "\n".

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
---
 t/t0027-auto-crlf.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh
index 3587e454f1..959b6da449 100755
--- a/t/t0027-auto-crlf.sh
+++ b/t/t0027-auto-crlf.sh
@@ -15,8 +15,10 @@ compare_ws_file () {
 	pfx=$1
 	exp=$2.expect
 	act=$pfx.actual.$3
-	tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" >"$exp" &&
-	tr '\015\000abcdef0123456789' QN00000000000000000 <"$3" >"$act" &&
+	tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" |
+		sed -e "s/0000*/$ZERO_OID/" >"$exp" &&
+	tr '\015\000abcdef0123456789' QN00000000000000000 <"$3" |
+		sed -e "s/0000*/$ZERO_OID/" >"$act" &&
 	test_cmp "$exp" "$act" &&
 	rm "$exp" "$act"
 }
Previous: brian m. carlsonNext: brian m. carlson
Message 12 of 17 in “Hash-independent tests, part 4”
  1. 00/10 Hash-independent tests, part 4brian m. carlson, Jun 9, 2019
  2. 01/10 t: add helper to convert object IDs to pathsbrian m. carlson, Jun 9, 2019
  3. 02/10 t1410: make hash size independentbrian m. carlson, Jun 9, 2019
  4. 03/10 t1450: make hash size independentbrian m. carlson, Jun 9, 2019
  5. Eric SunshineJun 10, 2019
  6. brian m. carlsonJun 10, 2019
  7. Jonathan TanJun 11, 2019
  8. Eric SunshineJun 11, 2019
  9. brian m. carlsonJun 11, 2019
  10. brian m. carlsonJun 11, 2019
  11. 04/10 t5000: make hash independentbrian m. carlson, Jun 9, 2019
  12. 06/10 t0027: make hash size independentbrian m. carlson, Jun 9, 2019
  13. 05/10 t6030: make test work with SHA-256brian m. carlson, Jun 9, 2019
  14. 07/10 t0090: make test pass with SHA-256brian m. carlson, Jun 9, 2019
  15. 08/10 t1007: remove SHA1 prerequisitesbrian m. carlson, Jun 9, 2019
  16. 10/10 t2203: avoid hard-coded object ID valuesbrian m. carlson, Jun 9, 2019
  17. 09/10 t1710: make hash independentbrian m. carlson, Jun 9, 2019

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.