aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorDavid Chase <drchase@google.com>2022-03-07 18:27:14 -0500
committerDavid Chase <drchase@google.com>2022-03-07 18:27:14 -0500
commitf49279383901af656e40f225eb67ff62f507e13d (patch)
tree456dc18ec82112c48d73ef2a3f369e15dc84ed05 /misc
parent768804dfdd81b04a1184c86e538634872b907149 (diff)
parentc9b60632ebb08a428a9bd15a89798a693667cb05 (diff)
downloadgo-f49279383901af656e40f225eb67ff62f507e13d.tar.gz
go-f49279383901af656e40f225eb67ff62f507e13d.zip
[dev.boringcrypto] all: merge master into dev.boringcrypto
Change-Id: I4e09d4f2cc77c4c2dc12f1ff40d8c36053ab7ab6
Diffstat (limited to 'misc')
-rw-r--r--misc/cgo/testsanitizers/asan_test.go2
-rw-r--r--misc/reboot/overlaydir_test.go15
-rw-r--r--misc/reboot/reboot_test.go9
3 files changed, 16 insertions, 10 deletions
diff --git a/misc/cgo/testsanitizers/asan_test.go b/misc/cgo/testsanitizers/asan_test.go
index 1b70bce3d11..22dcf23c3ba 100644
--- a/misc/cgo/testsanitizers/asan_test.go
+++ b/misc/cgo/testsanitizers/asan_test.go
@@ -63,7 +63,7 @@ func TestASAN(t *testing.T) {
// sanitizer library needs a
// symbolizer program and can't find it.
const noSymbolizer = "external symbolizer"
- // Check if -asan option can correctly print where the error occured.
+ // Check if -asan option can correctly print where the error occurred.
if tc.errorLocation != "" &&
!strings.Contains(out, tc.errorLocation) &&
!strings.Contains(out, noSymbolizer) &&
diff --git a/misc/reboot/overlaydir_test.go b/misc/reboot/overlaydir_test.go
index c446d0891cf..71faf0936ba 100644
--- a/misc/reboot/overlaydir_test.go
+++ b/misc/reboot/overlaydir_test.go
@@ -6,6 +6,7 @@ package reboot_test
import (
"io"
+ "io/fs"
"os"
"path/filepath"
"strings"
@@ -26,10 +27,14 @@ func overlayDir(dstRoot, srcRoot string) error {
return err
}
- return filepath.Walk(srcRoot, func(srcPath string, info os.FileInfo, err error) error {
+ return filepath.WalkDir(srcRoot, func(srcPath string, entry fs.DirEntry, err error) error {
if err != nil || srcPath == srcRoot {
return err
}
+ if filepath.Base(srcPath) == "testdata" {
+ // We're just building, so no need to copy those.
+ return fs.SkipDir
+ }
suffix := strings.TrimPrefix(srcPath, srcRoot)
for len(suffix) > 0 && suffix[0] == filepath.Separator {
@@ -37,6 +42,7 @@ func overlayDir(dstRoot, srcRoot string) error {
}
dstPath := filepath.Join(dstRoot, suffix)
+ info, err := entry.Info()
perm := info.Mode() & os.ModePerm
if info.Mode()&os.ModeSymlink != 0 {
info, err = os.Stat(srcPath)
@@ -46,14 +52,15 @@ func overlayDir(dstRoot, srcRoot string) error {
perm = info.Mode() & os.ModePerm
}
- // Always copy directories (don't symlink them).
+ // Always make copies of directories.
// If we add a file in the overlay, we don't want to add it in the original.
if info.IsDir() {
return os.MkdirAll(dstPath, perm|0200)
}
- // If the OS supports symlinks, use them instead of copying bytes.
- if err := os.Symlink(srcPath, dstPath); err == nil {
+ // If we can use a hard link, do that instead of copying bytes.
+ // Go builds don't like symlinks in some cases, such as go:embed.
+ if err := os.Link(srcPath, dstPath); err == nil {
return nil
}
diff --git a/misc/reboot/reboot_test.go b/misc/reboot/reboot_test.go
index ef164d32327..a134affbc24 100644
--- a/misc/reboot/reboot_test.go
+++ b/misc/reboot/reboot_test.go
@@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"testing"
+ "time"
)
func TestRepeatBootstrap(t *testing.T) {
@@ -19,16 +20,14 @@ func TestRepeatBootstrap(t *testing.T) {
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)
+ 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)