返回 DeepSeek-Reasonix
sync_output_test.go
根目录 / internal / cli / sync_output_test.go
1 package cli
2
3 import (
4 "testing"
5
6 tea "charm.land/bubbletea/v2"
7 "github.com/charmbracelet/x/ansi"
8 )
9
10 // TestForceSyncOutputOnlyOverSSH pins the #8405 workaround: synchronized
11 // output is forced on for SSH sessions (where bubbletea skips its capability
12 // query) and stays off locally unless the terminal itself reports support.
13 func TestForceSyncOutputOnlyOverSSH(t *testing.T) {
14 for _, k := range []string{"SSH_CONNECTION", "SSH_CLIENT", "SSH_TTY", "REASONIX_DISABLE_SYNC_OUTPUT"} {
15 t.Setenv(k, "")
16 }
17 if cmd := forceSyncOutputCmd(); cmd != nil {
18 t.Fatal("local sessions must not force synchronized output")
19 }
20 t.Setenv("SSH_TTY", "/dev/pts/3")
21 cmd := forceSyncOutputCmd()
22 if cmd == nil {
23 t.Fatal("SSH sessions must force synchronized output")
24 }
25 msg := cmd()
26 report, ok := msg.(tea.ModeReportMsg)
27 if !ok || report.Mode != ansi.ModeSynchronizedOutput || report.Value != ansi.ModeReset {
28 t.Fatalf("forceSyncOutputCmd() = %#v, want a 2026 mode report with reset value", msg)
29 }
30 t.Setenv("REASONIX_DISABLE_SYNC_OUTPUT", "1")
31 if cmd := forceSyncOutputCmd(); cmd != nil {
32 t.Fatal("REASONIX_DISABLE_SYNC_OUTPUT=1 must opt out")
33 }
34 }
35
35 lines GO