diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2019-09-11 22:57:41 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2019-09-11 22:57:41 -0400 |
commit | 067a40c9967365fe39f61aca3aec5f4eda225315 (patch) | |
tree | c383533b1ce21385acdb26b40b7a3aec8746a3de | |
parent | 4f80c17192f2b28c96a489969d4435151d68d0ce (diff) | |
download | bfs-067a40c9967365fe39f61aca3aec5f4eda225315.tar.xz |
tests.sh: Use an array for the enabled tests
The separate $run_test_* variables were sensitive to the environment
that ran the script.
-rwxr-xr-x | tests.sh | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -95,11 +95,7 @@ UPDATE= VERBOSE= EXPLICIT= -function enable_tests() { - for test; do - eval run_$test=yes - done -} +enabled_tests=() for arg; do case "$arg" in @@ -146,7 +142,7 @@ for arg; do ;; test_*) EXPLICIT=yes - enable_tests "$arg" + enabled_tests+=("$arg") ;; *) printf "${RED}error:${RST} Unrecognized option '%s'.\n\n" "$arg" >&2 @@ -676,13 +672,15 @@ if [ "$DEFAULT" ]; then fi if [ ! "$EXPLICIT" ]; then - [ "$POSIX" ] && enable_tests "${posix_tests[@]}" - [ "$BSD" ] && enable_tests "${bsd_tests[@]}" - [ "$GNU" ] && enable_tests "${gnu_tests[@]}" - [ "$ALL" ] && enable_tests "${bfs_tests[@]}" - [ "$SUDO" ] && enable_tests "${sudo_tests[@]}" + [ "$POSIX" ] && enabled_tests+=("${posix_tests[@]}") + [ "$BSD" ] && enabled_tests+=("${bsd_tests[@]}") + [ "$GNU" ] && enabled_tests+=("${gnu_tests[@]}") + [ "$ALL" ] && enabled_tests+=("${bfs_tests[@]}") + [ "$SUDO" ] && enabled_tests+=("${sudo_tests[@]}") fi +eval enabled_tests=($(printf '%q\n' "${enabled_tests[@]}" | sort -u)) + # The temporary directory that will hold our test data TMP="$(mktemp -d "${TMPDIR:-/tmp}"/bfs.XXXXXXXXXX)" chown "$(id -u):$(id -g)" "$TMP" @@ -2533,12 +2531,10 @@ fi passed=0 failed=0 -for test in ${!run_*}; do - test=${test#run_} - +for test in "${enabled_tests[@]}"; do printf "${BOL}${YLW}%s${RST}${EOL}" "$test" - ("$test" "$dir") + ("$test") status=$? if [ $status -eq 0 ]; then |