跳到主要内容

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

浏览文件

relay_stop_test.go

32 行 · 789 B历史下载
1package main
2
3import (
4 "os"
5 "os/exec"
6 "runtime"
7 "syscall"
8 "testing"
9)
10
11func TestRelayRecognizesOnlyTheRequestedTermination(t *testing.T) {
12 if runtime.GOOS == "windows" {
13 t.Skip("POSIX signal fixture; Windows build is checked separately")
14 }
15 for _, tc := range []struct {
16 child string
17 forwarded os.Signal
18 want bool
19 }{
20 {"kill -TERM $$", syscall.SIGTERM, true},
21 {"exit 143", syscall.SIGTERM, true},
22 {"exit 143", nil, false},
23 {"kill -TERM $$", nil, false},
24 {"exit 7", syscall.SIGTERM, false},
25 {"kill -KILL $$", syscall.SIGTERM, false},
26 } {
27 err := exec.Command("sh", "-c", tc.child).Run()
28 if got := expectedRelayStop(err, tc.forwarded); got != tc.want {
29 t.Fatalf("child=%q signal=%v: got %t, want %t", tc.child, tc.forwarded, got, tc.want)
30 }
31 }
32}