返回 DeepSeek-Reasonix
shell_label_test.go
根目录 / internal / boot / shell_label_test.go
1 package boot
2
3 import (
4 "testing"
5
6 "reasonix/internal/sandbox"
7 )
8
9 func TestResolvedShellLabelUsesBoundInterpreter(t *testing.T) {
10 for _, tc := range []struct {
11 name string
12 shell sandbox.Shell
13 configuredPath string
14 userShellPath string
15 want string
16 }{
17 {"configured path uses resolved executable", sandbox.Shell{Kind: sandbox.ShellPowerShell, Path: `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`}, `C:\stale\bash.exe`, "", `C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe`},
18 {"auto resolution preserves cache-stable kind", sandbox.Shell{Kind: sandbox.ShellBash, Path: `/opt/homebrew/bin/bash`}, "", "", "bash"},
19 {"kind fallback", sandbox.Shell{Kind: sandbox.ShellZsh}, "", "", "zsh"},
20 {"different user shell is identified", sandbox.Shell{Kind: sandbox.ShellBash, Path: `/bin/bash`}, "", "/bin/fish", "bash (tool subprocess; user login shell: fish)"},
21 {"same user shell keeps label", sandbox.Shell{Kind: sandbox.ShellBash, Path: `/bin/bash`}, "", "/bin/bash", "bash"},
22 } {
23 t.Run(tc.name, func(t *testing.T) {
24 if got := resolvedShellLabel(tc.shell, tc.configuredPath, tc.userShellPath); got != tc.want {
25 t.Fatalf("shell label = %q, want %q", got, tc.want)
26 }
27 })
28 }
29 }
30
30 lines GO