1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-08 21:59:16 +00:00

Test case update

This commit is contained in:
Tw93
2025-11-15 13:40:43 +08:00
parent cccc41990e
commit f7dff3b798
7 changed files with 32 additions and 133 deletions

View File

@@ -95,8 +95,19 @@ teardown() {
}
@test "drain_pending_input clears stdin buffer" {
# Test that drain_pending_input doesn't hang
result=$(echo -e "test\ninput" | HOME="$HOME" timeout 1 bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/common.sh'; drain_pending_input; echo done")
# Test that drain_pending_input doesn't hang (using background job with timeout)
result=$(
(echo -e "test\ninput" | HOME="$HOME" bash --noprofile --norc -c "source '$PROJECT_ROOT/lib/common.sh'; drain_pending_input; echo done") &
pid=$!
sleep 2
if kill -0 "$pid" 2> /dev/null; then
kill "$pid" 2> /dev/null || true
wait "$pid" 2> /dev/null || true
echo "timeout"
else
wait "$pid" 2> /dev/null || true
fi
)
[[ "$result" == "done" ]]
}