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

Re: [PATCH] p3400: stop using tac(1)

From
Jeff King <peff@peff.net>
Date
Oct 4, 2021, 08:31 UTC
Message-ID
<YVq752xjzYz+LTq6@coredump.intra.peff.net>
In-Reply-To
<85831cc2-307f-1be8-9bb3-c44028ad07fa@web.de>
On Sat, Oct 02, 2021 at 07:44:14PM +0200, René Scharfe wrote:
> b3dfeebb92 (rebase: avoid computing unnecessary patch IDs, 2016-07-29)
> added a perf test that calls tac(1) from GNU core utilities.  Support
> systems without it by reversing the generated list using sort -nr
> instead.  sort(1) with options -n and -r is already used in other tests.
Cute fix. With regular seq(1), this whole thing can become:
  seq 1000 -1 1

without the extra process, but our test_seq doesn't understand non-1 increments (nor comparisons besides -le). It wouldn't be that hard to teach it, but given that this is the first time we've wanted it, it may not be worth the effort.

-Peff
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 6348e8d733..76c8c0f2f6 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -1149,15 +1149,22 @@ test_cmp_fspath () {
 
 test_seq () {
 	case $# in
-	1)	set 1 "$@" ;;
-	2)	;;
-	*)	BUG "not 1 or 2 parameters to test_seq" ;;
+	1)	set 1 1 "$1" ;;
+	2)	set "$1" 1 "$2" ;;
+	3)	;;
+	*)	BUG "not 1, 2, or 3 parameters to test_seq" ;;
 	esac
+	if test "$1" -lt "$3"
+	then
+		test_seq_cmp__=-le
+	else
+		test_seq_cmp__=-ge
+	fi
 	test_seq_counter__=$1
-	while test "$test_seq_counter__" -le "$2"
+	while test "$test_seq_counter__" $test_seq_cmp__ "$3"
 	do
 		echo "$test_seq_counter__"
-		test_seq_counter__=$(( $test_seq_counter__ + 1 ))
+		test_seq_counter__=$(( $test_seq_counter__ + $2 ))
 	done
 }
 
Previous: René ScharfeNext: René Scharfe
Message 2 of 7 in “p3400: stop using tac(1)”
  1. p3400: stop using tac(1)René Scharfe, Oct 2, 2021
  2. Jeff KingOct 4, 2021
  3. René ScharfeOct 5, 2021
  4. Jeff KingOct 5, 2021
  5. René ScharfeOct 5, 2021
  6. René ScharfeOct 7, 2021
  7. Junio C HamanoOct 7, 2021

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.