all: fix go generate (needs protolegacy build tag for weak fields)

Prior to this change, one could either use go generate or
./test.bash -regenerate to re-generate the files — but only
the latter way would work.

With this change, we make ./test.bash -regenerate call go generate
so that the two ways cannot diverge again.

Change-Id: I940df66ebc6a4200847cf751929b3611309b67bc
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/547256
Reviewed-by: Lasse Folger <lassefolger@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Michael Stapelberg 2023-12-05 16:14:19 +01:00
parent 704136e0c0
commit 2b71f26c99
3 changed files with 4 additions and 4 deletions

View File

@ -367,8 +367,8 @@ func downloadArchive(check func(error), dstPath, srcURL, skipPrefix, wantSHA256
func mustHandleFlags(t *testing.T) {
if *regenerate {
t.Run("Generate", func(t *testing.T) {
fmt.Print(mustRunCommand(t, "go", "run", "-tags", "protolegacy", "./internal/cmd/generate-types", "-execute"))
fmt.Print(mustRunCommand(t, "go", "run", "-tags", "protolegacy", "./internal/cmd/generate-protos", "-execute"))
fmt.Print(mustRunCommand(t, "go", "generate", "./internal/cmd/generate-types"))
fmt.Print(mustRunCommand(t, "go", "generate", "./internal/cmd/generate-protos"))
files := strings.Split(strings.TrimSpace(mustRunCommand(t, "git", "ls-files", "*.go")), "\n")
mustRunCommand(t, append([]string{"gofmt", "-w"}, files...)...)
})

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate go run . -execute
//go:generate go run -tags protolegacy . -execute
package main

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:generate go run . -execute
//go:generate go run -tags protolegacy . -execute
package main