mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
internal/testenv: add GOROOT and use it to fix tests broken with -trimpath
This fixes many (but not all) of the tests that currently fail (due to a bogus path reported by runtime.GOROOT) when run with 'go test -trimpath std cmd'. Updates #51461 Change-Id: Ia2cc05705529c4859e7928f32eeceed647f2e986 Reviewed-on: https://go-review.googlesource.com/c/go/+/391806 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
This commit is contained in:
parent
9ac75d3951
commit
58631ba54f
22 changed files with 242 additions and 83 deletions
|
|
@ -49,7 +49,7 @@ func checkGdbEnvironment(t *testing.T) {
|
|||
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")
|
||||
}
|
||||
}
|
||||
|
|
@ -204,7 +204,7 @@ func testGdbPython(t *testing.T, cgo bool) {
|
|||
}
|
||||
|
||||
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",
|
||||
}
|
||||
|
|
@ -215,7 +215,7 @@ func testGdbPython(t *testing.T, cgo bool) {
|
|||
// 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,
|
||||
|
|
@ -276,7 +276,7 @@ func testGdbPython(t *testing.T, cgo bool) {
|
|||
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)
|
||||
|
|
@ -416,7 +416,7 @@ func TestGdbBacktrace(t *testing.T) {
|
|||
|
||||
// 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",
|
||||
|
|
@ -498,7 +498,7 @@ func TestGdbAutotmpTypes(t *testing.T) {
|
|||
|
||||
// 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",
|
||||
|
|
@ -563,7 +563,7 @@ func TestGdbConst(t *testing.T) {
|
|||
|
||||
// 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",
|
||||
|
|
@ -626,7 +626,7 @@ func TestGdbPanic(t *testing.T) {
|
|||
|
||||
// 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",
|
||||
|
|
@ -701,7 +701,7 @@ func TestGdbInfCallstack(t *testing.T) {
|
|||
// 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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue