summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-02-09 22:52:33 -0500
committerTavian Barnes <tavianator@tavianator.com>2017-02-10 09:03:35 -0500
commit7b989b55f7c90e0855ccc0685eb77104a9622a2b (patch)
treedcb8c66461bcef14bb4a7397b0f194733d92d899
parent924826a817e397c89509963a1d13d951c9d51ce5 (diff)
downloadbfs-7b989b55f7c90e0855ccc0685eb77104a9622a2b.tar.xz
tests: Don't require bash associative arrays
That's a bash 4 feature, while macOS is stuck on bash 3.
-rwxr-xr-xtests.sh33
1 files changed, 11 insertions, 22 deletions
diff --git a/tests.sh b/tests.sh
index 3289f9a..95e7a9f 100755
--- a/tests.sh
+++ b/tests.sh
@@ -336,29 +336,16 @@ for arg; do
esac
done
-declare -A run_tests
-
-for test in "${posix_tests[@]}"; do
- run_tests["$test"]=yes
-done
-
-if [ "$BSD" ]; then
- for test in "${bsd_tests[@]}"; do
- run_tests["$test"]=yes
- done
-fi
-
-if [ "$GNU" ]; then
- for test in "${gnu_tests[@]}"; do
- run_tests["$test"]=yes
+function enable_tests() {
+ for test; do
+ declare -g run_$test=yes
done
-fi
+}
-if [ "$ALL" ]; then
- for test in "${bfs_tests[@]}"; do
- run_tests["$test"]=yes
- done
-fi
+enable_tests "${posix_tests[@]}"
+[ "$BSD" ] && enable_tests "${bsd_tests[@]}"
+[ "$GNU" ] && enable_tests "${gnu_tests[@]}"
+[ "$ALL" ] && enable_tests "${bfs_tests[@]}"
function bfs_sort() {
awk -F/ '{ print NF - 1 " " $0 }' | sort -n | cut -d' ' -f2-
@@ -989,7 +976,9 @@ function test_printf_leak() {
result=0
-for test in "${!run_tests[@]}"; do
+for test in ${!run_*}; do
+ test=${test#run_}
+
if [ -t 1 ]; then
printf '\r\033[J%s' "$test"
else