8000 Fix silent failure of `rb_test` rules to run test (#21733) · protocolbuffers/protobuf@0cf5489 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cf5489

Browse files
JasonLunnshaod2
authored andcommitted
Fix silent failure of rb_test rules to run test (#21733)
Additional details discussed in bazel-contrib/rules_ruby#233 and bazel-contrib/rules_ruby#223 Restoring tests revealed latent bug in JRuby's `RubyMessage#convert` that was exposed by the introduction `test_to_hash` while tests were not running; fix included. Closes #21733 COPYBARA_INTEGRATE_REVIEW=#21733 from protocolbuffers:fix_rb_test 3f8418f PiperOrigin-RevId: 758470283
1 parent d390631 commit 0cf5489

File tree

2 files changed

+75
-1
lines changed

2 files changed

+75
-1
lines changed

ruby/src/main/java/com/google/protobuf/jruby/RubyMessage.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,17 @@ private Object convert(
10891089
}
10901090
break;
10911091
case MESSAGE:
1092-
val = ((RubyMessage) value).build(context, depth + 1, recursionLimit);
1092+
RubyMessage msg;
1093+
if (value instanceof RubyHash) {
1094+
RubyClass typeClass =
1095+
(RubyClass)
1096+
((RubyDescriptor) getDescriptorForField(context, fieldDescriptor))
1097+
.msgclass(context);
1098+
msg = (RubyMessage) typeClass.newInstance(context, value);
1099+
} else {
1100+
msg = (RubyMessage) value;
1101+
}
1102+
val = msg.build(context, depth + 1, recursionLimit);
10931103
break;
10941104
case ENUM:
10951105
EnumDescriptor enumDescriptor = fieldDescriptor.getEnumType();

ruby/tests/BUILD.bazel

+64
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ internal_ruby_proto_library(
1919
rb_test(
2020
name = "implementation",
2121
srcs = ["implementation.rb"],
22+
args = [
23+
"-Iruby/lib:ruby",
24+
"ruby/tests/implementation.rb",
25+
],
2226
deps = [
2327
"//ruby:protobuf",
2428
"@protobuf_bundle",
@@ -28,6 +32,10 @@ rb_test(
2832
rb_test(
2933
name = "basic",
3034
srcs = ["basic.rb"],
35+
args = [
36+
"-Iruby/lib:ruby",
37+
"ruby/tests/basic.rb",
38+
],
3139
deps = [
3240
":common_tests",
3341
":test_ruby_protos",
@@ -39,6 +47,10 @@ rb_test(
3947
rb_test(
4048
name = "basic_proto2",
4149
srcs = ["basic_proto2.rb"],
50+
args = [
51+
"-Iruby/lib:ruby",
52+
"ruby/tests/basic_proto2.rb",
53+
],
4254
deps = [
4355
":common_tests",
4456
":test_ruby_protos",
@@ -50,6 +62,10 @@ rb_test(
5062
rb_test(
5163
name = "encode_decode_test",
5264
srcs = ["encode_decode_test.rb"],
65+
args = [
66+
"-Iruby/lib:ruby",
67+
"ruby/tests/encode_decode_test.rb",
68+
],
5369
deps = [
5470
":test_ruby_protos",
5571
"//ruby:protobuf",
@@ -60,6 +76,10 @@ rb_test(
6076
rb_test(
6177
name = "gc_test",
6278
srcs = ["gc_test.rb"],
79+
args = [
80+
"-Iruby/lib:ruby",
81+
"ruby/tests/gc_test.rb",
82+
],
6383
deps = [
6484
":test_ruby_protos",
6585
"//ruby:protobuf",
@@ -70,6 +90,10 @@ rb_test(
7090
rb_test(
7191
name = "generated_code_test",
7292
srcs = ["generated_code_test.rb"],
93+
args = [
94+
"-Iruby/lib:ruby",
95+
"ruby/tests/generated_code_test.rb",
96+
],
7397
deps = [
7498
":test_ruby_protos",
7599
"//ruby:protobuf",
@@ -80,6 +104,10 @@ rb_test(
80104
rb_test(
81105
name = "multi_level_nesting_test",
82106
srcs = ["multi_level_nesting_test.rb"],
107+
args = [
108+
"-Iruby/lib:ruby",
109+
"ruby/tests/multi_level_nesting_test.rb",
110+
],
83111
deps = [
84112
":test_ruby_protos",
85113
"//ruby:protobuf",
@@ -90,6 +118,10 @@ rb_test(
90118
rb_test(
91119
name = "object_cache_test",
92120
srcs = ["object_cache_test.rb"],
121+
args = [
122+
"-Iruby/lib:ruby",
123+
"ruby/tests/object_cache_test.rb",
124+
],
93125
deps = [
94126
":test_ruby_protos",
95127
"//ruby:protobuf",
@@ -100,6 +132,10 @@ rb_test(
100132
rb_test(
101133
name = "repeated_field_test",
102134
srcs = ["repeated_field_test.rb"],
135+
args = [
136+
"-Iruby/lib:ruby:ruby/tests",
137+
"ruby/tests/repeated_field_test.rb",
138+
],
103139
deps = [
104140
":test_ruby_protos",
105141
"//ruby:protobuf",
@@ -110,6 +146,10 @@ rb_test(
110146
rb_test(
111147
name = "ruby_version",
112148
srcs = ["ruby_version.rb"],
149+
args = [
150+
"-Iruby/lib:ruby",
151+
"ruby/tests/ruby_version.rb",
152+
],
113153
deps = [
114154
":test_ruby_protos",
115155
"//ruby:protobuf",
@@ -120,6 +160,10 @@ rb_test(
120160
rb_test(
121161
name = "stress",
122162
srcs = ["stress.rb"],
163+
args = [
164+
"-Iruby/lib:ruby:ruby/tests",
165+
"ruby/tests/stress.rb",
166+
],
123167
deps = [
124168
":test_ruby_protos",
125169
"//ruby:protobuf",
@@ -130,6 +174,10 @@ rb_test(
130174
rb_test(
131175
name = "type_errors",
132176
srcs = ["type_errors.rb"],
177+
args = [
178+
"-Iruby/lib:ruby",
179+
"ruby/tests/type_errors.rb",
180+
],
133181
deps = [
134182
":test_ruby_protos",
135183
"//ruby:protobuf",
@@ -140,6 +188,10 @@ rb_test(
140188
rb_test(
141189
name = "utf8",
142190
srcs = ["utf8.rb"],
191+
args = [
192+
"-Iruby/lib:ruby:ruby/tests",
193+
"ruby/tests/utf8.rb",
194+
],
143195
deps = [
144196
":test_ruby_protos",
145197
"//ruby:protobuf",
@@ -150,6 +202,10 @@ rb_test(
150202
rb_test(
151203
name = "well_known_types_test",
152204
srcs = ["well_known_types_test.rb"],
205+
args = [
206+
"-Iruby/lib:ruby",
207+
"ruby/tests/well_known_types_test.rb",
208+
],
153209
deps = [
154210
":test_ruby_protos",
155211
"//ruby:protobuf",
@@ -160,6 +216,10 @@ rb_test(
160216
rb_test(
161217
name = "service_test",
162218
srcs = ["service_test.rb"],
219+
args = [
220+
"-Iruby/lib:ruby:ruby/tests",
221+
"ruby/tests/service_test.rb",
222+
],
163223
deps = [
164224
":test_ruby_protos",
165225
"//ruby:protobuf",
@@ -170,6 +230,10 @@ rb_test(
170230
rb_test(
171231
name = "memory_test",
172232
srcs = ["memory_test.rb"],
233+
args = [
234+
"-Iruby/lib:ruby",
235+
"ruby/tests/memory_test.rb",
236+
],
173237
deps = [
174238
":test_ruby_protos",
175239
"//ruby:protobuf",

0 commit comments

Comments
 (0)
0