Skip to content

Commit d167dd0

Browse files
Rachel Goldfingerkarenwuz
authored andcommitted
Add conformance test for edition unstable
PiperOrigin-RevId: 850054867
1 parent 94c7f73 commit d167dd0

27 files changed

+312
-8
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
@@ -139,6 +139,7 @@ cc_library(
139139
"//:test_messages_proto2_cc_proto",
140140
"//:test_messages_proto3_cc_proto",
141141
"//conformance/test_protos:test_messages_edition2023_cc_proto",
142+
"//conformance/test_protos:test_messages_edition_unstable_cc_proto",
142143
"//editions:test_messages_proto2_editions_cc_proto",
143144
"//editions:test_messages_proto3_editions_cc_proto",
144145
"//src/google/protobuf",
@@ -167,6 +168,7 @@ cc_library(
167168
"//:test_messages_proto2_cc_proto",
168169
"//:test_messages_proto3_cc_proto",
169170
"//conformance/test_protos:test_messages_edition2023_cc_proto",
171+
"//conformance/test_protos:test_messages_edition_unstable_cc_proto",
170172
"//editions:test_messages_proto2_editions_cc_proto",
171173
"//editions:test_messages_proto3_editions_cc_proto",
172174
"//src/google/protobuf",
@@ -250,6 +252,7 @@ cc_test(
250252
"//:test_messages_proto2_cc_proto",
251253
"//:test_messages_proto3_cc_proto",
252254
"//conformance/test_protos:test_messages_edition2023_cc_proto",
255+
"//conformance/test_protos:test_messages_edition_unstable_cc_proto",
253256
"//editions:test_messages_proto2_editions_cc_proto",
254257
"//editions:test_messages_proto3_editions_cc_proto",
255258
"@googletest//:gtest",
@@ -449,6 +452,7 @@ cc_binary(
449452
"//:type_cc_proto",
450453
"//:wrappers_cc_proto",
451454
"//conformance/test_protos:test_messages_edition2023_cc_proto",
455+
"//conformance/test_protos:test_messages_edition_unstable_cc_proto",
452456
"//editions:test_messages_proto2_editions_cc_proto",
453457
"//editions:test_messages_proto3_editions_cc_proto",
454458
"//src/google/protobuf",
@@ -481,6 +485,7 @@ java_binary(
481485
"//:test_messages_proto2_java_proto",
482486
"//:test_messages_proto3_java_proto",
483487
"//conformance/test_protos:test_messages_edition2023_java_proto",
488+
"//conformance/test_protos:test_messages_edition_unstable_java_proto",
484489
"//editions:test_messages_proto2_editions_java_proto",
485490
"//editions:test_messages_proto3_editions_java_proto",
486491
],
@@ -501,6 +506,7 @@ java_binary(
501506
"//:test_messages_proto2_java_proto_lite",
502507
"//:test_messages_proto3_java_proto_lite",
503508
"//conformance/test_protos:test_messages_edition2023_java_proto_lite",
509+
"//conformance/test_protos:test_messages_edition_unstable_java_proto_lite",
504510
"//editions:test_messages_proto2_editions_java_proto_lite",
505511
"//editions:test_messages_proto3_editions_java_proto_lite",
506512
],
@@ -520,6 +526,7 @@ py_binary(
520526
":conformance_py_proto",
521527
"//:protobuf_python",
522528
"//conformance/test_protos:test_messages_edition2023_py_pb2",
529+
"//conformance/test_protos:test_messages_edition_unstable_py_pb2",
523530
"//editions:test_messages_proto2_editions_py_pb2",
524531
"//editions:test_messages_proto3_editions_py_pb2",
525532
"//python:_message", # Make upb visible if we need it.
@@ -581,6 +588,7 @@ inline_sh_binary(
581588
visibility = ["//csharp:__subpackages__"],
582589
deps = [
583590
"//conformance/test_protos:test_messages_edition2023_csharp_proto",
591+
"//conformance/test_protos:test_messages_edition_unstable_csharp_proto",
584592
"//csharp/src/Google.Protobuf.Conformance:conformance_runfiles",
585593
],
586594
)
@@ -596,6 +604,7 @@ objc_library(
596604
"//:test_messages_proto2_objc_proto",
597605
"//:test_messages_proto3_objc_proto",
598606
"//conformance/test_protos:test_messages_edition2023_objc_proto",
607+
"//conformance/test_protos:test_messages_edition_unstable_objc_proto",
599608
"//editions:test_messages_proto2_editions_objc_proto",
600609
"//editions:test_messages_proto3_editions_objc_proto",
601610
],

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

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

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