diff --git a/protoc-gen-go/testdata/Makefile b/protoc-gen-go/testdata/Makefile index 15cb3157e8..d25dd784b4 100644 --- a/protoc-gen-go/testdata/Makefile +++ b/protoc-gen-go/testdata/Makefile @@ -47,11 +47,15 @@ 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 + # 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/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/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 {} 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