]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: add 'go generate' commands to modfile_flag test
authorJay Conrod <jayconrod@google.com>
Thu, 21 Nov 2019 23:54:38 +0000 (18:54 -0500)
committerJay Conrod <jayconrod@google.com>
Fri, 22 Nov 2019 16:03:16 +0000 (16:03 +0000)
Verify that 'go generate' works with -modfile. Also check that
go commands starts with 'go generate' do not inherit -modfile, but
they should still work if -modfile is set in GOFLAGS.

Updates #34506

Change-Id: I5e1f897b4e38e4fdaccc0fbb7a71b8d0e9fc0660
Reviewed-on: https://go-review.googlesource.com/c/go/+/208236
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
src/cmd/go/testdata/script/modfile_flag.txt

index 46a169fc427e2d1bcc6474663c03a8cb5e5f662c..1409be9599c455d19dd144e9ede372b45feaee79 100644 (file)
@@ -44,6 +44,19 @@ exists vendor
 go mod edit -require rsc.io/quote@v1.5.1
 ! go list .
 go list -mod=mod
+rm vendor
+
+
+# 'go generate' should use the alternate file when resolving packages.
+# Recursive go commands started with 'go generate' should not get an explicitly
+# passed -modfile, but they should see arguments from GOFLAGS.
+cp go.alt.mod go.gen.mod
+env OLD_GOFLAGS=$GOFLAGS
+env GOFLAGS=-modfile=go.gen.mod
+go generate -modfile=go.alt.mod .
+env GOFLAGS=$OLD_GOFLAGS
+grep example.com/exclude go.gen.mod
+! grep example.com/exclude go.alt.mod
 
 
 # The original files should not have been modified.
@@ -62,6 +75,10 @@ stderr '-modfile=goaltmod: file does not have .mod extension'
 -- go.sum --
 ʕ◔ϖ◔ʔ
 -- use.go --
-package use
+package main
 
 import _ "rsc.io/quote"
+-- gen.go --
+//go:generate go mod edit -exclude example.com/exclude@v1.0.0
+
+package main