Skip to content

Commit a12bbde

Browse files
Rachel Goldfingercopybara-github
authored andcommitted
Add conformance test for edition unstable
PiperOrigin-RevId: 837221234
1 parent 1c3e2fe commit a12bbde

File tree

8 files changed

+87
-5
lines changed

8 files changed

+87
-5
lines changed

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/ruby/BUILD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ internal_ruby_proto_library(
2525
srcs = [":copied_test_messages_edition2023_proto"],
2626
)
2727

28+
internal_ruby_proto_library(
29+
name = "test_messages_edition_unstable_ruby_proto",
30+
testonly = True,
31+
srcs = [":copied_test_messages_edition_unstable_proto"],
32+
)
33+
2834
rb_binary(
2935
name = "conformance_ruby",
3036
testonly = True,
@@ -34,6 +40,7 @@ rb_binary(
3440
deps = [
3541
":conformance_ruby_proto",
3642
":test_messages_edition2023_ruby_proto",
43+
":test_messages_edition_unstable_ruby_proto",
3744
"//ruby:conformance_editions_test_ruby_proto",
3845
"//ruby:conformance_test_ruby_proto",
3946
"//ruby:protobuf",
@@ -55,3 +62,10 @@ internal_copy_files(
5562
srcs = ["//conformance/test_protos:test_messages_edition2023.proto"],
5663
strip_prefix = "conformance/test_protos",
5764
)
65+
66+
internal_copy_files(
67+
name = "copied_test_messages_edition_unstable_proto",
68+
testonly = True,
69+
srcs = ["//conformance/test_protos:test_messages_edition_unstable.proto"],
70+
strip_prefix = "conformance/test_protos",
71+
)

conformance/test_protos/BUILD

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ package(
1414
default_visibility = ["//conformance:__subpackages__"],
1515
)
1616

17-
exports_files(["test_messages_edition2023.proto"])
17+
exports_files([
18+
"test_messages_edition2023.proto",
19+
"test_messages_edition_unstable.proto",
20+
])
1821

1922
internal_csharp_proto_library(
2023
name = "test_messages_edition2023_csharp_proto",
2124
srcs = ["test_messages_edition2023.proto"],
2225
)
2326

27+
internal_csharp_proto_library(
28+
name = "test_messages_edition_unstable_csharp_proto",
29+
srcs = ["test_messages_edition_unstable.proto"],
30+
)
31+
2432
# Aliases for older monolithic conformance test protos defined elsewhere.
2533
alias(
2634
name = "test_messages_proto2_editions_proto",
@@ -52,28 +60,60 @@ proto_library(
5260
visibility = ["//visibility:public"],
5361
)
5462

63+
proto_library(
64+
name = "test_messages_edition_unstable_proto",
65+
srcs = ["test_messages_edition_unstable.proto"],
66+
visibility = ["//visibility:public"],
67+
)
68+
5569
java_lite_proto_library(
5670
name = "test_messages_edition2023_java_proto_lite",
5771
deps = [":test_messages_edition2023_proto"],
5872
)
5973

74+
java_lite_proto_library(
75+
name = "test_messages_edition_unstable_java_proto_lite",
76+
deps = [":test_messages_edition_unstable_proto"],
77+
)
78+
6079
java_proto_library(
6180
name = "test_messages_edition2023_java_proto",
6281
deps = [":test_messages_edition2023_proto"],
6382
)
6483

84+
java_proto_library(
85+
name = "test_messages_edition_unstable_java_proto",
86+
deps = [":test_messages_edition_unstable_proto"],
87+
)
88+
6589
cc_proto_library(
6690
name = "test_messages_edition2023_cc_proto",
6791
deps = [":test_messages_edition2023_proto"],
6892
)
6993

94+
cc_proto_library(
95+
name = "test_messages_edition_unstable_cc_proto",
96+
deps = [":test_messages_edition_unstable_proto"],
97+
)
98+
7099
internal_py_proto_library(
71100
name = "test_messages_edition2023_py_pb2",
72101
srcs = [":test_messages_edition2023.proto"],
73102
srcs_version = "PY2AND3",
74103
)
75104

105+
internal_py_proto_library(
106+
name = "test_messages_edition_unstable_py_pb2",
107+
srcs = [":test_messages_edition_unstable.proto"],
108+
srcs_version = "PY2AND3",
109+
)
110+
76111
internal_objc_proto_library(
77112
name = "test_messages_edition2023_objc_proto",
78113
srcs = [":test_messages_edition2023.proto"],
79114
)
115+
116+
internal_objc_proto_library(
117+
name = "test_messages_edition_unstable_objc_proto",
118+
srcs = [":test_messages_edition_unstable.proto"],
119+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Protocol Buffers - Google's data interchange format
2+
// Copyright 2024 Google Inc. All rights reserved.
3+
//
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file or at
6+
// https://developers.google.com/open-source/licenses/bsd
7+
8+
edition = "UNSTABLE";
9+
10+
package protobuf_test_messages.edition_unstable;
11+
12+
option java_package = "com.google.protobuf_test_messages.edition_unstable";

java/core/src/main/java/com/google/protobuf/Descriptors.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ static FeatureSet getEditionDefaults(Edition edition) {
120120
+ javaEditionDefaults.getMinimumEdition()
121121
+ "!");
122122
}
123-
if (edition.getNumber() > javaEditionDefaults.getMaximumEdition().getNumber()) {
123+
if (edition.getNumber() > javaEditionDefaults.getMaximumEdition().getNumber()
124+
&& edition != Edition.EDITION_UNSTABLE) {
124125
throw new IllegalArgumentException(
125126
"Edition "
126127
+ edition

python/google/protobuf/descriptor_pool.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,10 @@ def _CreateDefaultFeatures(self, edition):
738738
),
739739
)
740740
)
741-
if edition > self._edition_defaults.maximum_edition:
741+
if (
742+
edition > self._edition_defaults.maximum_edition
743+
and edition != descriptor_pb2.EDITION_UNSTABLE
744+
):
742745
raise TypeError(
743746
'Edition %s is later than the maximum supported edition %s!'
744747
% (

src/google/protobuf/compiler/code_generator.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,10 @@ void GeneratorContext::GetCompilerVersion(Version* version) const {
106106
bool CanSkipEditionCheck(absl::string_view filename) {
107107
return absl::StartsWith(filename, "google/protobuf/") ||
108108
absl::StartsWith(filename, "upb/") ||
109-
absl::StartsWith(filename, "com/google/protobuf/");
109+
absl::StartsWith(filename, "com/google/protobuf/") ||
110+
absl::StartsWith(filename, "conformance/test_protos") ||
111+
// TODO: Remove this once internal_copy_files is removed.
112+
absl::StartsWith(filename, "conformance/ruby");
110113
}
111114

112115
} // namespace compiler

upb/reflection/file_def.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const UPB_DESC(FeatureSet*)
220220
upb_FileDef_EditionName(min));
221221
return NULL;
222222
}
223-
if (edition > max) {
223+
if (edition > max && edition != UPB_DESC(EDITION_UNSTABLE)) {
224224
_upb_DefBuilder_Errf(ctx,
225225
"Edition %s is later than the maximum edition %s "
226226
"given in the defaults",

0 commit comments

Comments
 (0)