From cacac8bdc5c93e7bc71df71981fdf32dded017bf Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 5 Jun 2020 16:08:08 -0400 Subject: 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 TryBot-Result: Gobot Gobot Reviewed-by: Dmitri Shuralyov --- src/cmd/objdump/objdump_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/cmd/objdump') diff --git a/src/cmd/objdump/objdump_test.go b/src/cmd/objdump/objdump_test.go index c974d6707b..a9dc7d1a5e 100644 --- a/src/cmd/objdump/objdump_test.go +++ b/src/cmd/objdump/objdump_test.go @@ -138,7 +138,11 @@ func testDisasm(t *testing.T, printCode bool, printGnuAsm bool, flags ...string) args = append(args, flags...) args = append(args, "fmthello.go") cmd := exec.Command(testenv.GoToolPath(t), args...) - cmd.Dir = "testdata" // "Bad line" bug #36683 is sensitive to being run in the source directory + // "Bad line" bug #36683 is sensitive to being run in the source directory. + cmd.Dir = "testdata" + // Ensure that the source file location embedded in the binary matches our + // actual current GOROOT, instead of GOROOT_FINAL if set. + cmd.Env = append(os.Environ(), "GOROOT_FINAL=") t.Logf("Running %v", cmd.Args) out, err := cmd.CombinedOutput() if err != nil { -- cgit v1.3