aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/addr2line
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2020-06-05 16:08:08 -0400
committerBryan C. Mills <bcmills@google.com>2020-06-09 02:49:06 +0000
commitcacac8bdc5c93e7bc71df71981fdf32dded017bf (patch)
treea446c52808abf100906c992122656a45b8e51c69 /src/cmd/addr2line
parente64675a79fef5924f268425de021372df874010e (diff)
downloadgo-cacac8bdc5c93e7bc71df71981fdf32dded017bf.tar.gz
go-cacac8bdc5c93e7bc71df71981fdf32dded017bf.zip
cmd/dist: do not unset GOROOT_FINAL prior to running tests
Also do not unset it by default in the tests for cmd/go. GOROOT_FINAL affects the GOROOT value embedded in binaries, such as 'cmd/cgo'. If its value changes and a build command is performed that depends on one of those binaries, the binary would be spuriously rebuilt. Instead, only unset it in the specific tests that make assumptions about the GOROOT paths embedded in specific compiled binaries. That may cause those tests to do a little extra rebuilding when GOROOT_FINAL is set, but that little bit of extra rebuilding seems preferable to spuriously-stale binaries. Fixes #39385 Change-Id: I7c87b1519bb5bcff64babf1505fd1033ffa4f4fb Reviewed-on: https://go-review.googlesource.com/c/go/+/236819 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'src/cmd/addr2line')
-rw-r--r--src/cmd/addr2line/addr2line_test.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/cmd/addr2line/addr2line_test.go b/src/cmd/addr2line/addr2line_test.go
index 22bf1379bb..e12f0ae814 100644
--- a/src/cmd/addr2line/addr2line_test.go
+++ b/src/cmd/addr2line/addr2line_test.go
@@ -74,18 +74,26 @@ func testAddr2Line(t *testing.T, exepath, addr string) {
t.Fatalf("Stat failed: %v", err)
}
fi2, err := os.Stat(srcPath)
+ if gorootFinal := os.Getenv("GOROOT_FINAL"); gorootFinal != "" && strings.HasPrefix(srcPath, gorootFinal) {
+ if os.IsNotExist(err) || (err == nil && !os.SameFile(fi1, fi2)) {
+ // srcPath has had GOROOT_FINAL substituted for GOROOT, and it doesn't
+ // match the actual file. GOROOT probably hasn't been moved to its final
+ // location yet, so try the original location instead.
+ fi2, err = os.Stat(runtime.GOROOT() + strings.TrimPrefix(srcPath, gorootFinal))
+ }
+ }
if err != nil {
t.Fatalf("Stat failed: %v", err)
}
if !os.SameFile(fi1, fi2) {
t.Fatalf("addr2line_test.go and %s are not same file", srcPath)
}
- if srcLineNo != "89" {
- t.Fatalf("line number = %v; want 89", srcLineNo)
+ if srcLineNo != "97" {
+ t.Fatalf("line number = %v; want 97", srcLineNo)
}
}
-// This is line 88. The test depends on that.
+// This is line 96. The test depends on that.
func TestAddr2Line(t *testing.T) {
testenv.MustHaveGoBuild(t)