diff options
author | Jay Conrod <jayconrod@google.com> | 2019-11-21 18:54:38 -0500 |
---|---|---|
committer | Jay Conrod <jayconrod@google.com> | 2019-11-22 16:03:16 +0000 |
commit | 300f5d5b4bac870aa146c14cbb50dbb3902f1feb (patch) | |
tree | 420e650314e6f24dd407f51d95a4cb432e7b486a | |
parent | 3922c006ad57f042238e48bb2cd13e5d88499a6c (diff) | |
download | go-300f5d5b4bac870aa146c14cbb50dbb3902f1feb.tar.gz go-300f5d5b4bac870aa146c14cbb50dbb3902f1feb.zip |
cmd/go: add 'go generate' commands to modfile_flag test
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>
-rw-r--r-- | src/cmd/go/testdata/script/modfile_flag.txt | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/cmd/go/testdata/script/modfile_flag.txt b/src/cmd/go/testdata/script/modfile_flag.txt index 46a169fc42..1409be9599 100644 --- a/src/cmd/go/testdata/script/modfile_flag.txt +++ b/src/cmd/go/testdata/script/modfile_flag.txt @@ -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 |