# HG changeset patch # User Franz Glasner # Date 1729428230 -7200 # Node ID 7ead30e3b2f99a0535b72d63c80e7fe44816f57e # Parent a339666cb42187ed91f233a63afebe7f01512808 farray.sh: Check for typos in local variable names or missing "local" declarations for variables diff -r a339666cb421 -r 7ead30e3b2f9 tests/farray-alist.t --- a/tests/farray-alist.t Sun Oct 20 13:27:10 2024 +0200 +++ b/tests/farray-alist.t Sun Oct 20 14:43:50 2024 +0200 @@ -962,3 +962,9 @@ DEBUG: `K22' -> `V22' $ falist_release LIST $ check_no_alist_artifacts + + +No Locals +========= + + $ check_no_local_artifacts diff -r a339666cb421 -r 7ead30e3b2f9 tests/farray-array.t --- a/tests/farray-array.t Sun Oct 20 13:27:10 2024 +0200 +++ b/tests/farray-array.t Sun Oct 20 14:43:50 2024 +0200 @@ -1733,3 +1733,9 @@ DEBUG: 2: `i22' $ farray_release TEST $ check_no_array_artifacts + + +No Locals +========= + + $ check_no_local_artifacts diff -r a339666cb421 -r 7ead30e3b2f9 tests/farray-object.t --- a/tests/farray-object.t Sun Oct 20 13:27:10 2024 +0200 +++ b/tests/farray-object.t Sun Oct 20 14:43:50 2024 +0200 @@ -87,3 +87,9 @@ $ falist_release LIST1 $ check_no_array_artifacts $ check_no_alist_artifacts + + +No Locals +========= + + $ check_no_local_artifacts diff -r a339666cb421 -r 7ead30e3b2f9 tests/testsetup.sh --- a/tests/testsetup.sh Sun Oct 20 13:27:10 2024 +0200 +++ b/tests/testsetup.sh Sun Oct 20 14:43:50 2024 +0200 @@ -3,6 +3,15 @@ # Test helpers for the shell unittests using cram. # + +#: +#: Set some directories to temporary values for inclusion of test configuration +#: files. +#: +CONFIGDIR="${TESTDIR}/etc" +PACKAGE_MAPPING="${CONFIGDIR}/package-mapping.conf" + + #: #: Check that no global variables that hold any array storage are left. #: @@ -33,3 +42,18 @@ return 0 fi } + + +#: +#: Check that no local variables are globally visible. +#: +#: Because all local variables have the ``__farr_`` prefix it can easily +#: checked that no forgotten "local" declarations exist. +#: +check_no_local_artifacts() { + if set | grep -E -e '^__farr.*='; then + return 1 + else + return 0 + fi +}