返回 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 TestExplicitBashPreservesHookDialectWithoutPowerShellFallback(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 snap.bashCands = nil
24 if _, ok := resolveExplicitBash(snap, ""); ok {
25 t.Fatal("missing explicit Bash must not fall back to PowerShell")
26 }
27 }
28
28 lines GO