if runtime.GOOS == "windows" {
exeSuffix = ".exe"
}
- path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
- if _, err := os.Stat(path); err == nil {
- return path
+ if goroot := build.Default.GOROOT; goroot != "" {
+ path := filepath.Join(goroot, "bin", "go"+exeSuffix)
+ if _, err := os.Stat(path); err == nil {
+ return path
+ }
}
return "go"
}
func main() {
flag.Parse()
+ if build.Default.GOROOT == "" {
+ log.Fatalf("GOROOT not found. (If binary was built with -trimpath, $GOROOT must be set.)")
+ }
+
if !strings.Contains(runtime.Version(), "weekly") && !strings.Contains(runtime.Version(), "devel") {
if *nextFiles != "" {
fmt.Printf("Go version is %q, ignoring -next %s\n", runtime.Version(), *nextFiles)
"flag"
"fmt"
"go/build"
+ "internal/testenv"
"os"
"path/filepath"
"sort"
for _, c := range contexts {
c.Compiler = build.Default.Compiler
}
+ build.Default.GOROOT = testenv.GOROOT(nil)
// Warm up the import cache in parallel.
var wg sync.WaitGroup
"bytes"
"cmd/compile/internal/types2"
"fmt"
+ "go/build"
"internal/goexperiment"
"internal/testenv"
"os"
"time"
)
+func TestMain(m *testing.M) {
+ build.Default.GOROOT = testenv.GOROOT(nil)
+ os.Exit(m.Run())
+}
+
// skipSpecialPlatforms causes the test to be skipped for platforms where
// builders (build.golang.org) don't have access to compiled packages for
// import.
const maxTime = 30 * time.Second
func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) {
- dirname := filepath.Join(runtime.GOROOT(), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir)
+ dirname := filepath.Join(testenv.GOROOT(t), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir)
list, err := os.ReadDir(dirname)
if err != nil {
t.Fatalf("testDir(%s): %s", dirname, err)
"bytes"
"flag"
"fmt"
+ "internal/testenv"
"io/ioutil"
"path/filepath"
"regexp"
lines uint
}
+ goroot := testenv.GOROOT(t)
+
results := make(chan parseResult)
go func() {
defer close(results)
for _, dir := range []string{
- filepath.Join(runtime.GOROOT(), "src"),
- filepath.Join(runtime.GOROOT(), "misc"),
+ filepath.Join(goroot, "src"),
+ filepath.Join(goroot, "misc"),
} {
walkDirs(t, dir, func(filename string) {
if skipRx != nil && skipRx.MatchString(filename) {
--- /dev/null
+// Copyright 2022 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 types2_test
+
+import (
+ "go/build"
+ "internal/testenv"
+ "os"
+ "testing"
+)
+
+func TestMain(m *testing.M) {
+ build.Default.GOROOT = testenv.GOROOT(nil)
+ os.Exit(m.Run())
+}
"internal/testenv"
"os"
"path/filepath"
- "runtime"
"strings"
"testing"
"time"
testenv.MustHaveGoBuild(t)
pkgCount := 0
- duration := walkPkgDirs(filepath.Join(runtime.GOROOT(), "src"), func(dir string, filenames []string) {
+ duration := walkPkgDirs(filepath.Join(testenv.GOROOT(t), "src"), func(dir string, filenames []string) {
typecheck(t, dir, filenames)
pkgCount++
}, t.Error)
t.Skip("skipping in short mode")
}
- testTestDir(t, filepath.Join(runtime.GOROOT(), "test"),
+ testTestDir(t, filepath.Join(testenv.GOROOT(t), "test"),
"cmplxdivide.go", // also needs file cmplxdivide1.go - ignore
"directive.go", // tests compiler rejection of bad directive placement - ignore
"directive2.go", // tests compiler rejection of bad directive placement - ignore
t.Skip("skipping in short mode")
}
- testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"),
+ testTestDir(t, filepath.Join(testenv.GOROOT(t), "test", "fixedbugs"),
"bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore
"issue6889.go", // gc-specific test
"issue11362.go", // canonical import path check
func TestStdKen(t *testing.T) {
testenv.MustHaveGoBuild(t)
- testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken"))
+ testTestDir(t, filepath.Join(testenv.GOROOT(t), "test", "ken"))
}
// Package paths of excluded packages.
}
// apply pkgh to the files in directory dir
- // but ignore files directly under $GOROOT/src (might be temporary test files).
- if dir != filepath.Join(runtime.GOROOT(), "src") {
- files, err := pkgFilenames(dir)
- if err != nil {
- w.errh(err)
- return
- }
- if files != nil {
- w.pkgh(dir, files)
- }
+ pkgFiles, err := pkgFilenames(dir)
+ if err != nil {
+ w.errh(err)
+ return
+ }
+ if pkgFiles != nil {
+ w.pkgh(dir, pkgFiles)
}
// traverse subdirectories, but don't walk into testdata
import (
"bytes"
"flag"
+ "go/build"
+ "internal/testenv"
"log"
"os"
"path/filepath"
buildCtx.GOPATH = ""
testGOPATH = true // force GOPATH mode; module test is in cmd/go/testdata/script/mod_doc.txt
+ // Set GOROOT in case runtime.GOROOT is wrong (for example, if the test was
+ // built with -trimpath). dirsInit would identify it using 'go env GOROOT',
+ // but we can't be sure that the 'go' in $PATH is the right one either.
+ buildCtx.GOROOT = testenv.GOROOT(nil)
+ build.Default.GOROOT = testenv.GOROOT(nil)
+
// Add $GOROOT/src/cmd/doc/testdata explicitly so we can access its contents in the test.
// Normally testdata directories are ignored, but sending it to dirs.scan directly is
// a hack that works around the check.
"os"
"path"
"path/filepath"
- "runtime"
"strings"
"testing"
)
func TestScan(t *testing.T) {
testenv.MustHaveGoBuild(t)
- imports, testImports, err := ScanDir(filepath.Join(runtime.GOROOT(), "src/encoding/json"), Tags())
+ imports, testImports, err := ScanDir(filepath.Join(testenv.GOROOT(t), "src/encoding/json"), Tags())
if err != nil {
t.Fatal(err)
}
"go/ast"
"go/printer"
"go/token"
+ "internal/testenv"
"io"
"io/fs"
"os"
}
// otherwise, test all Go files under *root
- filepath.WalkDir(*root, handleFile)
+ goroot := *root
+ if goroot == "" {
+ goroot = testenv.GOROOT(t)
+ }
+ filepath.WalkDir(goroot, handleFile)
}
func TestAll(t *testing.T) {
"os"
"os/exec"
"path/filepath"
- "runtime"
"strings"
"sync"
"testing"
// module version specified in GOROOT/src/cmd/go.mod.
bundleDir := t.TempDir()
r := runner{
- Dir: filepath.Join(runtime.GOROOT(), "src/cmd"),
+ Dir: filepath.Join(testenv.GOROOT(t), "src/cmd"),
Env: append(os.Environ(), modcacheEnv...),
}
r.run(t, goBin, "build", "-mod=readonly", "-o", bundleDir, "golang.org/x/tools/cmd/bundle")
}
}()
- rel, err := filepath.Rel(runtime.GOROOT(), m.Dir)
+ rel, err := filepath.Rel(testenv.GOROOT(t), m.Dir)
if err != nil {
- t.Fatalf("filepath.Rel(%q, %q): %v", runtime.GOROOT(), m.Dir, err)
+ t.Fatalf("filepath.Rel(%q, %q): %v", testenv.GOROOT(t), m.Dir, err)
}
r := runner{
Dir: filepath.Join(gorootCopyDir, rel),
func makeGOROOTCopy(t *testing.T) string {
t.Helper()
gorootCopyDir := t.TempDir()
- err := filepath.Walk(runtime.GOROOT(), func(src string, info os.FileInfo, err error) error {
+ err := filepath.Walk(testenv.GOROOT(t), func(src string, info os.FileInfo, err error) error {
if err != nil {
return err
}
- if info.IsDir() && src == filepath.Join(runtime.GOROOT(), ".git") {
+ if info.IsDir() && src == filepath.Join(testenv.GOROOT(t), ".git") {
return filepath.SkipDir
}
- rel, err := filepath.Rel(runtime.GOROOT(), src)
+ rel, err := filepath.Rel(testenv.GOROOT(t), src)
if err != nil {
- return fmt.Errorf("filepath.Rel(%q, %q): %v", runtime.GOROOT(), src, err)
+ return fmt.Errorf("filepath.Rel(%q, %q): %v", testenv.GOROOT(t), src, err)
}
dst := filepath.Join(gorootCopyDir, rel)
- if info.IsDir() && (src == filepath.Join(runtime.GOROOT(), "bin") ||
- src == filepath.Join(runtime.GOROOT(), "pkg")) {
+ if info.IsDir() && (src == filepath.Join(testenv.GOROOT(t), "bin") ||
+ src == filepath.Join(testenv.GOROOT(t), "pkg")) {
// If the OS supports symlinks, use them instead
// of copying the bin and pkg directories.
if err := os.Symlink(src, dst); err == nil {
goBin := testenv.GoToolPath(t)
goroot.once.Do(func() {
- goroot.err = filepath.WalkDir(runtime.GOROOT(), func(path string, info fs.DirEntry, err error) error {
+ goroot.err = filepath.WalkDir(testenv.GOROOT(t), func(path string, info fs.DirEntry, err error) error {
if err != nil {
return err
}
if info.IsDir() && (info.Name() == "vendor" || info.Name() == "testdata") {
return filepath.SkipDir
}
- if info.IsDir() && path == filepath.Join(runtime.GOROOT(), "pkg") {
+ if info.IsDir() && path == filepath.Join(testenv.GOROOT(t), "pkg") {
// GOROOT/pkg contains generated artifacts, not source code.
//
// In https://golang.org/issue/37929 it was observed to somehow contain
"internal/testenv"
"os/exec"
"path/filepath"
- "runtime"
"testing"
)
testenv.MustHaveCGO(t)
dir := t.TempDir()
cmd := exec.Command(testenv.GoToolPath(t), "build", "-gcflags=-N -l", "-o", filepath.Join(dir, "a.out"))
- cmd.Dir = filepath.Join(runtime.GOROOT(), "src", "runtime", "testdata", "testprogcgo")
+ cmd.Dir = filepath.Join(testenv.GOROOT(t), "src", "runtime", "testdata", "testprogcgo")
out, err := cmd.CombinedOutput()
if err != nil {
t.Logf("go build output: %s", out)
"internal/xcoff/testdata/gcc-ppc64-aix-dwarf2-exec",
}
for _, f := range testfiles {
- exepath := filepath.Join(runtime.GOROOT(), "src", f)
+ exepath := filepath.Join(testenv.GOROOT(t), "src", f)
if strings.HasSuffix(f, ".base64") {
tf, err := obscuretestdata.DecodeToTempFile(exepath)
if err != nil {
package importer
import (
+ "go/build"
"go/token"
"internal/testenv"
"io"
"os"
"os/exec"
- "runtime"
"strings"
"testing"
)
+func TestMain(m *testing.M) {
+ build.Default.GOROOT = testenv.GOROOT(nil)
+ os.Exit(m.Run())
+}
+
func TestForCompiler(t *testing.T) {
testenv.MustHaveGoBuild(t)
// https://github.com/golang/go#28995
mathBigInt := pkg.Scope().Lookup("Int")
posn := fset.Position(mathBigInt.Pos()) // "$GOROOT/src/math/big/int.go:25:1"
- filename := strings.Replace(posn.Filename, "$GOROOT", runtime.GOROOT(), 1)
+ filename := strings.Replace(posn.Filename, "$GOROOT", testenv.GOROOT(t), 1)
data, err := os.ReadFile(filename)
if err != nil {
t.Fatalf("can't read file containing declaration of math/big.Int: %v", err)
"time"
"go/ast"
+ "go/build"
"go/importer"
"go/parser"
"go/token"
. "go/internal/gcimporter"
)
+func TestMain(m *testing.M) {
+ build.Default.GOROOT = testenv.GOROOT(nil)
+ os.Exit(m.Run())
+}
+
// skipSpecialPlatforms causes the test to be skipped for platforms where
// builders (build.golang.org) don't have access to compiled packages for
// import.
var pkgExts = [...]string{".a", ".o"} // keep in sync with gcimporter.go
func testDir(t *testing.T, dir string, endTime time.Time) (nimports int) {
- dirname := filepath.Join(runtime.GOROOT(), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir)
+ dirname := filepath.Join(testenv.GOROOT(t), "pkg", runtime.GOOS+"_"+runtime.GOARCH, dir)
list, err := os.ReadDir(dirname)
if err != nil {
t.Fatalf("testDir(%s): %s", dirname, err)
// Check go files in test/typeparam, except those that fail for a known
// reason.
- rootDir := filepath.Join(runtime.GOROOT(), "test", "typeparam")
+ rootDir := filepath.Join(testenv.GOROOT(t), "test", "typeparam")
list, err := os.ReadDir(rootDir)
if err != nil {
t.Fatal(err)
"os"
"path"
"path/filepath"
- "runtime"
"strings"
"testing"
"time"
func TestMain(m *testing.M) {
flag.Parse()
- if goTool, err := testenv.GoTool(); err == nil {
- os.Setenv("PATH", filepath.Dir(goTool)+string(os.PathListSeparator)+os.Getenv("PATH"))
- }
+ build.Default.GOROOT = testenv.GOROOT(nil)
os.Exit(m.Run())
}
return 0, false
}
- list, err := os.ReadDir(filepath.Join(runtime.GOROOT(), "src", path))
+ list, err := os.ReadDir(filepath.Join(testenv.GOROOT(t), "src", path))
if err != nil {
t.Fatalf("walkDir %s failed (%v)", path, err)
}
testenv.MustHaveCGO(t)
importer := New(&build.Default, token.NewFileSet(), make(map[string]*types.Package))
- _, err := importer.ImportFrom("./misc/cgo/test", runtime.GOROOT(), 0)
+ _, err := importer.ImportFrom("./misc/cgo/test", testenv.GOROOT(t), 0)
if err != nil {
t.Fatalf("Import failed: %v", err)
}
--- /dev/null
+// Copyright 2022 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 types_test
+
+import (
+ "go/build"
+ "internal/testenv"
+ "os"
+ "testing"
+)
+
+func TestMain(m *testing.M) {
+ build.Default.GOROOT = testenv.GOROOT(nil)
+ os.Exit(m.Run())
+}
"internal/testenv"
"os"
"path/filepath"
- "runtime"
"strings"
"testing"
"time"
testenv.MustHaveGoBuild(t)
pkgCount := 0
- duration := walkPkgDirs(filepath.Join(runtime.GOROOT(), "src"), func(dir string, filenames []string) {
+ duration := walkPkgDirs(filepath.Join(testenv.GOROOT(t), "src"), func(dir string, filenames []string) {
typecheck(t, dir, filenames)
pkgCount++
}, t.Error)
t.Skip("skipping in short mode")
}
- testTestDir(t, filepath.Join(runtime.GOROOT(), "test"),
+ testTestDir(t, filepath.Join(testenv.GOROOT(t), "test"),
"cmplxdivide.go", // also needs file cmplxdivide1.go - ignore
"directive.go", // tests compiler rejection of bad directive placement - ignore
"directive2.go", // tests compiler rejection of bad directive placement - ignore
t.Skip("skipping in short mode")
}
- testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "fixedbugs"),
+ testTestDir(t, filepath.Join(testenv.GOROOT(t), "test", "fixedbugs"),
"bug248.go", "bug302.go", "bug369.go", // complex test instructions - ignore
"issue6889.go", // gc-specific test
"issue11362.go", // canonical import path check
func TestStdKen(t *testing.T) {
testenv.MustHaveGoBuild(t)
- testTestDir(t, filepath.Join(runtime.GOROOT(), "test", "ken"))
+ testTestDir(t, filepath.Join(testenv.GOROOT(t), "test", "ken"))
}
// Package paths of excluded packages.
// typecheck package files
conf := Config{
- Error: func(err error) { t.Error(err) },
+ Error: func(err error) {
+ t.Helper()
+ t.Error(err)
+ },
Importer: stdLibImporter,
}
info := Info{Uses: make(map[*ast.Ident]Object)}
}
// apply pkgh to the files in directory dir
- // but ignore files directly under $GOROOT/src (might be temporary test files).
- if dir != filepath.Join(runtime.GOROOT(), "src") {
- files, err := pkgFilenames(dir)
- if err != nil {
- w.errh(err)
- return
- }
- if files != nil {
- w.pkgh(dir, files)
- }
+ pkgFiles, err := pkgFilenames(dir)
+ if err != nil {
+ w.errh(err)
+ return
+ }
+ if pkgFiles != nil {
+ w.pkgh(dir, pkgFiles)
}
// traverse subdirectories, but don't walk into testdata
"bytes"
"errors"
"flag"
+ "fmt"
"internal/cfg"
"os"
"os/exec"
return path
}
+var (
+ gorootOnce sync.Once
+ gorootPath string
+ gorootErr error
+)
+
+func findGOROOT() (string, error) {
+ gorootOnce.Do(func() {
+ gorootPath = runtime.GOROOT()
+ if gorootPath != "" {
+ // If runtime.GOROOT() is non-empty, assume that it is valid.
+ //
+ // (It might not be: for example, the user may have explicitly set GOROOT
+ // to the wrong directory, or explicitly set GOROOT_FINAL but not GOROOT
+ // and hasn't moved the tree to GOROOT_FINAL yet. But those cases are
+ // rare, and if that happens the user can fix what they broke.)
+ return
+ }
+
+ // runtime.GOROOT doesn't know where GOROOT is (perhaps because the test
+ // binary was built with -trimpath, or perhaps because GOROOT_FINAL was set
+ // without GOROOT and the tree hasn't been moved there yet).
+ //
+ // Since this is internal/testenv, we can cheat and assume that the caller
+ // is a test of some package in a subdirectory of GOROOT/src. ('go test'
+ // runs the test in the directory containing the packaged under test.) That
+ // means that if we start walking up the tree, we should eventually find
+ // GOROOT/src/go.mod, and we can report the parent directory of that.
+
+ cwd, err := os.Getwd()
+ if err != nil {
+ gorootErr = fmt.Errorf("finding GOROOT: %w", err)
+ return
+ }
+
+ dir := cwd
+ for {
+ parent := filepath.Dir(dir)
+ if parent == dir {
+ // dir is either "." or only a volume name.
+ gorootErr = fmt.Errorf("failed to locate GOROOT/src in any parent directory")
+ return
+ }
+
+ if base := filepath.Base(dir); base != "src" {
+ dir = parent
+ continue // dir cannot be GOROOT/src if it doesn't end in "src".
+ }
+
+ b, err := os.ReadFile(filepath.Join(dir, "go.mod"))
+ if err != nil {
+ if os.IsNotExist(err) {
+ dir = parent
+ continue
+ }
+ gorootErr = fmt.Errorf("finding GOROOT: %w", err)
+ return
+ }
+ goMod := string(b)
+
+ for goMod != "" {
+ var line string
+ line, goMod, _ = strings.Cut(goMod, "\n")
+ fields := strings.Fields(line)
+ if len(fields) >= 2 && fields[0] == "module" && fields[1] == "std" {
+ // Found "module std", which is the module declaration in GOROOT/src!
+ gorootPath = parent
+ return
+ }
+ }
+ }
+ })
+
+ return gorootPath, gorootErr
+}
+
+// GOROOT reports the path to the directory containing the root of the Go
+// project source tree. This is normally equivalent to runtime.GOROOT, but
+// works even if the test binary was built with -trimpath.
+//
+// If GOROOT cannot be found, GOROOT skips t if t is non-nil,
+// or panics otherwise.
+func GOROOT(t testing.TB) string {
+ path, err := findGOROOT()
+ if err != nil {
+ if t == nil {
+ panic(err)
+ }
+ t.Helper()
+ t.Skip(err)
+ }
+ return path
+}
+
// GoTool reports the path to the Go tool.
func GoTool() (string, error) {
if !HasGoBuild() {
if runtime.GOOS == "windows" {
exeSuffix = ".exe"
}
- path := filepath.Join(runtime.GOROOT(), "bin", "go"+exeSuffix)
+ goroot, err := findGOROOT()
+ if err != nil {
+ return "", fmt.Errorf("cannot find go tool: %w", err)
+ }
+ path := filepath.Join(goroot, "bin", "go"+exeSuffix)
if _, err := os.Stat(path); err == nil {
return path, nil
}
import (
"internal/testenv"
"os/exec"
- "path/filepath"
"regexp"
"runtime"
"strings"
func TestInlining(t *testing.T) {
testenv.MustHaveGoBuild(t)
t.Parallel()
- var exe string
- if runtime.GOOS == "windows" {
- exe = ".exe"
- }
out, err := exec.Command(
- filepath.Join(runtime.GOROOT(), "bin", "go"+exe),
+ testenv.GoToolPath(t),
"build",
"--gcflags=-m",
"net/netip").CombinedOutput()
if runtime.GOOS == "ios" {
t.Skipf("skipping on %s/%s", runtime.GOOS, runtime.GOARCH)
}
- root, err := filepath.EvalSymlinks(runtime.GOROOT() + "/test")
+ root, err := filepath.EvalSymlinks(testenv.GOROOT(t) + "/test")
if err != nil {
t.Fatal(err)
}
case "plan9":
t.Skip("there is no gdb on Plan 9")
}
- if final := os.Getenv("GOROOT_FINAL"); final != "" && runtime.GOROOT() != final {
+ if final := os.Getenv("GOROOT_FINAL"); final != "" && testenv.GOROOT(t) != final {
t.Skip("gdb test can fail with GOROOT_FINAL pending")
}
}
}
args := []string{"-nx", "-q", "--batch",
- "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"),
+ "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"),
"-ex", "set startup-with-shell off",
"-ex", "set print thread-events off",
}
// Until gold and gdb can work together, temporarily load the
// python script directly.
args = append(args,
- "-ex", "source "+filepath.Join(runtime.GOROOT(), "src", "runtime", "runtime-gdb.py"),
+ "-ex", "source "+filepath.Join(testenv.GOROOT(t), "src", "runtime", "runtime-gdb.py"),
)
} else {
args = append(args,
cmd.Env = []string{}
out, err := cmd.CombinedOutput()
if err != nil && bytes.Contains(out, []byte("cannot find GOROOT")) {
- t.Skipf("skipping because GOROOT=%s does not exist", runtime.GOROOT())
+ t.Skipf("skipping because GOROOT=%s does not exist", testenv.GOROOT(t))
}
_, file, _, _ := runtime.Caller(1)
// Execute gdb commands.
args := []string{"-nx", "-batch",
- "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"),
+ "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"),
"-ex", "set startup-with-shell off",
"-ex", "break main.eee",
"-ex", "run",
// Execute gdb commands.
args := []string{"-nx", "-batch",
- "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"),
+ "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"),
"-ex", "set startup-with-shell off",
"-ex", "break main.main",
"-ex", "run",
// Execute gdb commands.
args := []string{"-nx", "-batch",
- "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"),
+ "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"),
"-ex", "set startup-with-shell off",
"-ex", "break main.main",
"-ex", "run",
// Execute gdb commands.
args := []string{"-nx", "-batch",
- "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"),
+ "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"),
"-ex", "set startup-with-shell off",
"-ex", "run",
"-ex", "backtrace",
// Execute gdb commands.
// 'setg_gcc' is the first point where we can reproduce the issue with just one 'run' command.
args := []string{"-nx", "-batch",
- "-iex", "add-auto-load-safe-path " + filepath.Join(runtime.GOROOT(), "src", "runtime"),
+ "-iex", "add-auto-load-safe-path " + filepath.Join(testenv.GOROOT(t), "src", "runtime"),
"-ex", "set startup-with-shell off",
"-ex", "break setg_gcc",
"-ex", "run",
import (
"errors"
"fmt"
+ "internal/testenv"
"os"
"reflect"
"testing"
t.Fatal(err)
}
- gorootSource, ok := time.GorootZoneSource("../..")
+ gorootSource, ok := time.GorootZoneSource(testenv.GOROOT(t))
if !ok {
t.Fatal("Failed to locate tzinfo source in GOROOT.")
}