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

[PATCH v2] t/test-lib.sh: minor readability improvements

From
Mathias Lafeldt <misfire@debugon.org>
Date
Apr 29, 2011, 12:30 UTC
Message-ID
<1304080230-11670-1-git-send-email-misfire@debugon.org>
In-Reply-To
<4DBA8C43.4040804@debugon.org>

Apply parameter expansion. Also use here document to save test results instead of appending each line with ">>".

Signed-off-by: Mathias Lafeldt <misfire@debugon.org>
---
 t/test-lib.sh |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/t/test-lib.sh b/t/test-lib.sh
index abc47f3..aca03d2 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -575,7 +575,7 @@ test_external () {
 test_external_without_stderr () {
 	# The temporary file has no (and must have no) security
 	# implications.
-	tmp="$TMPDIR"; if [ -z "$tmp" ]; then tmp=/tmp; fi
+	tmp=${TMPDIR:-/tmp}
 	stderr="$tmp/git-external-stderr.$$.tmp"
 	test_external "$@" 4> "$stderr"
 	[ -f "$stderr" ] || error "Internal error: $stderr disappeared."
@@ -801,12 +801,14 @@ test_done () {
 		mkdir -p "$test_results_dir"
 		test_results_path="$test_results_dir/${0%.sh}-$$.counts"
 
-		echo "total $test_count" >> $test_results_path
-		echo "success $test_success" >> $test_results_path
-		echo "fixed $test_fixed" >> $test_results_path
-		echo "broken $test_broken" >> $test_results_path
-		echo "failed $test_failure" >> $test_results_path
-		echo "" >> $test_results_path
+		cat >>"$test_results_path" <<-EOF
+		total $test_count
+		success $test_success
+		fixed $test_fixed
+		broken $test_broken
+		failed $test_failure
+
+		EOF
 	fi
 
 	if test "$test_fixed" != 0
-- 
1.7.5
Previous: Mathias LafeldtNext: Junio C Hamano
Message 4 of 5 in “t/test-lib.sh: minor readability improvements”
  1. t/test-lib.sh: minor readability improvementsMathias Lafeldt, Apr 27, 2011
  2. Junio C HamanoApr 27, 2011
  3. Mathias LafeldtApr 29, 2011
  4. t/test-lib.sh: minor readability improvementsMathias Lafeldt, Apr 29, 2011
  5. Junio C HamanoApr 29, 2011

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.