summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.github/workflows/ci.yml4
-rw-r--r--tests/run.sh26
-rw-r--r--tests/util.sh17
3 files changed, 18 insertions, 29 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 72037e3..ff0ff6f 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -52,7 +52,9 @@ jobs:
- name: Install dependencies
run: |
- brew install expect
+ brew install \
+ bash \
+ expect
- name: Run tests
run: |
diff --git a/tests/run.sh b/tests/run.sh
index 4a159f9..85d961f 100644
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -28,7 +28,7 @@ debug_err() {
callers | while read -r line func file; do
if [ "$func" = source ]; then
local cmd="$(awk "NR == $line" "$file" 2>/dev/null)" || :
- debug "$file" $line "${RED}error $ret${RST}" "$cmd" >&4
+ debug "$file" $line "${RED}error $ret${RST}" "$cmd" >&$DUPERR
break
fi
done
@@ -73,21 +73,9 @@ bg_test() {
return $ret
}
-# Wait for any background job to complete
-if ((BASH_VERSINFO[0] > 4 || (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 3))); then
- wait_any() {
- wait -n
- }
-else
- wait_any() {
- read -ra jobs < <(jobs -p)
- wait ${jobs[0]}
- }
-fi
-
# Wait for a background test to finish
wait_test() {
- wait_any
+ wait -n
ret=$?
((BG--))
@@ -197,7 +185,7 @@ skip() {
caller | {
read -r line file
printf "${BOL}"
- debug "$file" $line "" "$(awk "NR == $line" "$file")" >&3
+ debug "$file" $line "" "$(awk "NR == $line" "$file")" >&$DUPOUT
}
fi
@@ -252,8 +240,8 @@ bfs_verbose() {
(
# Close some fds to make room for the pipe,
# even with extremely low ulimit -n
- exec >&- 4>&-
- exec >&3 3>&-
+ exec >&- {DUPERR}>&-
+ exec >&$DUPOUT {DUPOUT}>&-
color bfs_verbose_impl "$@"
)
fi
@@ -306,7 +294,7 @@ invoke_bfs() {
local ret=0
# Close the logging fds
- "${BFS[@]}" "$@" 3>&- 4>&- || ret=$?
+ "${BFS[@]}" "$@" {DUPOUT}>&- {DUPERR}>&- || ret=$?
# Allow bfs to fail, but not crash
if ((ret > 125)); then
@@ -391,7 +379,7 @@ diff_output() {
if ((UPDATE)); then
cp "$OUT" "$GOLD"
else
- $DIFF -u "$GOLD" "$OUT" >&4
+ $DIFF -u "$GOLD" "$OUT" >&$DUPERR
fi
}
diff --git a/tests/util.sh b/tests/util.sh
index 5bd3328..686cc77 100644
--- a/tests/util.sh
+++ b/tests/util.sh
@@ -68,7 +68,7 @@ stdenv() {
# Close stdin so bfs doesn't think we're interactive
# dup() the standard fds for logging even when redirected
- exec </dev/null 3>&1 4>&2
+ exec </dev/null {DUPOUT}>&1 {DUPERR}>&2
}
# Drop root priviliges or bail
@@ -159,19 +159,18 @@ defer() {
# Pop a single command from the defer stack and run it
pop_defer() {
- local i=$((${#DEFER_CMDS[@]} - 1))
- local cmd="${DEFER_CMDS[$i]}"
- local file="${DEFER_FILES[$i]}"
- local line="${DEFER_LINES[$i]}"
- unset "DEFER_CMDS[$i]"
- unset "DEFER_FILES[$i]"
- unset "DEFER_LINES[$i]"
+ local cmd="${DEFER_CMDS[-1]}"
+ local file="${DEFER_FILES[-1]}"
+ local line="${DEFER_LINES[-1]}"
+ unset "DEFER_CMDS[-1]"
+ unset "DEFER_FILES[-1]"
+ unset "DEFER_LINES[-1]"
local ret=0
eval "$cmd" || ret=$?
if ((ret != 0)); then
- debug "$file" $line "${RED}error $ret${RST}" "defer $cmd" >&4
+ debug "$file" $line "${RED}error $ret${RST}" "defer $cmd" >&$DUPERR
fi
return $ret