test_curses.sh: add test for reading from stdin for plumber in non-interactive mode - sfeed_tests - sfeed tests and RSS and Atom files
HTML git clone git://git.codemadness.org/sfeed_tests
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit 884b358f90417b70a0102463093d6ccf9f32b145
DIR parent 836843fc99ddc614248418c14a00804326544227
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sat, 11 Apr 2026 20:23:33 +0200
test_curses.sh: add test for reading from stdin for plumber in non-interactive mode
This tests for the bug that was recently fixed:
https://git.codemadness.org/sfeed/commit/45fba594ca26328ae1d7ba3b133983755af1d745.html
Diffstat:
M test_curses.sh | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+), 0 deletions(-)
---
DIR diff --git a/test_curses.sh b/test_curses.sh
@@ -1289,6 +1289,35 @@ fi
rm -f /tmp/sfeed_curses_path
test_end
+
+# Read from stdin in non-interactive mode should read from /dev/null succesfully (no read error).
+# assumes cat will return non-zero on a read error.
+test_start "Reading from stdin for plumber in non-interactive mode"
+
+testplumbread="$(mktemp)"
+stderr="$(mktemp)"
+$printf '#!/bin/sh\ncat 2>"%s"\necho $? >"%s"\n' "$stderr" "$plumbfile" > "$testplumbread"
+chmod +x "$testplumbread"
+
+rm -f "$plumbfile"
+touch "$plumbfile"
+
+# watchdog, kill it, but makes sure plumb script is run (must run within N seconds).
+(sleep 1; pkill -SIGTERM sfeed_curses) &
+fakedata | SFEED_PLUMBER_INTERACTIVE="0" SFEED_PLUMBER="$testplumbread" SFEED_AUTOCMD="o" $sc
+status=$?
+test $status -eq 143 || fail "Exit code must be 143, was: $status" # must be terminated
+
+contents="$(cat "$plumbfile")"
+test "$contents" = "0" || fail "Incorrect exit statuscode: $contents, must be 0"
+
+contents="$(cat "$stderr")"
+rm -f "$testplumbread" "$stderr"
+test "$contents" = "" || fail "Incorrect, stderr output should be empty"
+
+test_end
+
+
# -a runs automated tests only.
test "$1" = "-a" || manual