返回 DeepSeek-Reasonix
bash_persistent_windows_test.go
根目录 / internal / tool / builtin / bash_persistent_windows_test.go
1 //go:build windows
2
3 package builtin
4
5 import (
6 "os"
7 "path/filepath"
8 "strings"
9 "testing"
10
11 "reasonix/internal/sandbox"
12 )
13
14 // Exercise the complete foreground tool path with an explicitly selected Git
15 // Bash. Manager-only tests cannot catch a host silently binding PowerShell or
16 // routing this call through a terminal or a fresh one-shot process.
17 func TestBashPersistentWindowsUnicodeAndState(t *testing.T) {
18 sh, ok := sandbox.ResolveExplicitBash("")
19 if !ok {
20 t.Skip("Git Bash is required for the native Windows regression")
21 }
22 t.Setenv("LC_ALL", "C")
23 dir := t.TempDir()
24 filename := "中文😀.txt"
25 if err := os.WriteFile(filepath.Join(dir, filename), []byte("内容😀"), 0o600); err != nil {
26 t.Fatal(err)
27 }
28 if err := os.Mkdir(filepath.Join(dir, "sub"), 0o700); err != nil {
29 t.Fatal(err)
30 }
31 b := persistentBash(t, dir)
32 b.shell = sh
33 ctx := fullAccessBashTestContext(t.Context())
34 for _, tc := range []struct{ command, want string }{
35 {"ls -a", filename},
36 {"test ! -t 1; cat '" + filename + "'", "内容😀"},
37 {"export RX_WINDOWS_PIPE='变量😀'; cd sub; printf 'changed'", "changed"},
38 {"printf '%s:%s' \"${PWD##*/}\" \"$RX_WINDOWS_PIPE\"", "sub:变量😀"},
39 } {
40 out, err := b.Execute(ctx, argsJSON(t, map[string]any{"command": tc.command}))
41 if err != nil || !strings.Contains(out, tc.want) {
42 t.Fatalf("%s: output=%q error=%v", tc.command, out, err)
43 }
44 }
45 }
46
46 lines GO