cad2d783b3
release / build-web (push) Has been cancelled
release / build-bundles (aarch64-linux-gnu-gcc, arm64, linux, ubuntu-latest, linux-arm64) (push) Has been cancelled
release / build-bundles (amd64, darwin, macos-13, macos-x64) (push) Has been cancelled
release / build-bundles (amd64, linux, ubuntu-latest, linux-x64) (push) Has been cancelled
release / build-bundles (amd64, windows, windows-latest, windows-x64) (push) Has been cancelled
release / build-bundles (arm64, darwin, macos-14, macos-arm64) (push) Has been cancelled
feat: windows support
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package process
|
|
|
|
import (
|
|
"runtime"
|
|
"testing"
|
|
)
|
|
|
|
func TestDefaultShellCommand_CustomShell(t *testing.T) {
|
|
cmd := defaultShellCommand("/usr/local/bin/fish")
|
|
if cmd[0] != "/usr/local/bin/fish" {
|
|
t.Errorf("expected preferred shell as first element, got %q", cmd[0])
|
|
}
|
|
}
|
|
|
|
func TestDefaultShellCommand_EmptyPreferred(t *testing.T) {
|
|
cmd := defaultShellCommand("")
|
|
if len(cmd) == 0 {
|
|
t.Fatal("expected non-empty command")
|
|
}
|
|
// On Unix, should fall back to $SHELL or /bin/sh with -l flag
|
|
// On Windows, should fall back to %COMSPEC% or powershell.exe
|
|
if runtime.GOOS != "windows" {
|
|
if cmd[len(cmd)-1] != "-l" {
|
|
t.Errorf("expected login flag -l on Unix, got %v", cmd)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestShellExecArgs(t *testing.T) {
|
|
prog, args := shellExecArgs("echo hello")
|
|
if prog == "" {
|
|
t.Fatal("expected non-empty program")
|
|
}
|
|
if len(args) == 0 {
|
|
t.Fatal("expected non-empty args")
|
|
}
|
|
// The command string should appear in the args
|
|
found := false
|
|
for _, a := range args {
|
|
if a == "echo hello" {
|
|
found = true
|
|
break
|
|
}
|
|
}
|
|
if !found {
|
|
t.Errorf("expected command string in args, got prog=%q args=%v", prog, args)
|
|
}
|
|
}
|