Skip to content

Commit 0404e66

Browse files
Rachel Goldfingercopybara-github
authored andcommitted
Add conformance test for edition unstable
PiperOrigin-RevId: 850054867
1 parent 99187f1 commit 0404e66

27 files changed

+226
-7
lines changed

cmake/conformance.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,16 @@ add_custom_command(
3838
${protobuf_BINARY_DIR}/conformance/conformance.pb.cc
3939
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition2023.pb.h
4040
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition2023.pb.cc
41+
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition_unstable.pb.h
42+
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition_unstable.pb.cc
4143
DEPENDS ${protobuf_PROTOC_EXE}
4244
${protobuf_SOURCE_DIR}/conformance/conformance.proto
4345
${protobuf_SOURCE_DIR}/conformance/test_protos/test_messages_edition2023.proto
46+
${protobuf_SOURCE_DIR}/conformance/test_protos/test_messages_edition_unstable.proto
4447
COMMAND ${protobuf_PROTOC_EXE}
4548
${protobuf_SOURCE_DIR}/conformance/conformance.proto
4649
${protobuf_SOURCE_DIR}/conformance/test_protos/test_messages_edition2023.proto
50+
${protobuf_SOURCE_DIR}/conformance/test_protos/test_messages_edition_unstable.proto
4751
--proto_path=${protobuf_SOURCE_DIR}
4852
--cpp_out=${protobuf_BINARY_DIR}
4953
)
@@ -89,6 +93,8 @@ add_library(libconformance_common STATIC
8993
${protobuf_BINARY_DIR}/conformance/conformance.pb.cc
9094
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition2023.pb.h
9195
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition2023.pb.cc
96+
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition_unstable.pb.h
97+
${protobuf_BINARY_DIR}/conformance/test_protos/test_messages_edition_unstable.pb.cc
9298
${protobuf_BINARY_DIR}/editions/golden/test_messages_proto3_editions.pb.h
9399
${protobuf_BINARY_DIR}/editions/golden/test_messages_proto3_editions.pb.cc
94100
${protobuf_BINARY_DIR}/editions/golden/test_messages_proto2_editions.pb.h

conformance/BUILD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ cc_library(
138138
"//:test_messages_proto2_cc_proto",
139139
"//:test_messages_proto3_cc_proto",
140140
"//conformance/test_protos:test_messages_edition2023_cc_proto",
141+
"//conformance/test_protos:test_messages_edition_unstable_cc_proto",
141142
"//editions:test_messages_proto2_editions_cc_proto",
142143
"//editions:test_messages_proto3_editions_cc_proto",
143144
"//src/google/protobuf",
@@ -166,6 +167,7 @@ cc_library(
166167
"//:test_messages_proto2_cc_proto",
167168
"//:test_messages_proto3_cc_proto",
168169
"//conformance/test_protos:test_messages_edition2023_cc_proto",
170+
"//conformance/test_protos:test_messages_edition_unstable_cc_proto",
169171
"//editions:test_messages_proto2_editions_cc_proto",
170172
"//editions:test_messages_proto3_editions_cc_proto",
171173
"//src/google/protobuf",
@@ -249,6 +251,7 @@ cc_test(
249251
"//:test_messages_proto2_cc_proto",
250252
"//:test_messages_proto3_cc_proto",
251253
"//conformance/test_protos:test_messages_edition2023_cc_proto",
254+
"//conformance/test_protos:test_messages_edition_unstable_cc_proto",
252255
"//editions:test_messages_proto2_editions_cc_proto",
253256
"//editions:test_messages_proto3_editions_cc_proto",
254257
"@googletest//:gtest",
@@ -440,6 +443,7 @@ cc_binary(
440443
"//:type_cc_proto",
441444
"//:wrappers_cc_proto",
442445
"//conformance/test_protos:test_messages_edition2023_cc_proto",
446+
"//conformance/test_protos:test_messages_edition_unstable_cc_proto",
443447
"//editions:test_messages_proto2_editions_cc_proto",
444448
"//editions:test_messages_proto3_editions_cc_proto",
445449
"//src/google/protobuf",
@@ -472,6 +476,7 @@ java_binary(
472476
"//:test_messages_proto2_java_proto",
473477
"//:test_messages_proto3_java_proto",
474478
"//conformance/test_protos:test_messages_edition2023_java_proto",
479+
"//conformance/test_protos:test_messages_edition_unstable_java_proto",
475480
"//editions:test_messages_proto2_editions_java_proto",
476481
"//editions:test_messages_proto3_editions_java_proto",
477482
],
@@ -492,6 +497,7 @@ java_binary(
492497
"//:test_messages_proto2_java_proto_lite",
493498
"//:test_messages_proto3_java_proto_lite",
494499
"//conformance/test_protos:test_messages_edition2023_java_proto_lite",
500+
"//conformance/test_protos:test_messages_edition_unstable_java_proto_lite",
495501
"//editions:test_messages_proto2_editions_java_proto_lite",
496502
"//editions:test_messages_proto3_editions_java_proto_lite",
497503
],
@@ -511,6 +517,7 @@ py_binary(
511517
":conformance_py_proto",
512518
"//:protobuf_python",
513519
"//conformance/test_protos:test_messages_edition2023_py_pb2",
520+
"//conformance/test_protos:test_messages_edition_unstable_py_pb2",
514521
"//editions:test_messages_proto2_editions_py_pb2",
515522
"//editions:test_messages_proto3_editions_py_pb2",
516523
"//python:_message", # Make upb visible if we need it.
@@ -572,6 +579,7 @@ inline_sh_binary(
572579
visibility = ["//csharp:__subpackages__"],
573580
deps = [
574581
"//conformance/test_protos:test_messages_edition2023_csharp_proto",
582+
"//conformance/test_protos:test_messages_edition_unstable_csharp_proto",
575583
"//csharp/src/Google.Protobuf.Conformance:conformance_runfiles",
576584
],
577585
)
@@ -587,6 +595,7 @@ objc_library(
587595
"//:test_messages_proto2_objc_proto",
588596
"//:test_messages_proto3_objc_proto",
589597
"//conformance/test_protos:test_messages_edition2023_objc_proto",
598+
"//conformance/test_protos:test_messages_edition_unstable_objc_proto",
590599
"//editions:test_messages_proto2_editions_objc_proto",
591600
"//editions:test_messages_proto3_editions_objc_proto",
592601
],

conformance/ConformanceJava.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import com.google.protobuf.util.JsonFormat.TypeRegistry;
1818
import com.google.protobuf_test_messages.edition2023.TestAllTypesEdition2023;
1919
import com.google.protobuf_test_messages.edition2023.TestMessagesEdition2023;
20+
import com.google.protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable;
21+
import com.google.protobuf_test_messages.edition_unstable.TestMessagesEditionUnstableProto;
2022
import com.google.protobuf_test_messages.editions.proto2.TestMessagesProto2Editions;
2123
import com.google.protobuf_test_messages.editions.proto3.TestMessagesProto3Editions;
2224
import com.google.protobuf_test_messages.proto2.TestMessagesProto2;
@@ -217,6 +219,8 @@ private Class<? extends AbstractMessage> createTestMessage(String messageType) {
217219
return TestAllTypesProto2.class;
218220
case "protobuf_test_messages.editions.TestAllTypesEdition2023":
219221
return TestAllTypesEdition2023.class;
222+
case "protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable":
223+
return TestAllTypesEditionUnstable.class;
220224
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
221225
return TestMessagesProto3Editions.TestAllTypesProto3.class;
222226
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":
@@ -235,6 +239,8 @@ private Class<?> createTestFile(String messageType) {
235239
return TestMessagesProto2.class;
236240
case "protobuf_test_messages.editions.TestAllTypesEdition2023":
237241
return TestMessagesEdition2023.class;
242+
case "protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable":
243+
return TestMessagesEditionUnstableProto.class;
238244
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
239245
return TestMessagesProto3Editions.class;
240246
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":

conformance/ConformanceJavaLite.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import com.google.protobuf.conformance.Conformance;
1616
import com.google.protobuf_test_messages.edition2023.TestAllTypesEdition2023;
1717
import com.google.protobuf_test_messages.edition2023.TestMessagesEdition2023;
18+
import com.google.protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable;
19+
import com.google.protobuf_test_messages.edition_unstable.TestMessagesEditionUnstableProto;
1820
import com.google.protobuf_test_messages.editions.proto2.TestMessagesProto2Editions;
1921
import com.google.protobuf_test_messages.editions.proto3.TestMessagesProto3Editions;
2022
import com.google.protobuf_test_messages.proto2.TestMessagesProto2;
@@ -216,6 +218,8 @@ private Class<? extends AbstractMessageLite> createTestMessage(String messageTyp
216218
return TestAllTypesProto2.class;
217219
case "protobuf_test_messages.editions.TestAllTypesEdition2023":
218220
return TestAllTypesEdition2023.class;
221+
case "protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable":
222+
return TestAllTypesEditionUnstable.class;
219223
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
220224
return TestMessagesProto3Editions.TestAllTypesProto3.class;
221225
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":
@@ -234,6 +238,8 @@ private Class<?> createTestFile(String messageType) {
234238
return TestMessagesProto2.class;
235239
case "protobuf_test_messages.editions.TestAllTypesEdition2023":
236240
return TestMessagesEdition2023.class;
241+
case "protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable":
242+
return TestMessagesEditionUnstableProto.class;
237243
case "protobuf_test_messages.editions.proto3.TestAllTypesProto3":
238244
return TestMessagesProto3Editions.class;
239245
case "protobuf_test_messages.editions.proto2.TestAllTypesProto2":

conformance/binary_json_conformance_suite.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "conformance/conformance.pb.h"
3434
#include "conformance_test.h"
3535
#include "conformance/test_protos/test_messages_edition2023.pb.h"
36+
#include "conformance/test_protos/test_messages_edition_unstable.pb.h"
3637
#include "editions/golden/test_messages_proto2_editions.pb.h"
3738
#include "editions/golden/test_messages_proto3_editions.pb.h"
3839
#include "google/protobuf/json/json.h"
@@ -51,6 +52,7 @@ using google::protobuf::Descriptor;
5152
using google::protobuf::FieldDescriptor;
5253
using google::protobuf::internal::WireFormatLite;
5354
using google::protobuf::util::NewTypeResolverForDescriptorPool;
55+
using protobuf_test_messages::edition_unstable::TestAllTypesEditionUnstable;
5456
using protobuf_test_messages::editions::TestAllTypesEdition2023;
5557
using protobuf_test_messages::proto2::TestAllTypesProto2;
5658
using protobuf_test_messages::proto3::TestAllTypesProto3;
@@ -318,6 +320,7 @@ void BinaryAndJsonConformanceSuite::RunSuiteImpl() {
318320
BinaryAndJsonConformanceSuiteImpl<TestAllTypesProto2Editions>(
319321
this, /*run_proto3_tests=*/false);
320322
RunDelimitedFieldTests();
323+
RunUnstableTests();
321324
}
322325
}
323326

@@ -374,6 +377,22 @@ void BinaryAndJsonConformanceSuite::RunDelimitedFieldTests() {
374377
R"pb([protobuf_test_messages.editions.delimited_ext] { c: 99 })pb");
375378
}
376379

380+
void BinaryAndJsonConformanceSuite::RunUnstableTests() {
381+
SetTypeUrl(GetTypeUrl(TestAllTypesEditionUnstable::GetDescriptor()));
382+
383+
RunValidProtobufTest<TestAllTypesEditionUnstable>(
384+
absl::StrCat("ValidInt32"), REQUIRED,
385+
field(1, WireFormatLite::WIRETYPE_VARINT, varint(99)),
386+
R"pb(optional_int32: 99)pb");
387+
388+
RunValidProtobufTest<TestAllTypesEditionUnstable>(
389+
absl::StrCat("ValidMap.Integer"), REQUIRED,
390+
len(8,
391+
absl::StrCat(field(1, WireFormatLite::WIRETYPE_VARINT, varint(99)),
392+
field(2, WireFormatLite::WIRETYPE_VARINT, varint(87)))),
393+
R"pb(map_int32_int32 { key: 99 value: 87 })pb");
394+
}
395+
377396
void BinaryAndJsonConformanceSuite::RunMessageSetTests() {
378397
RunValidBinaryProtobufTest<TestAllTypesProto2>(
379398
absl::StrCat("ValidMessageSetEncoding"), REQUIRED,

conformance/binary_json_conformance_suite.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class BinaryAndJsonConformanceSuite : public ConformanceTestSuite {
5757

5858
void RunDelimitedFieldTests();
5959

60+
void RunUnstableTests();
61+
6062
void RunMessageSetTests();
6163

6264
template <typename MessageType>

conformance/conformance.proto

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ message ConformanceRequest {
101101
// protobuf_test_messages.proto2.TestAllTypesProto2 or
102102
// protobuf_test_messages.editions.proto2.TestAllTypesProto2 or
103103
// protobuf_test_messages.editions.proto3.TestAllTypesProto3 or
104-
// protobuf_test_messages.editions.TestAllTypesEdition2023.
104+
// protobuf_test_messages.editions.TestAllTypesEdition2023 or
105+
// protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable.
105106
string message_type = 4;
106107

107108
// Each test is given a specific test category. Some category may need

conformance/conformance_cpp.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "absl/strings/str_cat.h"
3333
#include "conformance/conformance.pb.h"
3434
#include "conformance/test_protos/test_messages_edition2023.pb.h"
35+
#include "conformance/test_protos/test_messages_edition_unstable.pb.h"
3536
#include "editions/golden/test_messages_proto2_editions.pb.h"
3637
#include "editions/golden/test_messages_proto3_editions.pb.h"
3738
#include "google/protobuf/endian.h"
@@ -58,6 +59,7 @@ using ::google::protobuf::util::JsonStringToMessage;
5859
using ::google::protobuf::util::MessageToJsonString;
5960
using ::google::protobuf::util::NewTypeResolverForDescriptorPool;
6061
using ::google::protobuf::util::TypeResolver;
62+
using ::protobuf_test_messages::edition_unstable::TestAllTypesEditionUnstable;
6163
using ::protobuf_test_messages::editions::TestAllTypesEdition2023;
6264
using ::protobuf_test_messages::proto2::TestAllTypesProto2;
6365
using ::protobuf_test_messages::proto3::TestAllTypesProto3;
@@ -97,6 +99,7 @@ class Harness {
9799
google::protobuf::LinkMessageReflection<TestAllTypesProto2>();
98100
google::protobuf::LinkMessageReflection<TestAllTypesProto3>();
99101
google::protobuf::LinkMessageReflection<TestAllTypesEdition2023>();
102+
google::protobuf::LinkMessageReflection<TestAllTypesEditionUnstable>();
100103
google::protobuf::LinkMessageReflection<TestAllTypesProto2Editions>();
101104
google::protobuf::LinkMessageReflection<TestAllTypesProto3Editions>();
102105

conformance/conformance_objc.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#import "google/protobuf/TestMessagesProto2.pbobjc.h"
1414
#import "google/protobuf/TestMessagesProto3.pbobjc.h"
1515
#import "test_protos/TestMessagesEdition2023.pbobjc.h"
16+
#import "test_protos/TestMessagesEditionUnstable.pbobjc.h"
1617

1718
static void Die(NSString *format, ...) __dead2;
1819

@@ -65,6 +66,11 @@ static void Die(NSString *format, ...) {
6566
isEqual:@"protobuf_test_messages.editions.TestAllTypesEdition2023"]) {
6667
msgClass = [EditionsTestAllTypesEdition2023 class];
6768
registry = [EditionsTestMessagesEdition2023Root extensionRegistry];
69+
} else if ([request.messageType
70+
isEqual:
71+
@"protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable"]) {
72+
msgClass = [EditionUnstableTestAllTypesEditionUnstable class];
73+
registry = [EditionUnstableTestMessagesEditionUnstableRoot extensionRegistry];
6874
} else if ([request.messageType
6975
isEqual:@"protobuf_test_messages.editions.proto2.TestAllTypesProto2"]) {
7076
msgClass = [EditionsProto2TestAllTypesProto2 class];

conformance/conformance_php.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ function doTest($request)
6363
case 'protobuf_test_messages.editions.TestAllTypesEdition2023':
6464
$response->setSkipped('PHP doesn\'t support editions-specific features yet');
6565
return $response;
66+
case 'protobuf_test_messages.edition_unstable.TestAllTypesEditionUnstable':
67+
$response->setSkipped('PHP doesn\'t support editions-specific features yet');
68+
return $response;
6669
case '':
6770
trigger_error(
6871
'Protobuf request doesn\'t have specific payload type',

0 commit comments

Comments
 (0)