Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ TEST(CompilerErrorContextStatus, Default) {
ASSERT_TRUE(status_pb.context().Is<compilerpb::CompilerErrorGroup>());

status_pb.context().UnpackTo(&errorgroup_out);
EXPECT_EQ(errorgroup_in.DebugString(), errorgroup_out.DebugString());
EXPECT_TRUE(google::protobuf::util::MessageDifferencer::Equals(errorgroup_in, errorgroup_out));
for (int64_t i = 0; i < errorgroup_in.errors_size(); i++) {
auto error_parent_out = errorgroup_in.errors(i);
auto error_out = error_parent_out.line_col_error();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#include <gmock/gmock.h>
#include <google/protobuf/text_format.h>
#include <google/protobuf/util/message_differencer.h>
#include <gtest/gtest.h>

#include <unordered_map>
Expand Down Expand Up @@ -208,7 +209,8 @@ TEST_F(DistributedPlanTest, construction_test) {

for (const auto& [carnot_id, carnot_info] : carnot_id_to_carnot_info_map) {
CarnotInstance* carnot_instance = physical_plan->Get(carnot_id);
EXPECT_THAT(carnot_instance->carnot_info(), EqualsProto(carnot_info.DebugString()));
EXPECT_TRUE(google::protobuf::util::MessageDifferencer::Equals(carnot_instance->carnot_info(),
carnot_info));
EXPECT_THAT(carnot_instance->QueryBrokerAddress(), carnot_info.query_broker_address());
auto new_graph = std::make_shared<IR>();
SwapGraphBeingBuilt(new_graph);
Expand Down
12 changes: 9 additions & 3 deletions src/carnot/planner/docs/doc_extractor_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

#include <fstream>
#include <string>

#include <google/protobuf/text_format.h>

#include "src/carnot/planner/docs/doc_extractor.h"
#include "src/carnot/udf_exporter/udf_exporter.h"

#include <fstream>

namespace px {
namespace carnot {
namespace planner {
Expand Down Expand Up @@ -79,8 +82,11 @@ int main(int argc, char** argv) {
}
auto docs = docs_or_s.ConsumeValueOrDie();

std::string text_output;
google::protobuf::TextFormat::PrintToString(docs, &text_output);

std::ofstream output_file;
output_file.open(FLAGS_output_file);
output_file << docs.DebugString();
output_file << text_output;
output_file.close();
}
4 changes: 2 additions & 2 deletions src/common/base/status_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ TEST(Status, context_copy_tests) {
Status s2 = s1;
EXPECT_TRUE(s2.has_context());
EXPECT_EQ(s1, s2);
EXPECT_EQ(s1.context()->DebugString(), s2.context()->DebugString());
EXPECT_TRUE(google::protobuf::util::MessageDifferencer::Equals(*s1.context(), *s2.context()));
}

TEST(Status, context_vs_no_context_status) {
Expand All @@ -120,7 +120,7 @@ TEST(Status, context_vs_no_context_status) {
EXPECT_NE(s1, s2);
EXPECT_FALSE(s2.has_context());
EXPECT_EQ(s2.context(), nullptr);
EXPECT_NE(s1.ToProto().DebugString(), s2.ToProto().DebugString());
EXPECT_FALSE(google::protobuf::util::MessageDifferencer::Equals(s1.ToProto(), s2.ToProto()));
}

TEST(StatusAdapter, proto_with_context_test) {
Expand Down
12 changes: 12 additions & 0 deletions src/common/testing/protobuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <optional>
#include <ostream>
#include <string>
#include <type_traits>
#include <utility>

#include "src/common/base/logging.h"
Expand Down Expand Up @@ -109,6 +110,17 @@ inline ::testing::PolymorphicMatcher<EqualsProtoMatcher> EqualsProto(std::string
return ::testing::MakePolymorphicMatcher(EqualsProtoMatcher(std::move(text_pb)));
}

// Overload that takes a protobuf message directly.
// This avoids the need to call DebugString() which in newer protobuf versions
// adds a "goo.gle/debugonly" prefix that breaks parsing.
template <typename ProtoType,
typename = std::enable_if_t<std::is_base_of_v<google::protobuf::Message, ProtoType>>>
inline ::testing::PolymorphicMatcher<EqualsProtoMatcher> EqualsProto(const ProtoType& proto) {
std::string text_pb;
google::protobuf::TextFormat::PrintToString(proto, &text_pb);
return ::testing::MakePolymorphicMatcher(EqualsProtoMatcher(std::move(text_pb)));
}

inline ::testing::PolymorphicMatcher<PartiallyEqualsProtoMatcher> Partially(
const ::testing::PolymorphicMatcher<EqualsProtoMatcher>& matcher) {
return ::testing::MakePolymorphicMatcher(
Expand Down
12 changes: 6 additions & 6 deletions src/vizier/services/agent/pem/tracepoint_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ TEST_F(TracepointManagerTest, CreateTracepoint) {
tracepoint->set_name("test_tracepoint");

EXPECT_CALL(stirling_,
RegisterTracepoint(tracepoint_id, ::testing::Pointee(testing::proto::EqualsProto(
tracepoint->DebugString()))));
RegisterTracepoint(tracepoint_id,
::testing::Pointee(testing::proto::EqualsProto(*tracepoint))));
EXPECT_OK(tracepoint_manager_->HandleMessage(std::move(msg)));

EXPECT_CALL(stirling_, GetTracepointInfo(tracepoint_id))
Expand Down Expand Up @@ -152,8 +152,8 @@ TEST_F(TracepointManagerTest, CreateTracepointFailed) {
tracepoint->set_name("test_tracepoint");

EXPECT_CALL(stirling_,
RegisterTracepoint(tracepoint_id, ::testing::Pointee(testing::proto::EqualsProto(
tracepoint->DebugString()))));
RegisterTracepoint(tracepoint_id,
::testing::Pointee(testing::proto::EqualsProto(*tracepoint))));
EXPECT_OK(tracepoint_manager_->HandleMessage(std::move(msg)));

EXPECT_CALL(stirling_, GetTracepointInfo(tracepoint_id))
Expand Down Expand Up @@ -185,8 +185,8 @@ TEST_F(TracepointManagerTest, CreateTracepointPreconditionFailed) {
tracepoint->set_name("test_tracepoint");

EXPECT_CALL(stirling_,
RegisterTracepoint(tracepoint_id, ::testing::Pointee(testing::proto::EqualsProto(
tracepoint->DebugString()))));
RegisterTracepoint(tracepoint_id,
::testing::Pointee(testing::proto::EqualsProto(*tracepoint))));
EXPECT_OK(tracepoint_manager_->HandleMessage(std::move(msg)));

EXPECT_CALL(stirling_, GetTracepointInfo(tracepoint_id))
Expand Down
Loading