跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

terminal_windows_test.go

37 行 · 1006 B历史下载
1package workbench
2
3import (
4 "io"
5 "os/exec"
6 "strings"
7 "testing"
8 "time"
9)
10
11func TestWindowsTerminalInputResizeAndExit(t *testing.T) {
12 cmd := exec.Command("powershell.exe", "-NoProfile", "-NonInteractive", "-Command", "$v=[Console]::ReadLine(); [Console]::WriteLine('received:'+$v)")
13 terminal, err := startTerminal(cmd, 80, 24)
14 if err != nil {
15 t.Fatal(err)
16 }
17 t.Cleanup(func() { _ = terminal.Kill(); _ = terminal.Close() })
18 if err = terminal.Resize(120, 40); err != nil {
19 t.Fatal(err)
20 }
21 output := make(chan string, 1)
22 go func() { b, _ := io.ReadAll(terminal); output <- string(b) }()
23 if _, err = io.WriteString(terminal, "cage-terminal\r"); err != nil {
24 t.Fatal(err)
25 }
26 select {
27 case text := <-output:
28 if !strings.Contains(text, "received:cage-terminal") {
29 t.Fatalf("ConPTY input did not reach child: %q", text)
30 }
31 if err := terminal.Wait(); err != nil {
32 t.Fatal(err)
33 }
34 case <-time.After(15 * time.Second):
35 t.Fatal("ConPTY did not drain and close after child exit")
36 }
37}