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

Re: [PATCH] tests: turn on network daemon tests by default

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 12, 2014, 22:34 UTC
Message-ID
<xmqq38jom037.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20140212214753.GA6799@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
>   test_normalize_tristate GIT_TEST_DAEMON

Heh, great minds think alike. This is what I am playing with, without committing (because I do like your "ask config if this is a kind of various boolean 'false' representations, which I haven't managed to add to it).

 t/lib-git-daemon.sh     |  2 +-
 t/lib-httpd.sh          |  2 +-
 t/test-lib-functions.sh | 45 +++++++++++++++++++++++++++------------------
 3 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/t/lib-git-daemon.sh b/t/lib-git-daemon.sh
index 36106de..615bf5d 100644
--- a/t/lib-git-daemon.sh
+++ b/t/lib-git-daemon.sh
@@ -16,7 +16,7 @@
 #	stop_git_daemon
 #	test_done
 
-GIT_TEST_GIT_DAEMON=$(test_tristate "$GIT_TEST_GIT_DAEMON")
+test_tristate GIT_TEST_GIT_DAEMON
 if test "$GIT_TEST_GIT_DAEMON" = false
 then
 	skip_all="git-daemon testing disabled (unset GIT_TEST_GIT_DAEMON to enable)"
diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh
index 583fb14..f9c2e22 100644
--- a/t/lib-httpd.sh
+++ b/t/lib-httpd.sh
@@ -30,7 +30,7 @@
 # Copyright (c) 2008 Clemens Buchacher <drizzd@aon.at>
 #
 
-GIT_TEST_HTTPD=$(test_tristate "$GIT_TEST_HTTPD")
+test_tristate GIT_TEST_HTTPD
 if test "$GIT_TEST_HTTPD" = false
 then
 	skip_all="Network testing disabled (unset GIT_TEST_HTTPD to enable)"
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 3cc09c0..21c5214 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -716,27 +716,36 @@ perl () {
 	command "$PERL_PATH" "$@"
 }
 
-# Normalize the value given in $1 to one of "true", "false", or "auto". The
-# result is written to stdout. E.g.:
+# Given a variable $1, normalize the value of it to one of "true",
+# "false", or "auto" and store the result to it.
 #
-#     GIT_TEST_HTTPD=$(test_tristate "$GIT_TEST_HTTPD")
+#     test_tristate GIT_TEST_HTTPD
 #
+# A variable set to an empty string is set to 'false'.
+# A variable set to 'false' or 'auto' keeps its value.
+# Anything else is set to 'true'.
+# An unset variable defaults to 'auto'.
+#
+# The last rule is to allow people to set the variable to an empty
+# string and export it to decline testing the particular feature
+# for versions both before and after this change.  We used to treat
+# both unset and empty variable as a signal for "do not test" and
+# took any non-empty string as "please test".
+
 test_tristate () {
-	case "$1" in
-	""|auto)
-		echo auto
-		;;
-	*)
-		# Rely on git-config to handle all the variants of
-		# true/1/on/etc that we allow.
-		if ! git -c magic.hack="$1" config --bool magic.hack 2>/dev/null
-		then
-			# If git-config failed, it was some non-bool value like
-			# YesPlease. Default this to "true" for historical
-			# compatibility.
-			echo true
-		fi
-	esac
+	if eval "test x\"\${$1+isset}\" = xisset"
+	then
+		# explicitly set
+		eval "
+			case \"\$$1\" in
+			'')	$1=false ;;
+			false | auto) ;;
+			*)	$1=true ;;
+			esac
+		"
+	else
+		eval "$1=auto"
+	fi
 }
 
 # Exit the test suite, either by skipping all remaining tests or by
Previous: Jeff KingNext: Junio C Hamano
Message 17 of 44 in “Fix the shallow deepen bug with no-done”
  1. 0/6 Fix the shallow deepen bug with no-doneNguyễn Thái Ngọc Duy, Feb 6, 2014
  2. 1/6 test: rename http fetch and push test filesNguyễn Thái Ngọc Duy, Feb 6, 2014
  3. Jeff KingFeb 6, 2014
  4. 2/6 t5538: fix default http portNguyễn Thái Ngọc Duy, Feb 6, 2014
  5. Jeff KingFeb 6, 2014
  6. Jeff KingFeb 7, 2014
  7. Duy NguyenFeb 8, 2014
  8. Jeff KingFeb 10, 2014
  9. Junio C HamanoFeb 10, 2014
  10. Jeff KingFeb 10, 2014
  11. Jeff KingFeb 10, 2014
  12. tests: turn on network daemon tests by defaultJeff King, Feb 10, 2014
  13. Junio C HamanoFeb 11, 2014
  14. Jeff KingFeb 11, 2014
  15. Junio C HamanoFeb 11, 2014
  16. Jeff KingFeb 12, 2014
  17. Junio C HamanoFeb 12, 2014
  18. Junio C HamanoFeb 13, 2014
  19. Jeff KingFeb 14, 2014
  20. Junio C HamanoFeb 14, 2014
  21. Junio C HamanoFeb 12, 2014
  22. Jeff KingFeb 12, 2014
  23. Duy NguyenFeb 13, 2014
  24. t5537: move http tests out to t5539Nguyễn Thái Ngọc Duy, Feb 13, 2014
  25. Junio C HamanoFeb 13, 2014
  26. 3/6 pack-protocol.txt: clarify 'obj-id' in the last ACK after 'done'Nguyễn Thái Ngọc Duy, Feb 6, 2014
  27. Junio C HamanoFeb 6, 2014
  28. 4/6 protocol-capabilities.txt: refer multi_ack_detailed back to pack-protocol.txtNguyễn Thái Ngọc Duy, Feb 6, 2014
  29. 5/6 protocol-capabilities.txt: document no-doneNguyễn Thái Ngọc Duy, Feb 6, 2014
  30. Junio C HamanoFeb 6, 2014
  31. Jeff KingFeb 6, 2014
  32. 6/6 fetch-pack: fix deepen shallow over smart http with no-done capNguyễn Thái Ngọc Duy, Feb 6, 2014
  33. Junio C HamanoFeb 6, 2014
  34. Duy NguyenFeb 7, 2014
  35. Eric SunshineFeb 6, 2014
  36. Jeff KingFeb 6, 2014
  37. Junio C HamanoFeb 7, 2014
  38. Duy NguyenFeb 7, 2014
  39. Junio C HamanoFeb 10, 2014
  40. Junio C HamanoFeb 6, 2014
  41. Jeff KingFeb 6, 2014
  42. Duy NguyenFeb 7, 2014
  43. Jonathan NiederFeb 7, 2014
  44. Junio C HamanoFeb 7, 2014

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.