. "$BST_LIB"
require expect expect/present

# expect drives a real pty (spawn/send/expect/wait) — coverage shell cannot do.
# On wasm32-hwjs expect currently execve-EINVALs (BRINTOS-37): present-but-broken,
# so this reports `not ok` (a real failure), never `skip`. It passes once
# BRINTOS-37 lands — which blocks this suite.
out=$(expect "$BST_DATA/selftest_expect.exp" 2>&1); rc=$?

case "$out" in *ALL-EXPECT-OK*) all=1 ;; *) all=0 ;; esac
if [ "$rc" -eq 0 ] && [ "$all" -eq 1 ]; then bst_ok expect/all-ok
else bst_notok expect/all-ok "rc=$rc $(_bst_1line "$out")"; fi

for tag in E1ver E2spawn E3regexp E4wait; do
  case "$out" in
    *"E-$tag OK"*) bst_ok "expect/$tag" ;;
    *)             bst_notok "expect/$tag" "not OK in output (rc=$rc)" ;;
  esac
done
