Use external Go in recovery commands

This commit is contained in:
2026-11-04 01:23:24 +00:00
parent 7dcc9a37c7
commit a3c74188be
3 changed files with 6 additions and 3 deletions

View File

@@ -143,7 +143,7 @@ func selectedPublicationRecoveryCommand(ctx context.Context, result releasekit.P
return "", err
}
if args != nil {
prefix := "go -C " + shellQuote(git.DisplayDiagnostic(args.Directory))
prefix := "env go -C " + shellQuote(git.DisplayDiagnostic(args.Directory))
command := "(export GOWORK=off GOTOOLCHAIN=local && releasekit_host_os=$(" + prefix + " env GOHOSTOS) && releasekit_host_arch=$(" + prefix + " env GOHOSTARCH) && GOOS=\"$releasekit_host_os\" GOARCH=\"$releasekit_host_arch\" " + prefix
for _, arg := range args.Args {
command += " " + shellQuote(git.DisplayDiagnostic(arg))

View File

@@ -280,9 +280,10 @@ func TestColdGoToolRecoverySurvivesLauncherExit(t *testing.T) {
if scenario.record != "" {
selected = strings.Replace(selected, shellQuote(originalRecord), shellQuote(scenario.record), 1)
}
recovery := exec.Command("sh", "-c", selected)
recovery.Dir = t.TempDir()
foreignOS, foreignArch := foreignTarget()
goFunction := "go() { GOOS=" + shellQuote(foreignOS) + " GOARCH=" + shellQuote(foreignArch) + " command go \"$@\"; }\n"
recovery := exec.Command("sh", "-c", goFunction+selected)
recovery.Dir = t.TempDir()
recovery.Env = setEnvironment(setEnvironment(os.Environ(), "GOOS", foreignOS), "GOARCH", foreignArch)
recovered, err := recovery.CombinedOutput()
if scenario.status == 0 && err != nil || scenario.status != 0 && (!errors.As(err, &exitError) || exitError.ExitCode() != scenario.status) {