diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-10-06 11:42:06 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-10-06 11:58:58 -0400 |
commit | 5e7b5eeb59f9f46ce916aaf968dd42570570580a (patch) | |
tree | 133c228e12ac8db13151b207a2bf927111bc9bb2 /tests | |
parent | 2d0cd364b63e26d7ede70cc1d6f85bea87850d84 (diff) | |
download | bfs-5e7b5eeb59f9f46ce916aaf968dd42570570580a.tar.xz |
tests: New bfs_pty wrapper for unbuffer
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bfs/color_auto.sh | 4 | ||||
-rw-r--r-- | tests/bfs/nocolor_env.sh | 2 | ||||
-rw-r--r-- | tests/bfs/status.sh | 4 | ||||
-rwxr-xr-x | tests/tests.sh | 14 |
4 files changed, 17 insertions, 7 deletions
diff --git a/tests/bfs/color_auto.sh b/tests/bfs/color_auto.sh index aa2eb02..7e875cc 100644 --- a/tests/bfs/color_auto.sh +++ b/tests/bfs/color_auto.sh @@ -1,6 +1,4 @@ -command -v unbuffer &>/dev/null || skip - unset NO_COLOR -unbuffer "${BFS[@]}" rainbow >"$OUT" +bfs_pty rainbow >"$OUT" sort_output diff_output diff --git a/tests/bfs/nocolor_env.sh b/tests/bfs/nocolor_env.sh index 399bdb0..0a17fb2 100644 --- a/tests/bfs/nocolor_env.sh +++ b/tests/bfs/nocolor_env.sh @@ -1,5 +1,5 @@ command -v unbuffer &>/dev/null || skip -NO_COLOR=1 unbuffer "${BFS[@]}" rainbow >"$OUT" +NO_COLOR=1 bfs_pty rainbow >"$OUT" sort_output diff_output diff --git a/tests/bfs/status.sh b/tests/bfs/status.sh index 30bdfa7..d3859e2 100644 --- a/tests/bfs/status.sh +++ b/tests/bfs/status.sh @@ -1,3 +1 @@ -command -v unbuffer &>/dev/null || skip - -unbuffer "${BFS[@]}" basic -status >"$OUT" +bfs_pty basic -status >"$OUT" diff --git a/tests/tests.sh b/tests/tests.sh index 61f17b4..5297446 100755 --- a/tests/tests.sh +++ b/tests/tests.sh @@ -488,6 +488,20 @@ function invoke_bfs() { fi } +function bfs_pty() { + command -v unbuffer &>/dev/null || skip + + bfs_verbose "$@" + unbuffer bash -c 'stty cols 80 rows 24 && "$@"' bash "${BFS[@]}" "$@" + local status="$?" + + if ((status > 125)); then + exit "$status" + else + return "$status" + fi +} + function check_exit() { local expected="$1" local actual="0" |