Skip to content

Commit fee15f8

Browse files
zhangskzcopybara-github
authored andcommitted
Migrate unittest_features.proto to edition 2024.
Updates tests to avoid setting java features on this proto, since its used frequently in custom pools in unit tests (descriptor_unittest.cc, command_line_interface_unittest.cc) which would require adding the addl. dep in a bunch of places. PiperOrigin-RevId: 791866799
1 parent 6dce93c commit fee15f8

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

java/core/src/test/java/com/google/protobuf/DescriptorsTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.google.protobuf.test.UnittestImport.ImportEnum;
3939
import com.google.protobuf.test.UnittestImport.ImportEnumForMap;
4040
import legacy_features_unittest.UnittestLegacyFeatures;
41+
import pb.EnumFeature;
4142
import pb.UnittestFeatures;
4243
import proto2_unittest.TestCustomOptions;
4344
import proto2_unittest.UnittestCustomOptions;
@@ -1541,7 +1542,7 @@ void setTestFeature(DescriptorProtos.FeatureSet.Builder features, int value) {
15411542
features.setExtension(
15421543
UnittestFeatures.test,
15431544
features.getExtension(UnittestFeatures.test).toBuilder()
1544-
.setMultipleFeature(UnittestFeatures.EnumFeature.forNumber(value))
1545+
.setMultipleFeature(EnumFeature.forNumber(value))
15451546
.build());
15461547
}
15471548

src/google/protobuf/compiler/command_line_interface_unittest.cc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ TEST_F(CommandLineInterfaceTest, FeaturesEditionZero) {
14481448
TEST_F(CommandLineInterfaceTest, FeatureExtensions) {
14491449
CreateTempFile("google/protobuf/descriptor.proto",
14501450
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
1451-
CreateTempFile("features.proto",
1451+
CreateTempFile("google/protobuf/unittest_features.proto",
14521452
R"schema(
14531453
syntax = "proto2";
14541454
package pb;
@@ -1466,7 +1466,7 @@ TEST_F(CommandLineInterfaceTest, FeatureExtensions) {
14661466
CreateTempFile("foo.proto",
14671467
R"schema(
14681468
edition = "2023";
1469-
import "features.proto";
1469+
import "google/protobuf/unittest_features.proto";
14701470
message Foo {
14711471
int32 bar = 1;
14721472
int32 baz = 2 [features.(pb.test).int_feature = 5];
@@ -1539,12 +1539,12 @@ TEST_F(CommandLineInterfaceTest, FeatureTargetError) {
15391539
TEST_F(CommandLineInterfaceTest, FeatureExtensionError) {
15401540
CreateTempFile("google/protobuf/descriptor.proto",
15411541
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
1542-
CreateTempFile("features.proto",
1542+
CreateTempFile("google/protobuf/unittest_features.proto",
15431543
pb::TestInvalidFeatures::descriptor()->file()->DebugString());
15441544
CreateTempFile("foo.proto",
15451545
R"schema(
15461546
edition = "2023";
1547-
import "features.proto";
1547+
import "google/protobuf/unittest_features.proto";
15481548
message Foo {
15491549
int32 bar = 1;
15501550
int32 baz = 2 [features.(pb.test_invalid).repeated_feature = 5];
@@ -2280,12 +2280,13 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithMinimum) {
22802280
TEST_F(CommandLineInterfaceTest, EditionDefaultsWithExtension) {
22812281
CreateTempFile("google/protobuf/descriptor.proto",
22822282
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
2283-
CreateTempFile("features.proto",
2283+
CreateTempFile("google/protobuf/unittest_features.proto",
22842284
pb::TestFeatures::descriptor()->file()->DebugString());
22852285
Run("protocol_compiler --proto_path=$tmpdir "
22862286
"--edition_defaults_out=$tmpdir/defaults "
22872287
"--edition_defaults_maximum=99999_TEST_ONLY "
2288-
"features.proto google/protobuf/descriptor.proto");
2288+
"google/protobuf/unittest_features.proto "
2289+
"google/protobuf/descriptor.proto");
22892290
ExpectNoErrors();
22902291

22912292
FeatureSetDefaults defaults = ReadEditionDefaults("defaults");
@@ -2328,30 +2329,30 @@ TEST_F(CommandLineInterfaceTest, EditionDefaultsWithExtension) {
23282329
TEST_F(CommandLineInterfaceTest, EditionDefaultsDependencyManifest) {
23292330
CreateTempFile("google/protobuf/descriptor.proto",
23302331
google::protobuf::DescriptorProto::descriptor()->file()->DebugString());
2331-
CreateTempFile("features.proto",
2332+
CreateTempFile("google/protobuf/unittest_features.proto",
23322333
pb::TestFeatures::descriptor()->file()->DebugString());
23332334

23342335
Run("protocol_compiler --dependency_out=$tmpdir/manifest "
23352336
"--edition_defaults_out=$tmpdir/defaults "
2336-
"--proto_path=$tmpdir features.proto");
2337+
"--proto_path=$tmpdir google/protobuf/unittest_features.proto");
23372338

23382339
ExpectNoErrors();
23392340

2340-
ExpectFileContent(
2341-
"manifest",
2342-
"$tmpdir/defaults: "
2343-
"$tmpdir/google/protobuf/descriptor.proto\\\n $tmpdir/features.proto");
2341+
ExpectFileContent("manifest",
2342+
"$tmpdir/defaults: "
2343+
"$tmpdir/google/protobuf/descriptor.proto\\\n "
2344+
"$tmpdir/google/protobuf/unittest_features.proto");
23442345
}
23452346
#endif // _WIN32
23462347

23472348
TEST_F(CommandLineInterfaceTest, EditionDefaultsInvalidMissingDescriptor) {
2348-
CreateTempFile("features.proto", R"schema(
2349+
CreateTempFile("google/protobuf/unittest_features.proto", R"schema(
23492350
syntax = "proto2";
23502351
message Foo {}
23512352
)schema");
23522353
Run("protocol_compiler --proto_path=$tmpdir "
23532354
"--edition_defaults_out=$tmpdir/defaults "
2354-
"features.proto");
2355+
"google/protobuf/unittest_features.proto");
23552356
ExpectErrorSubstring("Could not find FeatureSet in descriptor pool");
23562357
}
23572358

src/google/protobuf/unittest_features.proto

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
// license that can be found in the LICENSE file or at
66
// https://developers.google.com/open-source/licenses/bsd
77

8-
edition = "2023";
8+
edition = "2024";
99

1010
package pb;
1111

1212
import "google/protobuf/descriptor.proto";
1313

14+
option java_outer_classname = "UnittestFeatures";
15+
1416
extend google.protobuf.FeatureSet {
1517
TestFeatures test = 9999;
1618
}

0 commit comments

Comments
 (0)