From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id A491D159C9B for ; Sun, 11 Aug 2024 10:11:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 22A942BC087; Sun, 11 Aug 2024 10:11:14 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 07DD52BC087 for ; Sun, 11 Aug 2024 10:11:14 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 256FF340C3C for ; Sun, 11 Aug 2024 10:11:13 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3F2611EE6 for ; Sun, 11 Aug 2024 10:11:10 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1723371059.df8c32007069a96a6ae56645b46771f598418b3e.sam@gentoo> Subject: [gentoo-commits] proj/gentoo-functions:master commit in: / X-VCS-Repository: proj/gentoo-functions X-VCS-Files: test-functions X-VCS-Directories: / X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: df8c32007069a96a6ae56645b46771f598418b3e X-VCS-Branch: master Date: Sun, 11 Aug 2024 10:11:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 6ba02e7e-129c-4ba7-bcd3-af4f45a9dbbb X-Archives-Hash: 11a9787586b7e86ee64961b4bbad30cb commit: df8c32007069a96a6ae56645b46771f598418b3e Author: Kerin Millar plushkava net> AuthorDate: Thu Aug 8 08:27:48 2024 +0000 Commit: Sam James gentoo org> CommitDate: Sun Aug 11 10:10:59 2024 +0000 URL: https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=df8c3200 test-functions: declare local variables where possible Given that test-functions bails out immediately in the absence of a conventional local builtin, one might as well. Besides, it would be trivial to eliminate local in the future, if so desired. Signed-off-by: Kerin Millar plushkava.net> Signed-off-by: Sam James gentoo.org> test-functions | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/test-functions b/test-functions index 79c66a9..00a128a 100755 --- a/test-functions +++ b/test-functions @@ -90,6 +90,8 @@ test_die() { eq 255 255 callback() { + local retval stderr + test_description="( exit $2 ); die" ( exit "$2" ) stderr=$(die "$2" 2>&1) @@ -134,6 +136,8 @@ test_edo() { } test_is_older_than() { + local age tstamp + set -- \ ge 1 N/A N/A \ ge 1 newer N/A \ @@ -212,6 +216,8 @@ test_is_older_than() { } test_get_bootparam() { + local cmdline + cmdline="foo gentoo=bar,baz quux" set -- \ ge 1 "${cmdline}" N/A \ @@ -228,6 +234,8 @@ test_get_bootparam() { ge 1 "${cmdline}" quux callback() { + local cmdline + cmdline=$2 shift 2 test_description="get_bootparam $(quote_args "$@")" @@ -252,6 +260,8 @@ test_esyslog() { } callback() { + local logged should_log + should_log=$2 shift 2 test_description="esyslog $(quote_args "$@")" @@ -429,6 +439,8 @@ test_srandom() { eq 0 callback() { + local number + number=$(srandom) test_description="srandom ($(( row += 1 ))/10: ${number:-blank})" is_int "${number}" \ @@ -612,6 +624,8 @@ test_hr() { eq 0 xxxxxxxxxxxxxxxxx xyz 17 callback() { + local expected + shift expected=$1 shift @@ -661,6 +675,8 @@ test_whenceforth() { chmod +x newer/file callback() { + local path + shift path=$1 shift @@ -692,6 +708,8 @@ test_get_nprocs() { set -- eq 0 callback() { + local nproc + shift test_description="get_nprocs" nproc=$(get_nprocs) && is_int "${nproc}" && test "${nproc}" -gt 0 @@ -836,6 +854,8 @@ test_substr() { eq 0 '' foobar 4 -1 callback() { + local expected str + shift expected=$1 shift @@ -927,7 +947,7 @@ test_quote_args() { set -- eq 0 callback() { - local POSIXLY_CORRECT i + local POSIXLY_CORRECT cksum fmt i str test_description="quote_args output test (expecting cksum 380900690)" i=0 @@ -957,6 +977,8 @@ test_assign() { eq 0 valid_nameref marmoset callback() { + local injection + shift test_description="assign $(quote_args "$@")" injection= @@ -978,6 +1000,8 @@ test_deref() { ge 1 PWD 'injection=1 #' callback() { + local assignee injection stdout + shift test_description="deref $(quote_args "$@")" case $# in @@ -996,6 +1020,8 @@ test_deref() { } test_update_time() { + local locale + set -- \ de_BE de_DE es_ES fr_BE fr_CA fr_FR it_IT nl_BE nl_NL pl_PL \ pt_BR pt_PT ru_RU sv_SE @@ -1015,6 +1041,8 @@ test_update_time() { set -- "$@" eq 0 '' callback() { + local genfun_time + shift if [ "$1" ]; then test_description="LC_ALL=$1 _update_time" @@ -1040,9 +1068,10 @@ test_update_time() { } iterate_tests() { + local code i j passed slice_width total + slice_width=$1 shift - total=$(( $# / slice_width )) passed=0 i=0