fix(mac): resolve duplicate symbols blocking darwin/linux builds + add Mac tests. Remove duplicate launchProcessGuard from guard_unix.go (kept richer health_unix.go shell-loop version using pgrep -f). Remove duplicate applyDetachedStart from exec_stub.go (kept platform_unix.go impl that clears stdio). Add silent_stub.go for !windows so silentCombinedOutput/silentOutput/silentRun compile on Mac. All 4 targets now build: darwin/arm64, darwin/amd64, linux/amd64, linux/arm64. New tests: workerProcessRunning, applyDetachedStart stdio clearing, PersistenceKeyName, HostOSVersion, LaunchAgent plist content, silent stub exec wrappers.

This commit is contained in:
AetherForge
2026-06-03 00:31:30 -07:00
parent bbc1526c37
commit a17cef4c5d
6 changed files with 268 additions and 12 deletions

View File

@@ -0,0 +1,28 @@
//go:build !windows
package client
import "os/exec"
// On non-Windows there are no console windows to hide; these are
// plain exec wrappers that mirror the silent_windows.go signatures.
func silentCmd(name string, arg ...string) *exec.Cmd {
return exec.Command(name, arg...)
}
func silentCombinedOutput(name string, arg ...string) ([]byte, error) {
return exec.Command(name, arg...).CombinedOutput()
}
func silentOutput(name string, arg ...string) ([]byte, error) {
return exec.Command(name, arg...).Output()
}
func silentRun(name string, arg ...string) error {
return exec.Command(name, arg...).Run()
}
func silentStart(cmd *exec.Cmd) error {
return cmd.Start()
}

View File

@@ -0,0 +1,65 @@
//go:build !windows
package client
import (
"os/exec"
"testing"
)
// These tests validate the Unix silent_stub wrappers produce the same
// behaviour as a plain exec.Command — confirming the stubs are wired correctly
// before we ever run the agent on Mac/Linux.
func TestSilentCombinedOutputEcho(t *testing.T) {
out, err := silentCombinedOutput("echo", "hello")
if err != nil {
t.Fatalf("silentCombinedOutput: %v", err)
}
if string(out) != "hello\n" {
t.Errorf("got %q, want \"hello\\n\"", string(out))
}
}
func TestSilentOutputEcho(t *testing.T) {
out, err := silentOutput("echo", "world")
if err != nil {
t.Fatalf("silentOutput: %v", err)
}
if string(out) != "world\n" {
t.Errorf("got %q, want \"world\\n\"", string(out))
}
}
func TestSilentRunTrue(t *testing.T) {
if err := silentRun("true"); err != nil {
t.Errorf("silentRun(true): %v", err)
}
}
func TestSilentRunFalse(t *testing.T) {
err := silentRun("false")
if err == nil {
t.Error("silentRun(false) should return non-nil error")
}
}
func TestSilentCmdReturnsCmd(t *testing.T) {
cmd := silentCmd("echo", "hi")
if cmd == nil {
t.Fatal("silentCmd returned nil")
}
if cmd.Path == "" {
t.Error("silentCmd returned cmd with empty Path")
}
}
func TestSilentStartAndWait(t *testing.T) {
cmd := exec.Command("true")
if err := silentStart(cmd); err != nil {
t.Fatalf("silentStart: %v", err)
}
if err := cmd.Wait(); err != nil {
t.Errorf("cmd.Wait after silentStart: %v", err)
}
}