summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKerin Millar <kfm@plushkava.net>2024-07-10 01:22:46 +0100
committerKerin Millar <kfm@plushkava.net>2024-07-10 01:26:59 +0100
commitc8aaf36b70029898822934615283ac3fbf5ae785 (patch)
tree083c41dc87799e060b466cf5680cf29f47b7929b /test-functions
parentMention that _SC_NPROCESSORS_ONLN is now standard (diff)
downloadgentoo-functions-c8aaf36b70029898822934615283ac3fbf5ae785.tar.gz
gentoo-functions-c8aaf36b70029898822934615283ac3fbf5ae785.tar.bz2
gentoo-functions-c8aaf36b70029898822934615283ac3fbf5ae785.zip
test-functions: Check whether local is supported
Test whether the (non-standard) local builtin is present and behaving in a manner considered to be conventional. Should the test fail, refrain from conducting any further tests. This causes the test suite to fail early for ksh - a shell not currently supported by the project. Signed-off-by: Kerin Millar <kfm@plushkava.net>
Diffstat (limited to 'test-functions')
-rwxr-xr-xtest-functions82
1 files changed, 53 insertions, 29 deletions
diff --git a/test-functions b/test-functions
index dab0aea..f37477c 100755
--- a/test-functions
+++ b/test-functions
@@ -24,6 +24,29 @@ cleanup_tmpdir() {
fi
}
+test_local() {
+ (
+ var=1
+ f() {
+ local var=2
+ g
+ test "${var}" = 3 || exit
+ }
+ g() {
+ test "${var}" = 2 || exit
+ var=3
+ }
+ f
+ test "${var}" = 1
+ ) 2>/dev/null
+ retval=$?
+ if [ "${retval}" -ne 0 ]; then
+ printf 'not '
+ fi
+ printf 'ok %d - /bin/sh supports local\n' "$((testnum += 1))"
+ return "${retval}"
+}
+
test_chdir() {
set -- \
ge 1 grandchild \
@@ -905,38 +928,39 @@ if [ "${PORTAGE_BIN_PATH}" ] && [ "${S}" ]; then
genfun_basedir=${S}
fi
-if ! GENFUN_MODULES="portage rc" . ./functions.sh; then
+if ! test_local; then
+ rc=1
+elif ! GENFUN_MODULES="portage rc" . ./functions.sh; then
bailout "Couldn't source ./functions.sh"
+else
+ assign_tmpdir
+ test_chdir || rc=1
+ test_chdir_noop || rc=1
+ ( test_ebegin ) || rc=1; testnum=$((testnum + 1))
+ test_is_older_than || rc=1
+ test_get_bootparam || rc=1
+ test_esyslog || rc=1
+ test_is_identifier || rc=1
+ test_is_int || rc=1
+ test_is_visible || rc=1
+ test_yesno || rc=1
+ test_die || rc=1
+ test_edo || rc=1
+ test_srandom || rc=1
+ test_newest || rc=1
+ test_trim || rc=1
+ test_hr || rc=1
+ test_whenceforth || rc=1
+ test_parallel_run || rc=1
+ test_is_anyof || rc=1
+ test_is_subset || rc=1
+ test_trueof_all || rc=1
+ test_trueof_any || rc=1
+ #test_substr || rc=1
+ test_contains_all || rc=1
+ test_contains_any || rc=1
fi
-assign_tmpdir
-
-test_chdir || rc=1
-test_chdir_noop || rc=1
-( test_ebegin ) || rc=1; testnum=$((testnum + 1))
-test_is_older_than || rc=1
-test_get_bootparam || rc=1
-test_esyslog || rc=1
-test_is_identifier || rc=1
-test_is_int || rc=1
-test_is_visible || rc=1
-test_yesno || rc=1
-test_die || rc=1
-test_edo || rc=1
-test_srandom || rc=1
-test_newest || rc=1
-test_trim || rc=1
-test_hr || rc=1
-test_whenceforth || rc=1
-test_parallel_run || rc=1
-test_is_anyof || rc=1
-test_is_subset || rc=1
-test_trueof_all || rc=1
-test_trueof_any || rc=1
-#test_substr || rc=1
-test_contains_all || rc=1
-test_contains_any || rc=1
-
cleanup_tmpdir
printf '1..%d\n' "${testnum}"