(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestSpawnDetachedDaemonProcess(t *testing.T) { |
| 15 | t.Parallel() |
| 16 | |
| 17 | homePaths, err := aghconfig.ResolveHomePathsFrom(t.TempDir()) |
| 18 | if err != nil { |
| 19 | t.Fatalf("ResolveHomePathsFrom() error = %v", err) |
| 20 | } |
| 21 | |
| 22 | scriptPath := filepath.Join(t.TempDir(), "agh-test-daemon.sh") |
| 23 | if err := os.WriteFile(scriptPath, []byte("#!/bin/sh\nexit 0\n"), 0o755); err != nil { |
| 24 | t.Fatalf("os.WriteFile(script) error = %v", err) |
| 25 | } |
| 26 | |
| 27 | process, err := spawnDetachedDaemonProcess(context.Background(), homePaths, func() (string, error) { |
| 28 | return scriptPath, nil |
| 29 | }) |
| 30 | if err != nil { |
| 31 | t.Fatalf("spawnDetachedDaemonProcess() error = %v", err) |
| 32 | } |
| 33 | if process.PID() <= 0 { |
| 34 | t.Fatalf("process.PID() = %d, want positive pid", process.PID()) |
| 35 | } |
| 36 | if err := process.Wait(); err != nil { |
| 37 | t.Fatalf("process.Wait() error = %v", err) |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func TestSpawnDetachedDaemonProcessWaitIncludesStderr(t *testing.T) { |
| 42 | t.Parallel() |
nothing calls this directly
no test coverage detected