Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
changeset 758:7ead30e3b2f9
farray.sh: Check for typos in local variable names or missing "local" declarations for variables
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Sun, 20 Oct 2024 14:43:50 +0200 |
| parents | a339666cb421 |
| children | 6f3f1bb9502c |
| files | tests/farray-alist.t tests/farray-array.t tests/farray-object.t tests/testsetup.sh |
| diffstat | 4 files changed, 42 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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
--- 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 +}
