diff tests/testsetup.sh @ 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 33df05108ba1
children bae0652d0577
line wrap: on
line diff
--- 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
+}