[PATCH 3/1] t3920: simplify redirection of loop output

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Redirect the output of for loops once instead of deleting the receiving
file and appending the output of individual commands.  This reduces
repetition and speeds up the test.  Here are the numbers on my Windows
machine before:

   $ (cd t && hyperfine.exe -w3 "sh.exe t3920-crlf-messages.sh")
   Benchmark 1: sh.exe t3920-crlf-messages.sh
     Time (mean ± σ):      5.923 s ±  0.037 s    [User: 0.000 s, System: 0.004 s]
     Range (min … max):    5.889 s …  5.997 s    10 runs

... and with this patch:

   Benchmark 1: sh.exe t3920-crlf-messages.sh
     Time (mean ± σ):      5.705 s ±  0.047 s    [User: 0.000 s, System: 0.001 s]
     Range (min … max):    5.632 s …  5.772 s    10 runs

Signed-off-by: René Scharfe <l.s.r@xxxxxx>
---
 t/t3920-crlf-messages.sh | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/t/t3920-crlf-messages.sh b/t/t3920-crlf-messages.sh
index 67fd2345af..4fc9fa9cad 100755
--- a/t/t3920-crlf-messages.sh
+++ b/t/t3920-crlf-messages.sh
@@ -68,12 +68,11 @@ test_crlf_subject_body_and_contents() {
 		set ${atoms} && atom=$1 && shift && atoms="$*" &&
 		set ${files} && file=$1 && shift && files="$*" &&
 		test_expect_success "${command}: --format='%${atom}' works with messages using CRLF" "
-			rm -f expect &&
 			for ref in ${LIB_CRLF_BRANCHES}
 			do
-				cat .crlf-${file}-\"\${ref}\".txt >>expect &&
-				printf \"\n\" >>expect || return 1
-			done &&
+				cat .crlf-${file}-\"\${ref}\".txt &&
+				printf \"\n\" || return 1
+			done >expect &&
 			git $command_and_args --format=\"%${atom}\" >actual &&
 			test_cmp expect actual
 		"
@@ -87,13 +86,12 @@ test_expect_success 'Setup refs with commit and tag messages using CRLF' '
 '

 test_expect_success 'branch: --verbose works with messages using CRLF' '
-	rm -f expect &&
 	for branch in $LIB_CRLF_BRANCHES
 	do
-		printf "  " >>expect &&
-		cat .crlf-subject-${branch}.txt >>expect &&
-		printf "\n" >>expect || return 1
-	done &&
+		printf "  " &&
+		cat .crlf-subject-${branch}.txt &&
+		printf "\n" t || return 1
+	done >expect &&
 	git branch -v >tmp &&
 	# Remove first two columns, and the line for the currently checked out branch
 	current=$(git branch --show-current) &&
--
2.38.1.windows.1




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux