From 2b0cf01bda03c183b62fb59548376183c7986184 Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 18 Jun 2015 14:59:26 -0400 Subject: [PATCH 1/2] Move `multi` to `multifile` Makes room for `multipkg` to be added in the next commit. --- protoc-gen-go/testdata/Makefile | 4 ++-- protoc-gen-go/testdata/main_test.go | 2 +- protoc-gen-go/testdata/{multi => multifile}/multi1.proto | 4 ++-- protoc-gen-go/testdata/{multi => multifile}/multi2.proto | 0 protoc-gen-go/testdata/{multi => multifile}/multi3.proto | 0 protoc-gen-go/testdata/my_test/test.pb.go | 2 +- protoc-gen-go/testdata/my_test/test.pb.go.golden | 2 +- protoc-gen-go/testdata/my_test/test.proto | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) rename protoc-gen-go/testdata/{multi => multifile}/multi1.proto (96%) rename protoc-gen-go/testdata/{multi => multifile}/multi2.proto (100%) rename protoc-gen-go/testdata/{multi => multifile}/multi3.proto (100%) diff --git a/protoc-gen-go/testdata/Makefile b/protoc-gen-go/testdata/Makefile index 15cb3157e8..16efee87b7 100644 --- a/protoc-gen-go/testdata/Makefile +++ b/protoc-gen-go/testdata/Makefile @@ -47,11 +47,11 @@ golden: nuke: clean testbuild: regenerate - go test + go test ./... regenerate: # Invoke protoc once to generate three independent .pb.go files in the same package. - protoc --go_out=. multi/multi{1,2,3}.proto + protoc --go_out=. multifile/multi{1,2,3}.proto #extension_test: extension_test.$O # $(LD) -L. -o $@ $< diff --git a/protoc-gen-go/testdata/main_test.go b/protoc-gen-go/testdata/main_test.go index 2f1711c505..3847470524 100644 --- a/protoc-gen-go/testdata/main_test.go +++ b/protoc-gen-go/testdata/main_test.go @@ -36,7 +36,7 @@ package testdata import ( "testing" - multipb "./multi" + multipb "./multifile" mytestpb "./my_test" ) diff --git a/protoc-gen-go/testdata/multi/multi1.proto b/protoc-gen-go/testdata/multifile/multi1.proto similarity index 96% rename from protoc-gen-go/testdata/multi/multi1.proto rename to protoc-gen-go/testdata/multifile/multi1.proto index 0da6e0af4b..7079ca8602 100644 --- a/protoc-gen-go/testdata/multi/multi1.proto +++ b/protoc-gen-go/testdata/multifile/multi1.proto @@ -31,8 +31,8 @@ syntax = "proto2"; -import "multi/multi2.proto"; -import "multi/multi3.proto"; +import "multifile/multi2.proto"; +import "multifile/multi3.proto"; package multitest; diff --git a/protoc-gen-go/testdata/multi/multi2.proto b/protoc-gen-go/testdata/multifile/multi2.proto similarity index 100% rename from protoc-gen-go/testdata/multi/multi2.proto rename to protoc-gen-go/testdata/multifile/multi2.proto diff --git a/protoc-gen-go/testdata/multi/multi3.proto b/protoc-gen-go/testdata/multifile/multi3.proto similarity index 100% rename from protoc-gen-go/testdata/multi/multi3.proto rename to protoc-gen-go/testdata/multifile/multi3.proto diff --git a/protoc-gen-go/testdata/my_test/test.pb.go b/protoc-gen-go/testdata/my_test/test.pb.go index 51acfaddf9..f2fc07baf0 100644 --- a/protoc-gen-go/testdata/my_test/test.pb.go +++ b/protoc-gen-go/testdata/my_test/test.pb.go @@ -25,7 +25,7 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -// discarding unused import multitest2 "multi" +// discarding unused import multitest2 "multifile" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal diff --git a/protoc-gen-go/testdata/my_test/test.pb.go.golden b/protoc-gen-go/testdata/my_test/test.pb.go.golden index 51acfaddf9..f2fc07baf0 100644 --- a/protoc-gen-go/testdata/my_test/test.pb.go.golden +++ b/protoc-gen-go/testdata/my_test/test.pb.go.golden @@ -25,7 +25,7 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" -// discarding unused import multitest2 "multi" +// discarding unused import multitest2 "multifile" // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal diff --git a/protoc-gen-go/testdata/my_test/test.proto b/protoc-gen-go/testdata/my_test/test.proto index 9acd4ce776..8155cf8fdb 100644 --- a/protoc-gen-go/testdata/my_test/test.proto +++ b/protoc-gen-go/testdata/my_test/test.proto @@ -35,7 +35,7 @@ syntax = "proto2"; package my.test; // dotted package name //import "imp.proto"; -import "multi/multi1.proto"; // unused import +import "multifile/multi1.proto"; // unused import enum HatType { // deliberately skipping 0 From 0f105742b7bb8463e6388fd8bf186f8deb82126c Mon Sep 17 00:00:00 2001 From: Tamir Duberstein Date: Thu, 18 Jun 2015 15:00:48 -0400 Subject: [PATCH 2/2] Add `multipkg` to exercise cross-package dependencies This current generates code that does not compile. --- protoc-gen-go/testdata/Makefile | 4 ++ protoc-gen-go/testdata/multipkg/bar/bar.proto | 40 +++++++++++++++++++ protoc-gen-go/testdata/multipkg/foo/foo.proto | 36 +++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 protoc-gen-go/testdata/multipkg/bar/bar.proto create mode 100644 protoc-gen-go/testdata/multipkg/foo/foo.proto diff --git a/protoc-gen-go/testdata/Makefile b/protoc-gen-go/testdata/Makefile index 16efee87b7..d25dd784b4 100644 --- a/protoc-gen-go/testdata/Makefile +++ b/protoc-gen-go/testdata/Makefile @@ -52,6 +52,10 @@ testbuild: regenerate regenerate: # Invoke protoc once to generate three independent .pb.go files in the same package. protoc --go_out=. multifile/multi{1,2,3}.proto + # Invoke protoc multiple times to build packages that are interdependent. + for dir in $(sort $(dir $(shell find multipkg -name '*.proto'))); do \ + protoc --go_out=. $$dir/*.proto; \ + done #extension_test: extension_test.$O # $(LD) -L. -o $@ $< diff --git a/protoc-gen-go/testdata/multipkg/bar/bar.proto b/protoc-gen-go/testdata/multipkg/bar/bar.proto new file mode 100644 index 0000000000..2ce42794e0 --- /dev/null +++ b/protoc-gen-go/testdata/multipkg/bar/bar.proto @@ -0,0 +1,40 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto2"; + +import "multipkg/foo/foo.proto"; + +package bar; + +message Bar { + optional foo.Foo foo = 1; +} diff --git a/protoc-gen-go/testdata/multipkg/foo/foo.proto b/protoc-gen-go/testdata/multipkg/foo/foo.proto new file mode 100644 index 0000000000..67fc4c53a1 --- /dev/null +++ b/protoc-gen-go/testdata/multipkg/foo/foo.proto @@ -0,0 +1,36 @@ +// Go support for Protocol Buffers - Google's data interchange format +// +// Copyright 2010 The Go Authors. All rights reserved. +// https://github.com/golang/protobuf +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +syntax = "proto2"; + +package foo; + +message Foo {}