[v2,06/24] t: use hash-specific lookup tables to define test constants
diff mbox series

Message ID 20200222201749.937983-7-sandals@crustytoothpaste.net
State New
Headers show
  • SHA-256 stage 4 implementation, part 1/3
Related show

Commit Message

brian m. carlson Feb. 22, 2020, 8:17 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 0ea1e5a05e..9fe390bd5a 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
@@ -1383,6 +1368,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