返回 DeepSeek-Reasonix
shell_explicit_bash_test.go
根目录 / internal / sandbox / shell_explicit_bash_test.go
1 package sandbox
2
3 import (
4 "os/exec"
5 "testing"
6 )
7
8 func TestExplicitBashPreservesHookDialectDespiteWindowsAgentPolicy(t *testing.T) {
9 const bashPath = `C:\Git\bin\bash.exe`
10 snap := &shellSnapshot{
11 goos: "windows",
12 lookPath: func(string) (string, error) { return "", exec.ErrNotFound },
13 exists: func(path string) bool { return path == bashPath },
14 isWSL: func(string) bool { return false },
15 bashCands: []string{bashPath},
16 probeFunc: func(path string) bool { return path == bashPath },
17 probeCache: make(map[string]bool),
18 }
19 got, ok := resolveExplicitBash(snap, "")
20 if !ok || got.Kind != ShellBash || got.Path != bashPath {
21 t.Fatalf("explicit hook shell = %+v, found=%v", got, ok)
22 }
23 if preference := effectiveShellPreference("windows", "bash", nil); preference != "auto" {
24 t.Fatalf("Agent policy changed: %q", preference)
25 }
26 snap.bashCands = nil
27 if _, ok := resolveExplicitBash(snap, ""); ok {
28 t.Fatal("missing explicit Bash must not fall back to PowerShell")
29 }
30 }
31
31 lines GO