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

[PATCH 2/2] test: relocate yes

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Mar 13, 2023, 05:01 UTC
Message-ID
<20230313050132.3464802-3-felipe.contreras@gmail.com>
In-Reply-To
<20230313050132.3464802-1-felipe.contreras@gmail.com>

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 --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
-- 
2.39.2.13.g1fb56cf030
Previous: Felipe Contreras
Message 3 of 3 in “test: framework API cleanup”
  1. 0/2 test: framework API cleanupFelipe Contreras, Mar 13, 2023
  2. 1/2 test: relocate test_expect_{success,failure}Felipe Contreras, Mar 13, 2023
  3. 2/2 test: relocate yesFelipe Contreras, Mar 13, 2023

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.