package main import ( "os" "os/exec" "strings" "testing" ) // The retired binary must fail and name its replacement, whatever it is asked. func TestRetiredBinaryNamesReplacement(t *testing.T) { if os.Getenv("ACCESS_ENGINE_STUB_CHILD") == "1" { main() return } cmd := exec.Command(os.Args[0], "-test.run=TestRetiredBinaryNamesReplacement", "serve", "--addr", "x") cmd.Env = append(os.Environ(), "ACCESS_ENGINE_STUB_CHILD=1") out, err := cmd.CombinedOutput() exit, ok := err.(*exec.ExitError) if !ok || exit.ExitCode() != 2 { t.Fatalf("want exit 2, got %v", err) } if !strings.Contains(string(out), "renamed to access-engine") { t.Fatalf("missing rename message: %s", out) } }