Просмотр исходного кода

goprotobuf: enable and fix the link test

R=dsymonds
TBR=dsymonds
CC=golang-dev
http://codereview.appspot.com/5656061
Rob Pike 14 лет назад
Родитель
Сommit
158f5911ff

+ 5 - 1
protoc-gen-go/testdata/extension_test.go

@@ -31,7 +31,9 @@
 
 // Test that we can use protocol buffers that use extensions.
 
-package main
+package testdata
+
+/*
 
 import (
 	"bytes"
@@ -204,3 +206,5 @@ func main() {
 		[]testing.InternalBenchmark{},
 		[]testing.InternalExample{})
 }
+
+*/

+ 7 - 5
protoc-gen-go/testdata/main.go → protoc-gen-go/testdata/main_test.go

@@ -31,14 +31,16 @@
 
 // A simple binary to link together the protocol buffers in this test.
 
-package main
+package testdata
 
 import (
-	"./multi1.pb"
-	"./test.pb"
+	"testing"
+
+	//	"./multi1.pb"
+	"code.google.com/p/goprotobuf/protoc-gen-go/testdata/my_test"
 )
 
-func main() {
+func TestLink(t *testing.T) {
 	_ = &my_test.Request{}
-	_ = &multitest.Multi1{}
+	//	_ = &multitest.Multi1{}
 }

+ 7 - 10
protoc-gen-go/testdata/my_test/test.pb.go

@@ -5,7 +5,6 @@ package my_test
 
 import proto "code.google.com/p/goprotobuf/proto"
 import "math"
-import imp1 "imp.pb"
 
 // discarding unused import multitest2 "multi1.pb"
 
@@ -116,15 +115,13 @@ func (x Reply_Entry_Game) String() string {
 }
 
 type Request struct {
-	Key              []int64                     `protobuf:"varint,1,rep,name=key" json:"key,omitempty"`
-	ImportedMessage  *imp1.ImportedMessage       `protobuf:"bytes,2,opt,name=imported_message" json:"imported_message,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"`
-	Owner            *imp1.ImportedMessage_Owner `protobuf:"varint,6,opt,name=owner,enum=imp.ImportedMessage_Owner" json:"owner,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"`
+	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{} }

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

@@ -31,7 +31,7 @@
 
 package my.test;  // dotted package name
 
-import "imp.proto";
+//import "imp.proto";
 import "multi1.proto";  // unused import
 
 enum HatType {
@@ -53,10 +53,10 @@ message Request {
     BLUE = 2;
   }
   repeated int64 key = 1;
-  optional imp.ImportedMessage imported_message = 2;
+//  optional imp.ImportedMessage imported_message = 2;
   optional Color hue = 3;
   optional HatType hat = 4 [default=FEDORA];
-  optional imp.ImportedMessage.Owner owner = 6;
+//  optional imp.ImportedMessage.Owner owner = 6;
   optional float deadline = 7 [default=inf];
   optional group SomeGroup = 8 {
     optional int32 group_field = 9;