Jelajahi Sumber

goprotobuf: fix compiler golden test

TBR=r
CC=golang-dev
http://codereview.appspot.com/5833043
David Symonds 14 tahun lalu
induk
melakukan
6280c20192

+ 1 - 1
Makefile

@@ -38,7 +38,7 @@ install:
 
 test:
 	go test ./proto
-	go test ./protoc-gen-go/testdata
+	make -C protoc-gen-go/testdata test
 
 clean:
 	go clean ./...

+ 7 - 16
protoc-gen-go/testdata/Makefile

@@ -29,29 +29,20 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-all: test
+all:
+	@echo run make test
 
-test:
-	echo protoc-gen-go tests are disabled
-	true
+include ../../Make.protobuf
 
-#include $(GOROOT)/src/Make.inc
-
-#all:
-#	@echo run make test
-
-#include $(GOROOT)/src/Make.common
-#include ../../Make.protobuf
-
-#CLEANFILES+=*.pb.go extension_test
+test:	golden
 
 #test:	golden testbuild extension_test
 #	./extension_test
 #	@echo PASS
 
-#golden:
-#	$(QUOTED_GOBIN)/gomake -B test.pb.go
-#	diff -w test.pb.go test.pb.go.golden
+golden:
+	make -B my_test/test.pb.go
+	diff -w my_test/test.pb.go my_test/test.pb.go.golden
 
 #nuke:	clean
 

+ 3 - 3
protoc-gen-go/testdata/multi1.proto → protoc-gen-go/testdata/multi/multi1.proto

@@ -29,10 +29,10 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-import "multi2.proto";
-import "multi3.proto";
+import "multi/multi2.proto";
+import "multi/multi3.proto";
 
-package multitest;
+package multi;
 
 message Multi1 {
   required Multi2 multi2 = 1;

+ 1 - 1
protoc-gen-go/testdata/multi2.proto → protoc-gen-go/testdata/multi/multi2.proto

@@ -29,7 +29,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-package multitest;
+package multi;
 
 message Multi2 {
   required int32 required_value = 1;

+ 1 - 1
protoc-gen-go/testdata/multi3.proto → protoc-gen-go/testdata/multi/multi3.proto

@@ -29,7 +29,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-package multitest;
+package multi;
 
 message Multi3 {
   enum HatType {

+ 1 - 1
protoc-gen-go/testdata/my_test/test.pb.go

@@ -6,7 +6,7 @@ package my_test
 import proto "code.google.com/p/goprotobuf/proto"
 import "math"
 
-// discarding unused import multitest2 "multi1.pb"
+// discarding unused import multi2 "multi/multi1.pb"
 
 // Reference proto and math imports to suppress error if they are not otherwise used.
 var _ = proto.GetString

+ 241 - 0
protoc-gen-go/testdata/my_test/test.pb.go.golden

@@ -0,0 +1,241 @@
+// Code generated by protoc-gen-go from "my_test/test.proto"
+// DO NOT EDIT!
+
+package my_test
+
+import proto "code.google.com/p/goprotobuf/proto"
+import "math"
+
+// discarding unused import multi2 "multi/multi1.pb"
+
+// Reference proto and math imports to suppress error if they are not otherwise used.
+var _ = proto.GetString
+var _ = math.Inf
+
+type HatType int32
+
+const (
+	HatType_FEDORA HatType = 1
+	HatType_FEZ    HatType = 2
+)
+
+var HatType_name = map[int32]string{
+	1: "FEDORA",
+	2: "FEZ",
+}
+var HatType_value = map[string]int32{
+	"FEDORA": 1,
+	"FEZ":    2,
+}
+
+func NewHatType(x HatType) *HatType {
+	e := HatType(x)
+	return &e
+}
+func (x HatType) String() string {
+	return proto.EnumName(HatType_name, int32(x))
+}
+
+type Days int32
+
+const (
+	Days_MONDAY  Days = 1
+	Days_TUESDAY Days = 2
+	Days_LUNDI   Days = 1
+)
+
+var Days_name = map[int32]string{
+	1: "MONDAY",
+	2: "TUESDAY",
+	// Duplicate value: 1: "LUNDI",
+}
+var Days_value = map[string]int32{
+	"MONDAY":  1,
+	"TUESDAY": 2,
+	"LUNDI":   1,
+}
+
+func NewDays(x Days) *Days {
+	e := Days(x)
+	return &e
+}
+func (x Days) String() string {
+	return proto.EnumName(Days_name, int32(x))
+}
+
+type Request_Color int32
+
+const (
+	Request_RED   Request_Color = 0
+	Request_GREEN Request_Color = 1
+	Request_BLUE  Request_Color = 2
+)
+
+var Request_Color_name = map[int32]string{
+	0: "RED",
+	1: "GREEN",
+	2: "BLUE",
+}
+var Request_Color_value = map[string]int32{
+	"RED":   0,
+	"GREEN": 1,
+	"BLUE":  2,
+}
+
+func NewRequest_Color(x Request_Color) *Request_Color {
+	e := Request_Color(x)
+	return &e
+}
+func (x Request_Color) String() string {
+	return proto.EnumName(Request_Color_name, int32(x))
+}
+
+type Reply_Entry_Game int32
+
+const (
+	Reply_Entry_FOOTBALL Reply_Entry_Game = 1
+	Reply_Entry_TENNIS   Reply_Entry_Game = 2
+)
+
+var Reply_Entry_Game_name = map[int32]string{
+	1: "FOOTBALL",
+	2: "TENNIS",
+}
+var Reply_Entry_Game_value = map[string]int32{
+	"FOOTBALL": 1,
+	"TENNIS":   2,
+}
+
+func NewReply_Entry_Game(x Reply_Entry_Game) *Reply_Entry_Game {
+	e := Reply_Entry_Game(x)
+	return &e
+}
+func (x Reply_Entry_Game) String() string {
+	return proto.EnumName(Reply_Entry_Game_name, int32(x))
+}
+
+type Request struct {
+	Key              []int64            `protobuf:"varint,1,rep,name=key" json:"key,omitempty"`
+	Hue              *Request_Color     `protobuf:"varint,3,opt,name=hue,enum=my.test.Request_Color" json:"hue,omitempty"`
+	Hat              *HatType           `protobuf:"varint,4,opt,name=hat,enum=my.test.HatType,def=1" json:"hat,omitempty"`
+	Deadline         *float32           `protobuf:"fixed32,7,opt,name=deadline,def=inf" json:"deadline,omitempty"`
+	Somegroup        *Request_SomeGroup `protobuf:"group,8,opt,name=SomeGroup" json:"somegroup,omitempty"`
+	Reset_           *int32             `protobuf:"varint,12,opt,name=reset" json:"reset,omitempty"`
+	XXX_unrecognized []byte             `json:",omitempty"`
+}
+
+func (this *Request) Reset()         { *this = Request{} }
+func (this *Request) String() string { return proto.CompactTextString(this) }
+
+const Default_Request_Hat HatType = HatType_FEDORA
+
+var Default_Request_Deadline float32 = float32(math.Inf(1))
+
+type Request_SomeGroup struct {
+	GroupField       *int32 `protobuf:"varint,9,opt,name=group_field" json:"group_field,omitempty"`
+	XXX_unrecognized []byte `json:",omitempty"`
+}
+
+func (this *Request_SomeGroup) Reset()         { *this = Request_SomeGroup{} }
+func (this *Request_SomeGroup) String() string { return proto.CompactTextString(this) }
+
+type Reply struct {
+	Found            []*Reply_Entry            `protobuf:"bytes,1,rep,name=found" json:"found,omitempty"`
+	CompactKeys      []int32                   `protobuf:"varint,2,rep,packed,name=compact_keys" json:"compact_keys,omitempty"`
+	XXX_extensions   map[int32]proto.Extension `json:",omitempty"`
+	XXX_unrecognized []byte                    `json:",omitempty"`
+}
+
+func (this *Reply) Reset()         { *this = Reply{} }
+func (this *Reply) String() string { return proto.CompactTextString(this) }
+
+var extRange_Reply = []proto.ExtensionRange{
+	{100, 536870911},
+}
+
+func (*Reply) ExtensionRangeArray() []proto.ExtensionRange {
+	return extRange_Reply
+}
+func (this *Reply) ExtensionMap() map[int32]proto.Extension {
+	if this.XXX_extensions == nil {
+		this.XXX_extensions = make(map[int32]proto.Extension)
+	}
+	return this.XXX_extensions
+}
+
+type Reply_Entry struct {
+	KeyThatNeeds_1234Camel_CasIng *int64 `protobuf:"varint,1,req,name=key_that_needs_1234camel_CasIng" json:"key_that_needs_1234camel_CasIng,omitempty"`
+	Value                         *int64 `protobuf:"varint,2,opt,name=value,def=7" json:"value,omitempty"`
+	XMyFieldName_2                *int64 `protobuf:"varint,3,opt,name=_my_field_name_2" json:"_my_field_name_2,omitempty"`
+	XXX_unrecognized              []byte `json:",omitempty"`
+}
+
+func (this *Reply_Entry) Reset()         { *this = Reply_Entry{} }
+func (this *Reply_Entry) String() string { return proto.CompactTextString(this) }
+
+const Default_Reply_Entry_Value int64 = 7
+
+type ReplyExtensions struct {
+	XXX_unrecognized []byte `json:",omitempty"`
+}
+
+func (this *ReplyExtensions) Reset()         { *this = ReplyExtensions{} }
+func (this *ReplyExtensions) String() string { return proto.CompactTextString(this) }
+
+var E_ReplyExtensions_Time = &proto.ExtensionDesc{
+	ExtendedType:  (*Reply)(nil),
+	ExtensionType: (*float64)(nil),
+	Field:         101,
+	Name:          "my.test.ReplyExtensions.time",
+	Tag:           "fixed64,101,opt,name=time",
+}
+
+type OldReply struct {
+	XXX_extensions   map[int32]proto.Extension `json:",omitempty"`
+	XXX_unrecognized []byte                    `json:",omitempty"`
+}
+
+func (this *OldReply) Reset()         { *this = OldReply{} }
+func (this *OldReply) String() string { return proto.CompactTextString(this) }
+
+func (this *OldReply) Marshal() ([]byte, error) {
+	return proto.MarshalMessageSet(this.ExtensionMap())
+}
+func (this *OldReply) Unmarshal(buf []byte) error {
+	return proto.UnmarshalMessageSet(buf, this.ExtensionMap())
+}
+
+// ensure OldReply satisfies proto.Marshaler and proto.Unmarshaler
+var _ proto.Marshaler = (*OldReply)(nil)
+var _ proto.Unmarshaler = (*OldReply)(nil)
+
+var extRange_OldReply = []proto.ExtensionRange{
+	{100, 536870911},
+}
+
+func (*OldReply) ExtensionRangeArray() []proto.ExtensionRange {
+	return extRange_OldReply
+}
+func (this *OldReply) ExtensionMap() map[int32]proto.Extension {
+	if this.XXX_extensions == nil {
+		this.XXX_extensions = make(map[int32]proto.Extension)
+	}
+	return this.XXX_extensions
+}
+
+var E_Tag = &proto.ExtensionDesc{
+	ExtendedType:  (*Reply)(nil),
+	ExtensionType: (*string)(nil),
+	Field:         103,
+	Name:          "my.test.tag",
+	Tag:           "bytes,103,opt,name=tag",
+}
+
+func init() {
+	proto.RegisterEnum("my.test.HatType", HatType_name, HatType_value)
+	proto.RegisterEnum("my.test.Days", Days_name, Days_value)
+	proto.RegisterEnum("my.test.Request_Color", Request_Color_name, Request_Color_value)
+	proto.RegisterEnum("my.test.Reply_Entry_Game", Reply_Entry_Game_name, Reply_Entry_Game_value)
+	proto.RegisterExtension(E_ReplyExtensions_Time)
+	proto.RegisterExtension(E_Tag)
+}

+ 1 - 1
protoc-gen-go/testdata/my_test/test.proto

@@ -32,7 +32,7 @@
 package my.test;  // dotted package name
 
 //import "imp.proto";
-import "multi1.proto";  // unused import
+import "multi/multi1.proto";  // unused import
 
 enum HatType {
   // deliberately skipping 0