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

[PATCH] test-lib: simplify GIT_SKIP_TESTS loop

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jul 9, 2010, 10:01 UTC
Message-ID
<0f97dc0377b97675f45b568254dabefb5b1e0146.1278669505.git.git@drmicha.warpmail.net>

04ece59 (GIT_SKIP_TESTS: allow users to omit tests that are known to break, 2006-12-28) introduced GIT_SKIP_TESTS, and since then we have had two nested loops iterating over GIT_SKIP_TESTS with the same loop variable.

Reduce this to one loop.
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
I am probably making a complete shell fool out of myself by overlooking
something completely trivial.

But just in case I am not, this reduces the loop from O(N^2) to O(N), although I do admit that N is typically not that large... (Note that the inner $skp does not overwrite the outer one, at least not with bash.)

 t/test-lib.sh |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index ac496aa..8e3de53 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -827,23 +827,20 @@ cd -P "$test" || exit 1
 
 this_test=${0##*/}
 this_test=${this_test%%-*}
+to_skip=
 for skp in $GIT_SKIP_TESTS
 do
-	to_skip=
-	for skp in $GIT_SKIP_TESTS
-	do
-		case "$this_test" in
-		$skp)
-			to_skip=t
-		esac
-	done
-	case "$to_skip" in
-	t)
-		say_color skip >&3 "skipping test $this_test altogether"
-		say_color skip "skip all tests in $this_test"
-		test_done
+	case "$this_test" in
+	$skp)
+		to_skip=t
 	esac
 done
+case "$to_skip" in
+t)
+	say_color skip >&3 "skipping test $this_test altogether"
+	say_color skip "skip all tests in $this_test"
+	test_done
+esac
 
 # Provide an implementation of the 'yes' utility
 yes () {
-- 
1.7.2.rc1.212.g850a
Next: Junio C Hamano
Message 1 of 3 in “test-lib: simplify GIT_SKIP_TESTS loop”
  1. test-lib: simplify GIT_SKIP_TESTS loopMichael J Gruber, Jul 9, 2010
  2. Junio C HamanoJul 9, 2010
  3. [PATCHv2] test-lib: simplify GIT_SKIP_TESTS loopMichael J Gruber, Jul 12, 2010

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.