From: Patrick Steinhardt Date: Fri, 06 Nov 2026 10:30:05 GMT Subject: [PATCH 5/7] t0027: cache expected output files Message-ID: <20261106-pks-gitlab-ci-speedups-v1-5-1fa0374c7287@pks.im> In-Reply-To: <20261106-pks-gitlab-ci-speedups-v1-0-1fa0374c7287@pks.im> In the preceding commit we have optimized one aspect of t0027 already. Another inefficiency is `compare_files ()` and `compare_ws_file ()`, which are both called more than a 1000 times. These functions will repeatedly generate the same expected outcome even though there's only a small handful of input files that the expected outcome is computed from. Recomputing those every time is of course quite pointless. Improve this by computing the expected outcome once, only, to reduce the number of spawned processes. This reduces the runtime by around 20-25%, and on Windows the runtime decreases from 480 to 380 seconds. Signed-off-by: Patrick Steinhardt --- t/t0027-auto-crlf.sh | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/t/t0027-auto-crlf.sh b/t/t0027-auto-crlf.sh index eefb346d11f..25ed6b33704 100755 --- a/t/t0027-auto-crlf.sh +++ b/t/t0027-auto-crlf.sh @@ -5,22 +5,23 @@ test_description='CRLF conversion all combinations' . ./test-lib.sh compare_files () { - tr '\015\000' QN <"$1" >"$1".expect && + { test -f "$1".expect || tr '\015\000' QN <"$1" >"$1".expect; } && tr '\015\000' QN <"$2" | tr -d 'Z' >"$2".actual && - test_cmp "$1".expect "$2".actual && - rm "$1".expect "$2".actual + test_cmp "$1".expect "$2".actual } compare_ws_file () { pfx=$1 - exp=$2.expect + exp=$2.ws-expect act=$pfx.actual.$3 - tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" | - sed -e "s/0000*/$ZERO_OID/" >"$exp" && + { + test -f "$exp" || + tr '\015\000abcdef0123456789' QN00000000000000000 <"$2" | + sed -e "s/0000*/$ZERO_OID/" >"$exp" ; + } && tr '\015\000abcdef0123456789' QN00000000000000000 <"$3" | sed -e "s/0000*/$ZERO_OID/" >"$act" && - test_cmp "$exp" "$act" && - rm "$exp" "$act" + test_cmp "$exp" "$act" } create_gitattributes () { -- 2.56.0.500.g5d06dc02cd.dirty