diff --git a/tests/run-bats.sh b/tests/run-bats.sh index 9059661..8aff317 100755 --- a/tests/run-bats.sh +++ b/tests/run-bats.sh @@ -39,11 +39,12 @@ fi SCRATCH_ROOT="$(mktemp -d)" trap 'rm -rf "$SCRATCH_ROOT"' EXIT -# A failing test is the normal case a CI runner must handle, and a failing -# background job makes `wait`/`wait -n` return non-zero -- under `set -e` that -# would abort the script right here, before the per-file report below ever -# runs. Every wait in this dispatcher is therefore explicitly guarded. -JOBS="$(nproc 2>/dev/null || echo 4)" +# Batches (not a rolling pool) because a bounded rolling pool needs `wait -n`, +# which is bash 4.3+ and this script is explicitly bash-3.2-safe like +# run-tests.sh; plain `wait` -- waiting for every job in the current batch -- +# is available since ancient bash. `getconf` over `nproc` for the same +# reason: `nproc` doesn't exist on macOS. +JOBS="$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)" running=0 i=0 for f in "${TEST_FILES[@]}"; do @@ -51,11 +52,11 @@ for f in "${TEST_FILES[@]}"; do ( "$BATS" "$f" >"$SCRATCH_ROOT/$i.log" 2>&1; echo $? >"$SCRATCH_ROOT/$i.status" ) & running=$((running + 1)) if [[ "$running" -ge "$JOBS" ]]; then - wait -n || true - running=$((running - 1)) + wait + running=0 fi done -wait || true +wait FAIL=0 TOTAL_OK=0