Commit 300f5d5b authored by Jay Conrod's avatar Jay Conrod

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: default avatarBryan C. Mills <bcmills@google.com>
parent 3922c006
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment