Skip to content

Commit ffeca77

Browse files
jnthntatumcopybara-github
authored andcommitted
Draft: misc fixes for running conformance tests cross compiled for windows.
PiperOrigin-RevId: 866661966
1 parent f563dfb commit ffeca77

11 files changed

Lines changed: 111 additions & 30 deletions

File tree

common/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ cc_library(
652652
"//internal:message_equality",
653653
"//internal:number",
654654
"//internal:protobuf_runtime_version",
655+
"//internal:reflection_get_message",
655656
"//internal:status_macros",
656657
"//internal:strings",
657658
"//internal:time",

common/value.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include "common/values/values.h"
5050
#include "internal/number.h"
5151
#include "internal/protobuf_runtime_version.h"
52+
#include "internal/reflection_get_message.h"
5253
#include "internal/status_macros.h"
5354
#include "internal/well_known_types.h"
5455
#include "runtime/runtime_options.h"
@@ -1580,11 +1581,12 @@ Value WrapFieldImpl(
15801581
}
15811582
if constexpr (Unsafe::value) {
15821583
return Value::WrapMessageUnsafe(
1583-
&reflection->GetMessage(*message, field), descriptor_pool,
1584-
message_factory, arena);
1584+
&cel::internal::ReflectionGetMessage(reflection, *message, field),
1585+
descriptor_pool, message_factory, arena);
15851586
} else {
1586-
return Value::WrapMessage(&reflection->GetMessage(*message, field),
1587-
descriptor_pool, message_factory, arena);
1587+
return Value::WrapMessage(
1588+
&cel::internal::ReflectionGetMessage(reflection, *message, field),
1589+
descriptor_pool, message_factory, arena);
15881590
}
15891591
case google::protobuf::FieldDescriptor::TYPE_BYTES: {
15901592
std::string scratch;

conformance/run.bzl

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ This module contains build rules for generating the conformance test targets.
1818

1919
load("@rules_cc//cc:cc_test.bzl", "cc_test")
2020

21+
_TESTS_TO_SKIP_WINDOWS = [
22+
# These tests depend on configuring a timezone database which isn't available in our windows
23+
# test environment.
24+
"timestamps/timestamp_selectors_tz/getDate",
25+
"timestamps/timestamp_selectors_tz/getDayOfMonth_name_pos",
26+
"timestamps/timestamp_selectors_tz/getDayOfMonth_name_neg",
27+
"timestamps/timestamp_selectors_tz/getDayOfYear",
28+
"timestamps/timestamp_selectors_tz/getMinutes",
29+
]
30+
2131
# Converts the list of tests to skip from the format used by the original Go test runner to a single
2232
# flag value where each test is separated by a comma. It also performs expansion, for example
2333
# `foo/bar,baz` becomes two entries which are `foo/bar` and `foo/baz`.
@@ -68,7 +78,12 @@ def _conformance_test_args(modern, optimize, recursive, select_opt, skip_check,
6878
def _conformance_test(name, data, modern, optimize, recursive, select_opt, skip_check, skip_tests, tags, dashboard):
6979
cc_test(
7080
name = _conformance_test_name(name, optimize, recursive),
71-
args = _conformance_test_args(modern, optimize, recursive, select_opt, skip_check, skip_tests, dashboard) + ["$(location " + test + ")" for test in data],
81+
args = _conformance_test_args(modern, optimize, recursive, select_opt, skip_check, skip_tests, dashboard) + ["$(location " + test + ")" for test in data] + select(
82+
{
83+
"@platforms//os:windows": ["--skip_tests={}".format(",".join(skip_tests + _TESTS_TO_SKIP_WINDOWS))],
84+
"//conditions:default": ["--skip_tests={}".format(",".join(skip_tests))],
85+
},
86+
),
7287
data = data,
7388
deps = ["//conformance:run"],
7489
tags = tags,
@@ -101,7 +116,7 @@ def gen_conformance_tests(name, data, modern = False, checked = False, select_op
101116
recursive = recursive,
102117
select_opt = select_opt,
103118
skip_check = skip_check,
104-
skip_tests = skip_tests,
119+
skip_tests = _expand_tests_to_skip(skip_tests),
105120
tags = tags,
106121
dashboard = dashboard,
107122
)

eval/public/structs/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ cc_library(
135135
"//eval/public:cel_value",
136136
"//internal:casts",
137137
"//internal:overflow",
138+
"//internal:reflection_get_message",
138139
"@com_google_absl//absl/container:flat_hash_set",
139140
"@com_google_absl//absl/status",
140141
"@com_google_absl//absl/status:statusor",

eval/public/structs/field_access_impl.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "eval/public/structs/cel_proto_wrap_util.h"
3232
#include "internal/casts.h"
3333
#include "internal/overflow.h"
34+
#include "internal/reflection_get_message.h"
3435
#include "google/protobuf/arena.h"
3536
#include "google/protobuf/map_field.h"
3637

@@ -81,7 +82,7 @@ class FieldAccessor {
8182
}
8283

8384
const Message* GetMessage() const {
84-
return static_cast<const Derived*>(this)->GetMessage();
85+
return (static_cast<const Derived*>(this)->GetMessage)();
8586
}
8687

8788
int64_t GetEnumValue() const {
@@ -142,7 +143,7 @@ class FieldAccessor {
142143
break;
143144
}
144145
case FieldDescriptor::CPPTYPE_MESSAGE: {
145-
const google::protobuf::Message* msg_value = GetMessage();
146+
const google::protobuf::Message* msg_value = (GetMessage)();
146147
return UnwrapMessageToValue(msg_value, protobuf_value_factory_, arena);
147148
}
148149
case FieldDescriptor::CPPTYPE_ENUM: {
@@ -233,7 +234,8 @@ class ScalarFieldAccessor : public FieldAccessor<ScalarFieldAccessor> {
233234
IsWrapperType(field_desc_)) {
234235
return nullptr;
235236
}
236-
return &GetReflection()->GetMessage(*msg_, field_desc_);
237+
return &cel::internal::ReflectionGetMessage(GetReflection(), *msg_,
238+
field_desc_);
237239
}
238240

239241
int64_t GetEnumValue() const {

extensions/protobuf/internal/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ cc_library(
4242
"//base:builtins",
4343
"//common:kind",
4444
"//common:memory",
45+
"//internal:reflection_get_message",
4546
"//internal:status_macros",
4647
"//runtime:runtime_options",
4748
"//runtime/internal:errors",

extensions/protobuf/internal/qualify.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "common/kind.h"
3030
#include "common/memory.h"
3131
#include "extensions/protobuf/internal/map_reflection.h"
32+
#include "internal/reflection_get_message.h"
3233
#include "internal/status_macros.h"
3334
#include "runtime/internal/errors.h"
3435
#include "runtime/runtime_options.h"
@@ -277,7 +278,8 @@ absl::Status ProtoQualifyState::ApplyFieldSpecifier(
277278
return absl::OkStatus();
278279
}
279280

280-
message_ = &reflection_->GetMessage(*message_, field_desc);
281+
message_ =
282+
&cel::internal::ReflectionGetMessage(reflection_, *message_, field_desc);
281283
descriptor_ = message_->GetDescriptor();
282284
reflection_ = message_->GetReflection();
283285
return absl::OkStatus();

internal/BUILD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ cc_library(
705705
srcs = ["json.cc"],
706706
hdrs = ["json.h"],
707707
deps = [
708+
":reflection_get_message",
708709
":status_macros",
709710
":strings",
710711
":well_known_types",
@@ -762,6 +763,7 @@ cc_library(
762763
deps = [
763764
":json",
764765
":number",
766+
":reflection_get_message",
765767
":status_macros",
766768
":well_known_types",
767769
"//common:memory",
@@ -834,3 +836,12 @@ cc_library(
834836
"@com_google_absl//absl/base:nullability",
835837
],
836838
)
839+
840+
cc_library(
841+
name = "reflection_get_message",
842+
hdrs = ["reflection_get_message.h"],
843+
deps = [
844+
"@com_google_absl//absl/base:nullability",
845+
"@com_google_protobuf//:protobuf",
846+
],
847+
)

internal/json.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include "absl/strings/string_view.h"
4343
#include "absl/types/variant.h"
4444
#include "extensions/protobuf/internal/map_reflection.h"
45+
#include "internal/reflection_get_message.h"
4546
#include "internal/status_macros.h"
4647
#include "internal/strings.h"
4748
#include "internal/well_known_types.h"
@@ -864,7 +865,7 @@ class MessageToJsonState {
864865
case FieldDescriptor::TYPE_GROUP:
865866
ABSL_FALLTHROUGH_INTENDED;
866867
case FieldDescriptor::TYPE_MESSAGE:
867-
return ToJson((reflection->GetMessage)(message, field), result);
868+
return ToJson(ReflectionGetMessage(reflection, message, field), result);
868869
case FieldDescriptor::TYPE_BYTES:
869870
BytesValueToJson(
870871
well_known_types::GetBytesField(message, field, scratch_), result);

internal/message_equality.cc

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include "extensions/protobuf/internal/map_reflection.h"
3838
#include "internal/json.h"
3939
#include "internal/number.h"
40+
#include "internal/reflection_get_message.h"
4041
#include "internal/status_macros.h"
4142
#include "internal/well_known_types.h"
4243
#include "google/protobuf/arena.h"
@@ -436,7 +437,8 @@ absl::StatusOr<EquatableValue> AsEquatableValue(
436437
return well_known_types::GetStringField(message, field, scratch);
437438
case FieldDescriptor::CPPTYPE_MESSAGE:
438439
return AsEquatableValue(
439-
reflection, message.GetReflection()->GetMessage(message, field),
440+
reflection,
441+
ReflectionGetMessage(message.GetReflection(), message, field),
440442
field->message_type(), scratch);
441443
default:
442444
return absl::InternalError(
@@ -1008,11 +1010,12 @@ class MessageEqualsState final {
10081010
Unique<Message> lhs_unpacked;
10091011
Unique<Message> rhs_unpacked;
10101012
if (lhs_field != nullptr && IsAnyField(lhs_field)) {
1011-
CEL_ASSIGN_OR_RETURN(lhs_unpacked,
1012-
well_known_types::UnpackAnyIfResolveable(
1013-
&arena_, lhs_reflection_.any_reflection,
1014-
lhs.GetReflection()->GetMessage(lhs, lhs_field),
1015-
pool_, factory_));
1013+
CEL_ASSIGN_OR_RETURN(
1014+
lhs_unpacked,
1015+
well_known_types::UnpackAnyIfResolveable(
1016+
&arena_, lhs_reflection_.any_reflection,
1017+
ReflectionGetMessage(lhs.GetReflection(), lhs, lhs_field), pool_,
1018+
factory_));
10161019
if (lhs_unpacked) {
10171020
lhs_ptr = cel::to_address(lhs_unpacked);
10181021
lhs_field = nullptr;
@@ -1027,11 +1030,12 @@ class MessageEqualsState final {
10271030
}
10281031
}
10291032
if (rhs_field != nullptr && IsAnyField(rhs_field)) {
1030-
CEL_ASSIGN_OR_RETURN(rhs_unpacked,
1031-
well_known_types::UnpackAnyIfResolveable(
1032-
&arena_, rhs_reflection_.any_reflection,
1033-
rhs.GetReflection()->GetMessage(rhs, rhs_field),
1034-
pool_, factory_));
1033+
CEL_ASSIGN_OR_RETURN(
1034+
rhs_unpacked,
1035+
well_known_types::UnpackAnyIfResolveable(
1036+
&arena_, rhs_reflection_.any_reflection,
1037+
ReflectionGetMessage(rhs.GetReflection(), rhs, rhs_field), pool_,
1038+
factory_));
10351039
if (rhs_unpacked) {
10361040
rhs_ptr = cel::to_address(rhs_unpacked);
10371041
rhs_field = nullptr;
@@ -1093,7 +1097,7 @@ class MessageEqualsState final {
10931097
const Message* absl_nullable rhs_packed = nullptr;
10941098
Unique<Message> rhs_unpacked;
10951099
if (rhs_field != nullptr && IsAnyField(rhs_field)) {
1096-
rhs_packed = &rhs.GetReflection()->GetMessage(rhs, rhs_field);
1100+
rhs_packed = &ReflectionGetMessage(rhs.GetReflection(), rhs, rhs_field);
10971101
} else if (rhs_field == nullptr && IsAny(rhs)) {
10981102
rhs_packed = &rhs;
10991103
}
@@ -1121,7 +1125,7 @@ class MessageEqualsState final {
11211125
}
11221126
const Message* absl_nonnull rhs_message =
11231127
rhs_field != nullptr
1124-
? &rhs.GetReflection()->GetMessage(rhs, rhs_field)
1128+
? &ReflectionGetMessage(rhs.GetReflection(), rhs, rhs_field)
11251129
: rhs_unpacked != nullptr ? cel::to_address(rhs_unpacked)
11261130
: &rhs;
11271131
const auto* rhs_descriptor = rhs_message->GetDescriptor();
@@ -1174,7 +1178,7 @@ class MessageEqualsState final {
11741178
const Message* absl_nullable lhs_packed = nullptr;
11751179
Unique<Message> lhs_unpacked;
11761180
if (lhs_field != nullptr && IsAnyField(lhs_field)) {
1177-
lhs_packed = &lhs.GetReflection()->GetMessage(lhs, lhs_field);
1181+
lhs_packed = &ReflectionGetMessage(lhs.GetReflection(), lhs, lhs_field);
11781182
} else if (lhs_field == nullptr && IsAny(lhs)) {
11791183
lhs_packed = &lhs;
11801184
}
@@ -1202,7 +1206,7 @@ class MessageEqualsState final {
12021206
}
12031207
const Message* absl_nonnull lhs_message =
12041208
lhs_field != nullptr
1205-
? &lhs.GetReflection()->GetMessage(lhs, lhs_field)
1209+
? &ReflectionGetMessage(lhs.GetReflection(), lhs, lhs_field)
12061210
: lhs_unpacked != nullptr ? cel::to_address(lhs_unpacked)
12071211
: &lhs;
12081212
const auto* lhs_descriptor = lhs_message->GetDescriptor();
@@ -1262,7 +1266,7 @@ class MessageEqualsState final {
12621266
const Message* absl_nullable rhs_packed = nullptr;
12631267
Unique<Message> rhs_unpacked;
12641268
if (rhs_field != nullptr && IsAnyField(rhs_field)) {
1265-
rhs_packed = &rhs.GetReflection()->GetMessage(rhs, rhs_field);
1269+
rhs_packed = &ReflectionGetMessage(rhs.GetReflection(), rhs, rhs_field);
12661270
} else if (rhs_field == nullptr && IsAny(rhs)) {
12671271
rhs_packed = &rhs;
12681272
}
@@ -1290,7 +1294,7 @@ class MessageEqualsState final {
12901294
}
12911295
const Message* absl_nonnull rhs_message =
12921296
rhs_field != nullptr
1293-
? &rhs.GetReflection()->GetMessage(rhs, rhs_field)
1297+
? &ReflectionGetMessage(rhs.GetReflection(), rhs, rhs_field)
12941298
: rhs_unpacked != nullptr ? cel::to_address(rhs_unpacked)
12951299
: &rhs;
12961300
const auto* rhs_descriptor = rhs_message->GetDescriptor();
@@ -1342,7 +1346,7 @@ class MessageEqualsState final {
13421346
const Message* absl_nullable lhs_packed = nullptr;
13431347
Unique<Message> lhs_unpacked;
13441348
if (lhs_field != nullptr && IsAnyField(lhs_field)) {
1345-
lhs_packed = &lhs.GetReflection()->GetMessage(lhs, lhs_field);
1349+
lhs_packed = &ReflectionGetMessage(lhs.GetReflection(), lhs, lhs_field);
13461350
} else if (lhs_field == nullptr && IsAny(lhs)) {
13471351
lhs_packed = &lhs;
13481352
}
@@ -1370,7 +1374,7 @@ class MessageEqualsState final {
13701374
}
13711375
const Message* absl_nonnull lhs_message =
13721376
lhs_field != nullptr
1373-
? &lhs.GetReflection()->GetMessage(lhs, lhs_field)
1377+
? &ReflectionGetMessage(lhs.GetReflection(), lhs, lhs_field)
13741378
: lhs_unpacked != nullptr ? cel::to_address(lhs_unpacked)
13751379
: &lhs;
13761380
const auto* lhs_descriptor = lhs_message->GetDescriptor();

0 commit comments

Comments
 (0)