all: implement support for proto3 optional semantics
In the upcoming 3.12.x release of protoc, the proto3 language will be
amended to support true presence for scalars. This CL adds support
to both the generator and runtime to support these semantics.
Newly added public API:
protogen.Plugin.SupportedFeatures
protoreflect.FieldDescriptor.HasPresence
protoreflect.FieldDescriptor.HasOptionalKeyword
protoreflect.OneofDescriptor.IsSynthetic
Change-Id: I7c86bf66d0ae56642109beb5f2132184593747ad
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/230698
Reviewed-by: Damien Neil <dneil@google.com>
diff --git a/integration_test.go b/integration_test.go
index 2a9a470..a6fe2b6 100644
--- a/integration_test.go
+++ b/integration_test.go
@@ -32,7 +32,7 @@
regenerate = flag.Bool("regenerate", false, "regenerate files")
buildRelease = flag.Bool("buildRelease", false, "build release binaries")
- protobufVersion = "3.11.4"
+ protobufVersion = "4b4e6674" // pre-release of 3.12.x
golangVersions = []string{"1.9.7", "1.10.8", "1.11.13", "1.12.17", "1.13.8", "1.14"}
golangLatest = golangVersions[len(golangVersions)-1]
@@ -209,8 +209,13 @@
protobufPath = workingDir
if _, err := os.Stat(protobufPath); err != nil {
fmt.Printf("download %v\n", filepath.Base(protobufPath))
- url := fmt.Sprintf("https://github.com/google/protobuf/releases/download/v%v/protobuf-all-%v.tar.gz", protobufVersion, protobufVersion)
- downloadArchive(check, protobufPath, url, "protobuf-"+protobufVersion)
+ if isCommit := strings.Trim(protobufVersion, "0123456789abcdef") == ""; isCommit {
+ command{Dir: testDir}.mustRun(t, "git", "clone", "https://github.com/protocolbuffers/protobuf", "protobuf-"+protobufVersion)
+ command{Dir: protobufPath}.mustRun(t, "git", "checkout", protobufVersion)
+ } else {
+ url := fmt.Sprintf("https://github.com/google/protobuf/releases/download/v%v/protobuf-all-%v.tar.gz", protobufVersion, protobufVersion)
+ downloadArchive(check, protobufPath, url, "protobuf-"+protobufVersion)
+ }
fmt.Printf("build %v\n", filepath.Base(protobufPath))
command{Dir: protobufPath}.mustRun(t, "./autogen.sh")
@@ -370,20 +375,10 @@
`),
}
-var noCopyrightHeader = []string{
- // Missing copyright header upstream.
- "internal/testprotos/benchmarks/datasets/",
-}
-
func mustHaveCopyrightHeader(t *testing.T, files []string) {
var bad []string
File:
for _, file := range files {
- for _, prefix := range noCopyrightHeader {
- if strings.HasPrefix(file, prefix) {
- continue File
- }
- }
b, err := ioutil.ReadFile(file)
if err != nil {
t.Fatal(err)