Skip to content

Commit

Permalink
proto: switch messageset_test to use makeMessages() injection point
Browse files Browse the repository at this point in the history
This required renaming the extension fields to have distinct names, as
makeMessages() uses the protobuild package, which works with field names.

The makeMessages() function can be centrally extended with other variants of
testprotos (e.g. editions).

Change-Id: I68ef28baee674c6b53da8629c5ff7b2e1b92d4ff
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/624415
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Chressie Himpel <[email protected]>
  • Loading branch information
stapelberg committed Nov 4, 2024
1 parent 29947bb commit 76135f9
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 156 deletions.
4 changes: 2 additions & 2 deletions internal/race_test/messageset_extension_init/race_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ func TestConcurrentInitialization(t *testing.T) {
wg.Add(2)
go func() {
defer wg.Done()
epb.E_Ext1_MessageSetExtension.ValueOf(&epb.Ext1{})
epb.E_Ext1_MessageSetExt1.ValueOf(&epb.Ext1{})
}()
go func() {
defer wg.Done()
epb.E_Ext1_MessageSetExtension.TypeDescriptor().Message()
epb.E_Ext1_MessageSetExt1.TypeDescriptor().Message()
}()
wg.Wait()
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ message MessageSet {
extensions 530000000 to max
[declaration = {
number: 536870912
full_name: ".goproto.proto.messageset.ExtLargeNumber.message_set_extension"
full_name: ".goproto.proto.messageset.ExtLargeNumber.message_set_extlarge"
type: ".goproto.proto.messageset.ExtLargeNumber"
}];
}
Expand Down
137 changes: 68 additions & 69 deletions internal/testprotos/messageset/msetextpb/msetextpb.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions internal/testprotos/messageset/msetextpb/msetextpb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,28 @@ option go_package = "google.golang.org/protobuf/internal/testprotos/messageset/m

message Ext1 {
extend MessageSet {
optional Ext1 message_set_extension = 1000;
optional Ext1 message_set_ext1 = 1000;
}
optional int32 ext1_field1 = 1;
optional int32 ext1_field2 = 2;
}

message Ext2 {
extend MessageSet {
optional Ext2 message_set_extension = 1001;
optional Ext2 message_set_ext2 = 1001;
}
optional int32 ext2_field1 = 1;
}

message ExtRequired {
extend MessageSet {
optional ExtRequired message_set_extension = 1002;
optional ExtRequired message_set_extrequired = 1002;
}
required int32 required_field1 = 1;
}

message ExtLargeNumber {
extend MessageSet {
optional ExtLargeNumber message_set_extension = 536870912; // 1<<29
optional ExtLargeNumber message_set_extlarge = 536870912; // 1<<29
}
}
Loading

0 comments on commit 76135f9

Please sign in to comment.