Skip to content

Commit

Permalink
Integrate from Piper for C++, Java, and Python (#10455)
Browse files Browse the repository at this point in the history
* Sync from Piper @469587494

PROTOBUF_SYNC_PIPER

* Fixing github SOT protoc builds

* Fixing typos from google

* Remove leaked util/hash reference

* Fixing bad python merge

* Fixing python C++ library order
  • Loading branch information
mkruskal-google authored Aug 24, 2022
1 parent 6e8a7cd commit a3c8e2d
Show file tree
Hide file tree
Showing 273 changed files with 3,538 additions and 9,705 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build --cxxopt=-std=c++14
build --cxxopt=-std=c++14
3 changes: 3 additions & 0 deletions cmake/abseil-cpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ set(protobuf_ABSL_USED_TARGETS
absl::base
absl::bind_front
absl::cleanup
absl::cord
absl::core_headers
absl::debugging
absl::dynamic_annotations
absl::flags
absl::flat_hash_map
absl::flat_hash_set
Expand Down
3 changes: 3 additions & 0 deletions conformance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ cc_library(
":jsoncpp",
":test_messages_proto2_proto_cc",
":test_messages_proto3_proto_cc",
"@com_google_absl//absl/status",
],
)

Expand Down Expand Up @@ -190,6 +191,8 @@ cc_binary(
"//:protobuf",
"//:test_messages_proto2_cc_proto",
"//:test_messages_proto3_cc_proto",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
],
)

Expand Down
72 changes: 36 additions & 36 deletions conformance/binary_json_conformance_suite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/type_resolver_util.h>
#include "absl/status/status.h"
#include "third_party/jsoncpp/json.h"
#include "conformance_test.h"
#include <google/protobuf/test_messages_proto2.pb.h>
#include <google/protobuf/test_messages_proto3.pb.h>
#include <google/protobuf/stubs/status.h>

namespace proto2_messages = protobuf_test_messages::proto2;

Expand Down Expand Up @@ -354,7 +354,7 @@ bool BinaryAndJsonConformanceSuite::ParseJsonResponse(
const ConformanceResponse& response,
Message* test_message) {
string binary_protobuf;
util::Status status =
absl::Status status =
JsonToBinaryString(type_resolver_.get(), type_url_,
response.json_payload(), &binary_protobuf);

Expand Down Expand Up @@ -384,7 +384,7 @@ bool BinaryAndJsonConformanceSuite::ParseResponse(
case ConformanceResponse::kProtobufPayload: {
if (requested_output != conformance::PROTOBUF) {
ReportFailure(test_name, level, request, response,
StrCat("Test was asked for ",
absl::StrCat("Test was asked for ",
WireFormatToString(requested_output),
" output but provided PROTOBUF instead.")
.c_str());
Expand All @@ -403,7 +403,7 @@ bool BinaryAndJsonConformanceSuite::ParseResponse(
case ConformanceResponse::kJsonPayload: {
if (requested_output != conformance::JSON) {
ReportFailure(test_name, level, request, response,
StrCat("Test was asked for ",
absl::StrCat("Test was asked for ",
WireFormatToString(requested_output),
" output but provided JSON instead.")
.c_str());
Expand Down Expand Up @@ -440,7 +440,7 @@ void BinaryAndJsonConformanceSuite::ExpectParseFailureForProtoWithProtoVersion (

const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
string effective_test_name = StrCat(
string effective_test_name = absl::StrCat(
setting.ConformanceLevelToString(level),
(is_proto3 ? ".Proto3" : ".Proto2"), ".ProtobufInput.", test_name);

Expand Down Expand Up @@ -571,7 +571,7 @@ void BinaryAndJsonConformanceSuite::RunValidJsonTestWithValidator(
const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
string effective_test_name =
StrCat(setting.ConformanceLevelToString(level),
absl::StrCat(setting.ConformanceLevelToString(level),
is_proto3 ? ".Proto3.JsonInput." : ".Proto2.JsonInput.",
test_name, ".Validator");

Expand Down Expand Up @@ -615,7 +615,7 @@ void BinaryAndJsonConformanceSuite::ExpectParseFailureForJson(
prototype, test_name, input_json);
const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
string effective_test_name = StrCat(
string effective_test_name = absl::StrCat(
setting.ConformanceLevelToString(level), ".Proto3.JsonInput.", test_name);

RunTest(effective_test_name, request, &response);
Expand All @@ -642,7 +642,7 @@ void BinaryAndJsonConformanceSuite::ExpectSerializeFailureForJson(
prototype, test_name, payload_message.SerializeAsString());
const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
string effective_test_name = StrCat(
string effective_test_name = absl::StrCat(
setting.ConformanceLevelToString(level), ".", test_name, ".JsonOutput");

RunTest(effective_test_name, request, &response);
Expand Down Expand Up @@ -768,10 +768,10 @@ void BinaryAndJsonConformanceSuite::TestValidDataForType(
string text = test_message->DebugString();

RunValidProtobufTest(
StrCat("ValidDataScalar", type_name, "[", i, "]"), REQUIRED,
absl::StrCat("ValidDataScalar", type_name, "[", i, "]"), REQUIRED,
proto, text, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataScalarBinary", type_name, "[", i, "]"),
absl::StrCat("ValidDataScalarBinary", type_name, "[", i, "]"),
RECOMMENDED, proto, expected_proto, is_proto3);
}

Expand Down Expand Up @@ -852,38 +852,38 @@ void BinaryAndJsonConformanceSuite::TestValidDataForType(

// Ensures both packed and unpacked data can be parsed.
RunValidProtobufTest(
StrCat("ValidDataRepeated", type_name, ".UnpackedInput"),
absl::StrCat("ValidDataRepeated", type_name, ".UnpackedInput"),
REQUIRED, default_proto_unpacked, text, is_proto3);
RunValidProtobufTest(
StrCat("ValidDataRepeated", type_name, ".PackedInput"),
absl::StrCat("ValidDataRepeated", type_name, ".PackedInput"),
REQUIRED, default_proto_packed, text, is_proto3);

// proto2 should encode as unpacked by default and proto3 should encode as
// packed by default.
string expected_proto = rep_field->is_packed()
? default_proto_packed_expected
: default_proto_unpacked_expected;
RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
RunValidBinaryProtobufTest(absl::StrCat("ValidDataRepeated", type_name,
".UnpackedInput.DefaultOutput"),
RECOMMENDED, default_proto_unpacked,
expected_proto, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
RunValidBinaryProtobufTest(absl::StrCat("ValidDataRepeated", type_name,
".PackedInput.DefaultOutput"),
RECOMMENDED, default_proto_packed,
expected_proto, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
RunValidBinaryProtobufTest(absl::StrCat("ValidDataRepeated", type_name,
".UnpackedInput.PackedOutput"),
RECOMMENDED, packed_proto_unpacked,
packed_proto_expected, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
RunValidBinaryProtobufTest(absl::StrCat("ValidDataRepeated", type_name,
".PackedInput.PackedOutput"),
RECOMMENDED, packed_proto_packed,
packed_proto_expected, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
RunValidBinaryProtobufTest(absl::StrCat("ValidDataRepeated", type_name,
".UnpackedInput.UnpackedOutput"),
RECOMMENDED, unpacked_proto_unpacked,
unpacked_proto_expected, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
RunValidBinaryProtobufTest(absl::StrCat("ValidDataRepeated", type_name,
".PackedInput.UnpackedOutput"),
RECOMMENDED, unpacked_proto_packed,
unpacked_proto_expected, is_proto3);
Expand All @@ -899,7 +899,7 @@ void BinaryAndJsonConformanceSuite::TestValidDataForType(
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();

RunValidProtobufTest(StrCat("ValidDataRepeated", type_name),
RunValidProtobufTest(absl::StrCat("ValidDataRepeated", type_name),
REQUIRED, proto, text, is_proto3);
}
}
Expand Down Expand Up @@ -975,7 +975,7 @@ void BinaryAndJsonConformanceSuite::TestValidDataForMapType(
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
RunValidProtobufTest(absl::StrCat("ValidDataMap", key_type_name,
value_type_name, ".Default"),
REQUIRED, proto, text, is_proto3);
}
Expand All @@ -988,7 +988,7 @@ void BinaryAndJsonConformanceSuite::TestValidDataForMapType(
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
RunValidProtobufTest(absl::StrCat("ValidDataMap", key_type_name,
value_type_name, ".MissingDefault"),
REQUIRED, proto, text, is_proto3);
}
Expand All @@ -1001,7 +1001,7 @@ void BinaryAndJsonConformanceSuite::TestValidDataForMapType(
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
RunValidProtobufTest(absl::StrCat("ValidDataMap", key_type_name,
value_type_name, ".NonDefault"),
REQUIRED, proto, text, is_proto3);
}
Expand All @@ -1014,7 +1014,7 @@ void BinaryAndJsonConformanceSuite::TestValidDataForMapType(
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
RunValidProtobufTest(absl::StrCat("ValidDataMap", key_type_name,
value_type_name, ".Unordered"),
REQUIRED, proto, text, is_proto3);
}
Expand All @@ -1031,7 +1031,7 @@ void BinaryAndJsonConformanceSuite::TestValidDataForMapType(
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(proto2);
string text = test_message->DebugString();
RunValidProtobufTest(StrCat("ValidDataMap", key_type_name,
RunValidProtobufTest(absl::StrCat("ValidDataMap", key_type_name,
value_type_name, ".DuplicateKey"),
REQUIRED, proto, text, is_proto3);
}
Expand All @@ -1045,7 +1045,7 @@ void BinaryAndJsonConformanceSuite::TestValidDataForMapType(
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(
StrCat("ValidDataMap", key_type_name, value_type_name,
absl::StrCat("ValidDataMap", key_type_name, value_type_name,
".DuplicateKeyInMapEntry"),
REQUIRED, proto, text, is_proto3);
}
Expand All @@ -1059,7 +1059,7 @@ void BinaryAndJsonConformanceSuite::TestValidDataForMapType(
test_message->MergeFromString(proto);
string text = test_message->DebugString();
RunValidProtobufTest(
StrCat("ValidDataMap", key_type_name, value_type_name,
absl::StrCat("ValidDataMap", key_type_name, value_type_name,
".DuplicateValueInMapEntry"),
REQUIRED, proto, text, is_proto3);
}
Expand Down Expand Up @@ -1125,10 +1125,10 @@ void BinaryAndJsonConformanceSuite::TestValidDataForOneofType(
string text = test_message->DebugString();

RunValidProtobufTest(
StrCat("ValidDataOneof", type_name, ".DefaultValue"), REQUIRED,
absl::StrCat("ValidDataOneof", type_name, ".DefaultValue"), REQUIRED,
proto, text, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataOneofBinary", type_name, ".DefaultValue"),
absl::StrCat("ValidDataOneofBinary", type_name, ".DefaultValue"),
RECOMMENDED, proto, proto, is_proto3);
}

Expand All @@ -1140,25 +1140,25 @@ void BinaryAndJsonConformanceSuite::TestValidDataForOneofType(
string text = test_message->DebugString();

RunValidProtobufTest(
StrCat("ValidDataOneof", type_name, ".NonDefaultValue"),
absl::StrCat("ValidDataOneof", type_name, ".NonDefaultValue"),
REQUIRED, proto, text, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataOneofBinary", type_name, ".NonDefaultValue"),
absl::StrCat("ValidDataOneofBinary", type_name, ".NonDefaultValue"),
RECOMMENDED, proto, proto, is_proto3);
}

{
// Tests oneof with multiple values of the same field.
const string proto = StrCat(default_value, non_default_value);
const string proto = absl::StrCat(default_value, non_default_value);
const string expected_proto = non_default_value;
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();

RunValidProtobufTest(StrCat("ValidDataOneof", type_name,
RunValidProtobufTest(absl::StrCat("ValidDataOneof", type_name,
".MultipleValuesForSameField"),
REQUIRED, proto, text, is_proto3);
RunValidBinaryProtobufTest(StrCat("ValidDataOneofBinary", type_name,
RunValidBinaryProtobufTest(absl::StrCat("ValidDataOneofBinary", type_name,
".MultipleValuesForSameField"),
RECOMMENDED, proto, expected_proto, is_proto3);
}
Expand All @@ -1175,17 +1175,17 @@ void BinaryAndJsonConformanceSuite::TestValidDataForOneofType(
cat(tag(other_field->number(), other_wire_type),
GetDefaultValue(other_type));

const string proto = StrCat(other_value, non_default_value);
const string proto = absl::StrCat(other_value, non_default_value);
const string expected_proto = non_default_value;
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();

RunValidProtobufTest(StrCat("ValidDataOneof", type_name,
RunValidProtobufTest(absl::StrCat("ValidDataOneof", type_name,
".MultipleValuesForDifferentField"),
REQUIRED, proto, text, is_proto3);
RunValidBinaryProtobufTest(
StrCat("ValidDataOneofBinary", type_name,
absl::StrCat("ValidDataOneofBinary", type_name,
".MultipleValuesForDifferentField"),
RECOMMENDED, proto, expected_proto, is_proto3);
}
Expand Down
4 changes: 0 additions & 4 deletions conformance/conformance.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ message ConformanceRequest {
// The payload (whether protobuf of JSON) is always for a
// protobuf_test_messages.proto3.TestAllTypes proto (as defined in
// src/google/protobuf/proto3_test_messages.proto).
//
// TODO(haberman): if/when we expand the conformance tests to support proto2,
// we will want to include a field that lets the payload/response be a
// protobuf_test_messages.google.protobuf.TestAllTypes message instead.
oneof payload {
bytes protobuf_payload = 1;
string json_payload = 2;
Expand Down
Loading

0 comments on commit a3c8e2d

Please sign in to comment.