@@ -369,15 +369,23 @@ rm -f /tmp/atch-envname.txt
369369# are replaced with underscores in the env var name:
370370# binary 'ssh2incus-atch' → env var 'SSH2INCUS_ATCH_SESSION'
371371DASH_ATCH=" $TESTDIR /bin/ssh2incus-atch"
372+ DASH_OUT=" $TESTDIR /atch-envdash.txt"
373+ ATCH_ABS=$( cd " $( dirname " $ATCH " ) " && pwd) /$( basename " $ATCH " )
372374mkdir -p " $TESTDIR /bin"
373- ln -s " $ATCH " " $DASH_ATCH " 2> /dev/null || cp " $ATCH " " $DASH_ATCH "
375+ ln -s " $ATCH_ABS " " $DASH_ATCH " 2> /dev/null || cp " $ATCH " " $DASH_ATCH "
374376" $DASH_ATCH " start envdash-test sh -c \
375- ' printf "%s\n" "$SSH2INCUS_ATCH_SESSION" > /tmp/atch-envdash.txt'
376- sleep 0.1
377- run grep -q " envdash-test" /tmp/atch-envdash.txt
377+ " printf '%s\n' \"\$ SSH2INCUS_ATCH_SESSION\" > '$DASH_OUT '"
378+ # Poll for the output file (up to 2s)
379+ i=0
380+ while [ $i -lt 40 ]; do
381+ [ -s " $DASH_OUT " ] && break
382+ sleep 0.05
383+ i=$(( i + 1 ))
384+ done
385+ run grep -q " envdash-test" " $DASH_OUT "
378386assert_exit " current: dash in binary name → underscore in env var name" 0 " $rc "
379387" $DASH_ATCH " kill envdash-test > /dev/null 2>&1
380- rm -f /tmp/atch-envdash.txt
388+ rm -f " $DASH_OUT "
381389
382390# ── 8. push command ───────────────────────────────────────────────────────────
383391
@@ -716,10 +724,12 @@ tidy s-tail
716724# appears to loop indefinitely.
717725#
718726# Strategy: create a synthetic .log file larger than SCROLLBACK_SIZE (128 KB),
719- # attach to the dead session using expect(1) to supply a PTY (required by
720- # attach_main), and verify the output byte count and content.
727+ # use the smart-open path (atch <session>) which replays the log for a dead
728+ # session before creating a new one, and verify the output byte count and
729+ # content. Note: strict attach (atch attach) no longer replays dead-session
730+ # logs (#26), so we must use the smart-open path here.
721731#
722- # expect(1) is available on macOS by default and on most Linux distros .
732+ # expect(1) is used to supply a real PTY (required by attach_main) .
723733# If absent, the test is skipped.
724734
725735if command -v expect > /dev/null 2>&1 && command -v python3 > /dev/null 2>&1 ; then
@@ -740,12 +750,13 @@ sys.stdout.buffer.write(old * old_count)
740750sys.stdout.buffer.write(new * new_count)
741751" > " $REPLAY_LOG "
742752
743- # Use expect to run atch attach with a real PTY, capturing all output.
744- # atch exits immediately after replaying the log for a dead session.
753+ # Use expect to run the smart-open path with a real PTY.
754+ # The smart-open path replays the dead-session log, then creates a new
755+ # session running 'exit 0' which exits immediately.
745756 REPLAY_OUT=$( mktemp)
746757 expect - << EXPECT_EOF > "$REPLAY_OUT " 2>/dev/null
747758set timeout 10
748- spawn $ATCH attach replay-cap-sess
759+ spawn $ATCH replay-cap-sess sh -c "exit 0"
749760expect eof
750761EXPECT_EOF
751762
0 commit comments