diff mbox series

[RFC,04/22] t: use hash-specific lookup tables to define test constants

Message ID 20200113124729.3684846-5-sandals@crustytoothpaste.net
State New, archived
Headers show
Series SHA-256 stage 4 implementation, part 1/3 | expand

Commit Message

brian m. carlson Jan. 13, 2020, 12:47 p.m. UTC
In the future, we'll allow developers to run the testsuite with a hash
algorithm of their choice.  To make this easier, compute the fixed
constants using test_oid. Move the constant initialization down below
the point where test-lib-functions.sh is loaded so the functions are

Note that we don't provide a value for the OID_REGEX value directly
because writing a large number of instances of "[0-9a-f]" in the
oid-info files is unwieldy and there isn't a way to compute it based on
those values. Instead, compute it based on ZERO_OID.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
 t/test-lib.sh | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)
diff mbox series


diff --git a/t/test-lib.sh b/t/test-lib.sh
index 44df51be8f..0b2566ad98 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -494,21 +494,6 @@  case $(echo $GIT_TRACE |tr "[A-Z]" "[a-z]") in
-# Convenience
-# A regexp to match 5, 35 and 40 hexdigits
-# Zero SHA-1
 # Line feed
@@ -1382,6 +1367,20 @@  then
+# Convenience
+# A regexp to match 5, 35 and 40 hexdigits
+ZERO_OID=$(test_oid zero)
+OID_REGEX=$(echo $ZERO_OID | sed -e 's/0/[0-9a-f]/g')
+EMPTY_TREE=$(test_oid empty_tree)
+EMPTY_BLOB=$(test_oid empty_blob)
 # Provide an implementation of the 'yes' utility; the upper bound
 # limit is there to help Windows that cannot stop this loop from
 # wasting cycles when the downstream stops reading, so do not be