]> Sergey Matveev's repositories - bfs.git/commitdiff
tests: New bfs_pty wrapper for unbuffer
authorTavian Barnes <tavianator@tavianator.com>
Fri, 6 Oct 2023 15:42:06 +0000 (11:42 -0400)
committerTavian Barnes <tavianator@tavianator.com>
Fri, 6 Oct 2023 15:58:58 +0000 (11:58 -0400)
tests/bfs/color_auto.sh
tests/bfs/nocolor_env.sh
tests/bfs/status.sh
tests/tests.sh

index aa2eb022d79523503b92c18b853359586a410be4..7e875cc9924b5a3ed5ef51dc0583dd4334358bf7 100644 (file)
@@ -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
index 399bdb0656db26e4213b2396419237e7df513735..0a17fb22d05ca27739cfb3f1a09931b37d90140e 100644 (file)
@@ -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
index 30bdfa7530d3c343681fba6ef6563f58471a8d59..d3859e262d74f71e1df6a6e7c6841d250280fb04 100644 (file)
@@ -1,3 +1 @@
-command -v unbuffer &>/dev/null || skip
-
-unbuffer "${BFS[@]}" basic -status >"$OUT"
+bfs_pty basic -status >"$OUT"
index 61f17b4d3ab3c37a53be3eba7c6341d2be59ff4f..5297446d7ef02b1f644c6d73492a3d439229f74c 100755 (executable)
@@ -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"