diff mbox series

[2/2] test: relocate yes

Message ID 20230313050132.3464802-3-felipe.contreras@gmail.com (mailing list archive)
State New, archived
Headers show
Series test: framework API cleanup | expand

Commit Message

Felipe Contreras March 13, 2023, 5:01 a.m. UTC
This is a command meant to be called by the subshells: therefore it
belongs in test-lib-functions.sh.

Cc: Brandon Casey <drafnel@gmail.com>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 t/test-lib-functions.sh | 21 +++++++++++++++++++++
 t/test-lib.sh           | 21 ---------------------
 2 files changed, 21 insertions(+), 21 deletions(-)
diff mbox series

Patch

diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 49a850989a..da39d98391 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -87,6 +87,27 @@  test_decode_color () {
 	'
 }
 
+# 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
+# tempted to turn it into an infinite loop. cf. 6129c930 ("test-lib:
+# limit the output of the yes utility", 2016-02-02)
+yes () {
+	if test $# = 0
+	then
+		y=y
+	else
+		y="$*"
+	fi
+
+	i=0
+	while test $i -lt 99
+	do
+		echo "$y"
+		i=$(($i+1))
+	done
+}
+
 lf_to_nul () {
 	perl -pe 'y/\012/\000/'
 }
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 388075a6c6..24aedc122d 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1694,27 +1694,6 @@  OIDPATH_REGEX=$(test_oid_to_path $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
-# tempted to turn it into an infinite loop. cf. 6129c930 ("test-lib:
-# limit the output of the yes utility", 2016-02-02)
-yes () {
-	if test $# = 0
-	then
-		y=y
-	else
-		y="$*"
-	fi
-
-	i=0
-	while test $i -lt 99
-	do
-		echo "$y"
-		i=$(($i+1))
-	done
-}
-
 # The GIT_TEST_FAIL_PREREQS code hooks into test_set_prereq(), and
 # thus needs to be set up really early, and set an internal variable
 # for convenience so the hot test_set_prereq() codepath doesn't need