Skip to content
go-libfossil Artifact [84a31d9afb]
Login

Artifact [84a31d9afb]

Artifact 84a31d9afb90f92219ca5ffb6d0eec48f3fd68ef37797c38eab22a5dbe0dc9d2:


//go:build !unix

package testutil

import (
	"os"
	"os/exec"
	"testing"
)

// StartServer is the non-unix fallback: no process groups, so only the parent
// is killed and reaped. The #352 race therefore remains on these platforms.
func StartServer(t *testing.T, bin string, args ...string) *exec.Cmd {
	t.Helper()
	if bin == "" {
		panic("testutil.StartServer: empty bin")
	}
	cmd := exec.Command(bin, args...)
	cmd.Stdout = os.Stderr
	cmd.Stderr = os.Stderr
	if err := cmd.Start(); err != nil {
		t.Fatalf("start %s %v: %v", bin, args, err)
	}
	t.Cleanup(func() {
		_ = cmd.Process.Kill()
		_ = cmd.Wait()
	})
	return cmd
}