From 95e809f0e525fca000ec634e1e8cc10d6cebdf30 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 2 Nov 2016 23:12:10 -0400 Subject: [PATCH] cmd/go: clear GIT_ALLOW_PROTOCOL during tests Clear it before any tests begin. Clear it again after TestIsSecureGitAllowProtocol sets it. Fixes #17700. Change-Id: I6ea50d37f8222d8c7c9fee0b1eac3bbdfb5d133e Reviewed-on: https://go-review.googlesource.com/32640 Reviewed-by: Quentin Smith Run-TryBot: Russ Cox --- src/cmd/go/go_test.go | 1 + src/cmd/go/vcs_test.go | 1 + 2 files changed, 2 insertions(+) diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 37da67c8b7..e6eec09082 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -99,6 +99,7 @@ func TestMain(m *testing.M) { // Don't let these environment variables confuse the test. os.Unsetenv("GOBIN") os.Unsetenv("GOPATH") + os.Unsetenv("GIT_ALLOW_PROTOCOL") if home, ccacheDir := os.Getenv("HOME"), os.Getenv("CCACHE_DIR"); home != "" && ccacheDir == "" { // On some systems the default C compiler is ccache. // Setting HOME to a non-existent directory will break diff --git a/src/cmd/go/vcs_test.go b/src/cmd/go/vcs_test.go index 798f6683a6..c73f5d0e85 100644 --- a/src/cmd/go/vcs_test.go +++ b/src/cmd/go/vcs_test.go @@ -271,6 +271,7 @@ func TestIsSecureGitAllowProtocol(t *testing.T) { {vcsBzr, "foo://example.com/bar.bzr", false}, } + defer os.Unsetenv("GIT_ALLOW_PROTOCOL") os.Setenv("GIT_ALLOW_PROTOCOL", "https:foo") for _, test := range tests { secure := test.vcs.isSecure(test.url)