protobuf-go/cmd/protoc-gen-go/testdata/gen_test.go
Joe Tsai d56458e71b internal/cmd/generate-protos: generate test for testdata
Running "go build ./..." does not descend into testdata directories.
However, the testdata in this repository is source code that is
intended to build properly. We could rename the directory, but that does
not test whether the generated packages can initialize properly.

Thus, we generate a trivial test that simply blank imports all packages.

Doing this reveals that some of the generated files have incorrect imports,
leading to registration conflicts.

To avoid introducing a dependency on gRPC from our go.mod file, we put
the testdata directories in their own module. Also, we avoid running
internal/testprotos through the grpc plugin because the servie and method
definitions in that directory are more for testing proto file initialization
rather than testing grpc generation.

Change-Id: Iaa6a06449787a085200e31bc7606e3ac904d3180
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/164917
Reviewed-by: Damien Neil <dneil@google.com>
2019-03-11 19:40:53 +00:00

30 lines
1.6 KiB
Go

// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style.
// license that can be found in the LICENSE file.
// Code generated by generate-protos. DO NOT EDIT.
package main
import (
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/annotations"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/comments"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/base"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/ext"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/extra"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/extensions/proto3"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/fieldnames"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/import_public/sub2"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/fmt"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_1"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_a_2"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/imports/test_b_1"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/issue780_oneof_conflict"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/nopackage"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/proto2"
_ "github.com/golang/protobuf/v2/cmd/protoc-gen-go/testdata/proto3"
)