mirror of
https://github.com/golang/go
synced 2024-11-06 08:36:14 -07:00
b90c6b99b3
This test is slow and resource-intensive, and will rarely catch failures. It is important to run sometimes, but probably a waste of time on smaller (and especially reverse) builders. Rather than hard-coding a list of small builders, only run it on the longtest builders. Fixes #35233 Fixes #30892 Fixes #49753 Change-Id: I25a9702e1f541246ea200fd7c79414ca5f69edae Reviewed-on: https://go-review.googlesource.com/c/go/+/366538 Trust: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
56 lines
1.3 KiB
Go
56 lines
1.3 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) {
|
|
if testing.Short() {
|
|
t.Skipf("skipping test that rebuilds the entire toolchain")
|
|
}
|
|
|
|
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)
|
|
}
|
|
}
|