summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorDmitri Shuralyov <dmitshur@golang.org>2023-04-17 17:37:37 -0400
committerGopher Robot <gobot@golang.org>2023-04-19 14:36:22 +0000
commit9cad0cc6e6b2a84134c46ce7069e62de28459f26 (patch)
tree1f98d2e353e652749636d0bceaf3590c80df8f17 /misc
parent8fa9e3beee8b0e6baa7333740996181268b60a3a (diff)
downloadgo-git-9cad0cc6e6b2a84134c46ce7069e62de28459f26.tar.gz
make.{bash,bat}: check unmodified $PATH for $GOROOT/bin presence
Previously, all.bash and all.bat restored the original $PATH before calling 'dist banner', so that it would do its job of checking whether the user still needs to add $GOROOT/bin to their $PATH. That worked for those scripts, but had no effect on make.bash nor make.bat. Instead of trying to extend that logic to more scripts, change the approach to provide dist an unmodified copy of $PATH via an internal to dist environment variable $DIST_UNMODIFIED_PATH. The make.bash and make.bat scripts happen to use dist env -p to modify $PATH, making it viable to add the internal variable there instead of in each script. It currently works by adding semicolon terminators to dist env output so that make.bash's 'eval $(dist env -p)' works as before but is able to export DIST_UNMODIFIED_PATH for following dist invocations to observe. Nothing needs to be done for Windows since its 'set ENV=val' format already has that effect. Plan 9 doesn't use the -p flag of dist env, and checks that GOROOT/bin is bound before /bin rather than looking at the $PATH env var like other OSes, so it may not have this bug. I don't have easy access to Plan 9 and haven't tried to confirm. Fixes #42563. Change-Id: I74691931167e974a930f7589d22a48bb6b931163 Reviewed-on: https://go-review.googlesource.com/c/go/+/485896 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'misc')
-rw-r--r--misc/reboot/reboot_test.go22
1 files changed, 20 insertions, 2 deletions
diff --git a/misc/reboot/reboot_test.go b/misc/reboot/reboot_test.go
index c4a9f3ef9f..94d61e000e 100644
--- a/misc/reboot/reboot_test.go
+++ b/misc/reboot/reboot_test.go
@@ -7,10 +7,13 @@
package reboot_test
import (
+ "fmt"
+ "io"
"os"
"os/exec"
"path/filepath"
"runtime"
+ "strings"
"testing"
"time"
)
@@ -67,12 +70,27 @@ func TestRepeatBootstrap(t *testing.T) {
makeScript = "make.bash"
}
+ var stdout strings.Builder
cmd := exec.Command(filepath.Join(goroot, "src", makeScript))
cmd.Dir = gorootSrc
- cmd.Env = append(cmd.Environ(), "GOROOT=", "GOROOT_BOOTSTRAP="+realGoroot)
+ cmd.Env = append(cmd.Environ(), "GOROOT=", "GOROOT_FINAL=", "GOROOT_BOOTSTRAP="+realGoroot)
cmd.Stderr = os.Stderr
- cmd.Stdout = os.Stdout
+ cmd.Stdout = io.MultiWriter(os.Stdout, &stdout)
if err := cmd.Run(); err != nil {
t.Fatal(err)
}
+
+ // Test that go.dev/issue/42563 hasn't regressed.
+ t.Run("PATH reminder", func(t *testing.T) {
+ var want string
+ switch gorootBin := filepath.Join(goroot, "bin"); runtime.GOOS {
+ default:
+ want = fmt.Sprintf("*** You need to add %s to your PATH.", gorootBin)
+ case "plan9":
+ want = fmt.Sprintf("*** You need to bind %s before /bin.", gorootBin)
+ }
+ if got := stdout.String(); !strings.Contains(got, want) {
+ t.Errorf("reminder %q is missing from %s stdout:\n%s", want, makeScript, got)
+ }
+ })
}