Publish Claude Code Binaries / Stage and publish binaries (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-arm64 (push) Canceled after 0s
Publish Tutti App Runtime / Build darwin-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build linux-amd64 (push) Canceled after 0s
Publish Tutti App Runtime / Build windows-amd64 (push) Canceled after 0s
Sync Tutti Agent Skills / sync (push) Canceled after 0s
Windows Agent Adapters / Test Windows agent adapters (push) Canceled after 0s
Windows Daemon Adapters / Test Windows daemon adapters (push) Canceled after 0s
Publish Tutti App Runtime / Publish runtime catalog (push) Canceled after 0s
103 lines
3.1 KiB
Go
103 lines
3.1 KiB
Go
//go:build windows
|
|
|
|
package agentstatus
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
"reflect"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestNewInstallShellCommandUsesCmdInterpreter(t *testing.T) {
|
|
t.Setenv("ComSpec", `C:\Windows\System32\cmd.exe`)
|
|
command := newInstallShellCommand(context.Background(), "echo tutti")
|
|
want := []string{`C:\Windows\System32\cmd.exe`, "/D", "/S", "/C", "echo tutti"}
|
|
if !reflect.DeepEqual(command.Args, want) {
|
|
t.Fatalf("command args = %#v, want %#v", command.Args, want)
|
|
}
|
|
}
|
|
|
|
func TestLoginCommandDoesNotUsePOSIXSingleQuotesOnWindows(t *testing.T) {
|
|
command := joinLoginShellCommand([]string{`C:\\Users\\tester\\AppData\\Local\\opencode.CMD`, "auth", "login"})
|
|
want := `C:\\Users\\tester\\AppData\\Local\\opencode.CMD auth login`
|
|
if command != want {
|
|
t.Fatalf("login command = %q, want %q", command, want)
|
|
}
|
|
}
|
|
|
|
func TestLoginCommandQuotesWindowsPathsWithSpaces(t *testing.T) {
|
|
command := joinLoginShellCommand([]string{`C:\\Program Files\\opencode\\opencode.CMD`, "auth", "login"})
|
|
want := `"C:\\Program Files\\opencode\\opencode.CMD" auth login`
|
|
if command != want {
|
|
t.Fatalf("login command = %q, want %q", command, want)
|
|
}
|
|
}
|
|
|
|
func TestPlatformExecutableFileAcceptsPlainWindowsFile(t *testing.T) {
|
|
path := filepath.Join(t.TempDir(), "command.exe")
|
|
if err := os.WriteFile(path, []byte("command"), 0o644); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
info, err := os.Stat(path)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if !platformExecutableFile(info) {
|
|
t.Fatal("platformExecutableFile() = false")
|
|
}
|
|
}
|
|
|
|
func TestOfficialScriptInvocationUsesManagedPosixShell(t *testing.T) {
|
|
env := []string{
|
|
"PATH=C:\\Windows\\System32",
|
|
managedPosixShellInstallerEnv + `=C:\\Work\\managed-posix-shell\\usr\\bin\\bash.exe`,
|
|
}
|
|
command, args, gotEnv := officialScriptInvocation("bash", `C:\\Users\\tester\\AppData\\Local\\Temp\\install.sh`, env)
|
|
wantArgs := []string{
|
|
`C:\\Work\\managed-posix-shell\\usr\\bin\\bash.exe`,
|
|
"--noprofile",
|
|
"--norc",
|
|
`C:\\Users\\tester\\AppData\\Local\\Temp\\install.sh`,
|
|
}
|
|
if !reflect.DeepEqual(args, wantArgs) {
|
|
t.Fatalf("args = %#v, want %#v", args, wantArgs)
|
|
}
|
|
if command != joinShellCommand(wantArgs) {
|
|
t.Fatalf("command = %q, want %q", command, joinShellCommand(wantArgs))
|
|
}
|
|
if got := installerEnvValue(gotEnv, "MSYS2_PATH_TYPE"); got != "inherit" {
|
|
t.Fatalf("MSYS2_PATH_TYPE = %q, want inherit", got)
|
|
}
|
|
}
|
|
|
|
func TestRunDefaultInstallCommandExecutesCmdPathWithSpaces(t *testing.T) {
|
|
scriptPath := filepath.Join(t.TempDir(), "path with spaces", "fake npm.cmd")
|
|
if err := os.MkdirAll(filepath.Dir(scriptPath), 0o755); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if err := os.WriteFile(
|
|
scriptPath,
|
|
[]byte("@echo off\r\necho marker=%1\r\nexit /b 0\r\n"),
|
|
0o644,
|
|
); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
result, err := runDefaultInstallCommand(context.Background(), InstallCommandInput{
|
|
Args: []string{scriptPath, "hello world"},
|
|
Env: os.Environ(),
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if result.ExitCode != 0 {
|
|
t.Fatalf("exit code = %d, stderr = %q", result.ExitCode, result.Stderr)
|
|
}
|
|
if !strings.Contains(result.Stdout, "marker=\"hello world\"") {
|
|
t.Fatalf("stdout = %q, want command argument to survive cmd.exe", result.Stdout)
|
|
}
|
|
}
|