diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 13:18:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 13:18:25 +0000 |
commit | 109be507377fe7f6e8819ac94041d3fdcdf6fd2f (patch) | |
tree | 2806a689f8fab4a2ec9fc949830ef270a91d667d /misc/reboot/reboot_test.go | |
parent | Initial commit. (diff) | |
download | golang-1.19-109be507377fe7f6e8819ac94041d3fdcdf6fd2f.tar.xz golang-1.19-109be507377fe7f6e8819ac94041d3fdcdf6fd2f.zip |
Adding upstream version 1.19.8.upstream/1.19.8upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'misc/reboot/reboot_test.go')
-rw-r--r-- | misc/reboot/reboot_test.go | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/misc/reboot/reboot_test.go b/misc/reboot/reboot_test.go new file mode 100644 index 0000000..a134aff --- /dev/null +++ b/misc/reboot/reboot_test.go @@ -0,0 +1,54 @@ +// 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" + "time" +) + +func TestRepeatBootstrap(t *testing.T) { + if testing.Short() { + t.Skipf("skipping test that rebuilds the entire toolchain") + } + + goroot := t.TempDir() + + gorootSrc := filepath.Join(goroot, "src") + overlayStart := time.Now() + if err := overlayDir(gorootSrc, filepath.Join(runtime.GOROOT(), "src")); err != nil { + t.Fatal(err) + } + t.Logf("GOROOT/src overlay set up in %s", time.Since(overlayStart)) + + 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) + } +} |