Skip to content

Commit 8d01029

Browse files
committed
Fix flakey test on Ubuntu
1 parent c1fa994 commit 8d01029

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

test/hdi.bats

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ setup() {
620620
# ── Interactive: copy to clipboard ───────────────────────────────────────────
621621

622622
@test "interactive: 'c' copies highlighted command to clipboard" {
623+
command -v python3 >/dev/null 2>&1 || skip "python3 required for PTY tests"
624+
623625
local fake_bin clip_file
624626
fake_bin="$(mktemp -d)"
625627
clip_file="$fake_bin/clipboard.txt"
@@ -631,12 +633,12 @@ setup() {
631633
# Keys: ↓ c q (navigate down one, copy, quit)
632634
local keys=$'\x1b[Bcq'
633635

634-
# Run interactively in a pseudo-TTY via script
635-
if [[ "$(uname)" == "Darwin" ]]; then
636-
printf '%s' "$keys" | script -q /dev/null env PATH="$fake_bin:$PATH" "$HDI" "$FIXTURES/node-express" >/dev/null 2>&1 || true
637-
else
638-
printf '%s' "$keys" | script -q -c "env PATH='$fake_bin:$PATH' '$HDI' '$FIXTURES/node-express'" /dev/null >/dev/null 2>&1 || true
639-
fi
636+
# Run interactively in a pseudo-TTY via Python pty module
637+
# (script(1) does not reliably forward stdin to the PTY on Linux)
638+
printf '%s' "$keys" | python3 -c "
639+
import pty, os, sys
640+
os.environ['PATH'] = sys.argv[1] + ':' + os.environ['PATH']
641+
pty.spawn(sys.argv[2:])" "$fake_bin" "$HDI" "$FIXTURES/node-express" >/dev/null 2>&1 || true
640642

641643
# Second command in node-express default mode is "nvm use 20"
642644
[ -f "$clip_file" ]

0 commit comments

Comments
 (0)