aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2022-04-25 10:27:34 -0400
committerThan McIntosh <thanm@google.com>2022-04-25 14:52:51 +0000
commit6b1d9aefa8fce9f9c83f46193bec43b9b70068ce (patch)
treef78ee592bf676e3193028b9edf5b1b308932b737
parent8140a605feee9058e28195fcb047d3f1906e77e5 (diff)
downloadgo-6b1d9aefa8fce9f9c83f46193bec43b9b70068ce.tar.gz
go-6b1d9aefa8fce9f9c83f46193bec43b9b70068ce.zip
crypto/ed25519: test fixup
Fix up TestEd25519Vectors to download files into its own temporary mod cache, as opposed relying on whatever GOPATH or GOMODCACHE setting is in effect when the test is run. Change-Id: I523f1862f5874b0635a6c0fa83d35a6cfac6073b Reviewed-on: https://go-review.googlesource.com/c/go/+/402154 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Than McIntosh <thanm@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
-rw-r--r--src/crypto/ed25519/ed25519vectors_test.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/crypto/ed25519/ed25519vectors_test.go b/src/crypto/ed25519/ed25519vectors_test.go
index 74fcdcdf4e..f933f2800a 100644
--- a/src/crypto/ed25519/ed25519vectors_test.go
+++ b/src/crypto/ed25519/ed25519vectors_test.go
@@ -74,11 +74,22 @@ func TestEd25519Vectors(t *testing.T) {
func downloadEd25519Vectors(t *testing.T) []byte {
testenv.MustHaveExternalNetwork(t)
+ // Create a temp dir and modcache subdir.
+ d := t.TempDir()
+ // Create a spot for the modcache.
+ modcache := filepath.Join(d, "modcache")
+ if err := os.Mkdir(modcache, 0777); err != nil {
+ t.Fatal(err)
+ }
+
+ t.Setenv("GO111MODULE", "on")
+ t.Setenv("GOMODCACHE", modcache)
+
// Download the JSON test file from the GOPROXY with `go mod download`,
// pinning the version so test and module caching works as expected.
goTool := testenv.GoToolPath(t)
path := "filippo.io/mostly-harmless/ed25519vectors@v0.0.0-20210322192420-30a2d7243a94"
- cmd := exec.Command(goTool, "mod", "download", "-json", path)
+ cmd := exec.Command(goTool, "mod", "download", "-modcacherw", "-json", path)
// TODO: enable the sumdb once the TryBots proxy supports it.
cmd.Env = append(os.Environ(), "GONOSUMDB=*")
output, err := cmd.Output()