diff options
Diffstat (limited to 'tests/run.sh')
-rw-r--r-- | tests/run.sh | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/tests/run.sh b/tests/run.sh index 115a036..3ed2a9c 100644 --- a/tests/run.sh +++ b/tests/run.sh @@ -94,19 +94,17 @@ reap_test() { # Wait for a background test to finish wait_test() { - local pid + local pid line ret - while true; do - wait -n -ppid + while :; do + line=$((LINENO + 1)) + _wait -n -ppid ret=$? if [ "${pid:-}" ]; then break - elif ((ret > 128)); then - # Interrupted by signal - continue else - debug "${BASH_SOURCE[0]}" $((LINENO - 3)) "${RED}error $ret${RST}" >&$DUPERR + debug "${BASH_SOURCE[0]}" $line "${RED}error $ret${RST}" >&$DUPERR exit 1 fi done @@ -120,7 +118,9 @@ wait_ready() { # We'd like to parse the output of jobs -n, but we can't run it in a # subshell or we won't get the right output jobs -n >"$TMP/jobs" - while read -r job status ret foo; do + + local job status ret rest + while read -r job status ret rest; do case "$status" in Done) reap_test 0 @@ -156,7 +156,7 @@ comake() { exec {READY_PIPE}<&${COPROC[0]} {DONE_PIPE}>&${COPROC[1]} } -# Print the current test progess +# Print the current test progress progress() { if [ "${BAR:-}" ]; then print_bar "$(printf "$@")" @@ -359,20 +359,12 @@ invoke_bfs() { fi } -if command -v unbuffer &>/dev/null; then - UNBUFFER=unbuffer -elif command -v expect_unbuffer &>/dev/null; then - UNBUFFER=expect_unbuffer -fi - # Run bfs with a pseudo-terminal attached bfs_pty() { - test -n "${UNBUFFER:-}" || skip - bfs_verbose "$@" local ret=0 - "$UNBUFFER" bash -c 'stty cols 80 rows 24 && "$@" </dev/null' bash "${BFS[@]}" "$@" || ret=$? + "$PTYX" -w80 -h24 -- "${BFS[@]}" "$@" || ret=$? if ((ret > 125)); then exit $ret @@ -412,8 +404,13 @@ make_xattrs() { # Get the Unix epoch time in seconds epoch_time() { - # https://stackoverflow.com/a/12746260/502399 - awk 'BEGIN { srand(); print srand(); }' + if [ "${EPOCHSECONDS:-}" ]; then + # Added in bash 5 + printf '%d' "$EPOCHSECONDS" + else + # https://stackoverflow.com/a/12746260/502399 + awk 'BEGIN { srand(); print srand(); }' + fi } ## Snapshot testing |