mirror of
https://github.com/golang/go
synced 2024-11-24 18:30:16 -07:00
a040ebeb98
Update references missed in CL 263142.
For #41190
Change-Id: I778760a6a69bd0440fec0848bdef539c9ccb4ee1
GitHub-Last-Rev: dda42b09ff
GitHub-Pull-Request: golang/go#42874
Reviewed-on: https://go-review.googlesource.com/c/go/+/273946
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Zhang <cherryyz@google.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
// Copyright 2019 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Package reboot_test verifies that the current GOROOT can be used to bootstrap
|
|
// itself.
|
|
package reboot_test
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
"runtime"
|
|
"testing"
|
|
)
|
|
|
|
func TestRepeatBootstrap(t *testing.T) {
|
|
goroot, err := os.MkdirTemp("", "reboot-goroot")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer os.RemoveAll(goroot)
|
|
|
|
gorootSrc := filepath.Join(goroot, "src")
|
|
if err := overlayDir(gorootSrc, filepath.Join(runtime.GOROOT(), "src")); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
if err := os.WriteFile(filepath.Join(goroot, "VERSION"), []byte(runtime.Version()), 0666); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
var makeScript string
|
|
switch runtime.GOOS {
|
|
case "windows":
|
|
makeScript = "make.bat"
|
|
case "plan9":
|
|
makeScript = "make.rc"
|
|
default:
|
|
makeScript = "make.bash"
|
|
}
|
|
|
|
cmd := exec.Command(filepath.Join(runtime.GOROOT(), "src", makeScript))
|
|
cmd.Dir = gorootSrc
|
|
cmd.Env = append(os.Environ(), "GOROOT=", "GOROOT_BOOTSTRAP="+runtime.GOROOT())
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Stdout = os.Stdout
|
|
if err := cmd.Run(); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
}
|