From acd5b05e9f1ec2153574807463af0612267b6067 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Thu, 9 Aug 2018 21:21:01 -0700 Subject: Fix failing tests. 1. Fix C++ tests. * Add missing files to Makefile.am and fix distcheck in tests.sh * Remove BUILT_SOURCES from conformance/Makefile.am. * Add some missing override keyword. * Add a type cast to int64 because our StrCat() in stubs can't handle size_t. 2. Fix Java tests. * Add missing test dependency on guava in pom.xml. * Include newly referenced test data in test resources. * Manually fix map_lite_test.proto which is overwritten because it's mapped from map_test.proto in google3. * Add back "optimize_for = LITE_RUNTIME" which is still needed to keep the opensource test passing as it's still running lite tests. * Add a type cast in newBuilder() because without it the code doesn't compile with openjdk javac 1.8 (the compiler can't figure if it's the right type due to complex generic typing). 3. Fix Python tests. * Remove/replace references to . * Suppress more warnings in setup.py. * Replace incorrect header inclusion for google/protobuf/proto_api.h. * Add strings::EndsWith to google/protobuf/stubs/strutil.h because it's referenced in the updated python C extension code. * Replace proto2 with google::protobuf. The proto2 name is leaked to opensource because we removed the subsitition rule for proto2 namespace but only fixed C++ source code and forgot to update python C extension code. --- src/Makefile.am | 5 +++++ src/google/protobuf/compiler/java/java_message_lite.cc | 4 ++-- src/google/protobuf/descriptor_database.h | 2 +- src/google/protobuf/stubs/strutil.h | 9 +++++++++ src/google/protobuf/text_format.cc | 5 +++-- 5 files changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index af264a95..1aabf972 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -112,6 +112,9 @@ nobase_include_HEADERS = \ google/protobuf/message_lite.h \ google/protobuf/metadata.h \ google/protobuf/metadata_lite.h \ + google/protobuf/port.h \ + google/protobuf/port_def.inc \ + google/protobuf/port_undef.inc \ google/protobuf/reflection.h \ google/protobuf/reflection_ops.h \ google/protobuf/repeated_field.h \ @@ -690,6 +693,7 @@ COMMON_TEST_SOURCES = \ google/protobuf/test_util.cc \ google/protobuf/test_util.h \ google/protobuf/test_util.inc \ + google/protobuf/test_util2.h \ google/protobuf/testing/googletest.cc \ google/protobuf/testing/googletest.h \ google/protobuf/testing/file.cc \ @@ -743,6 +747,7 @@ protobuf_test_SOURCES = \ google/protobuf/proto3_arena_lite_unittest.cc \ google/protobuf/proto3_arena_unittest.cc \ google/protobuf/proto3_lite_unittest.cc \ + google/protobuf/proto3_lite_unittest.inc \ google/protobuf/reflection_ops_unittest.cc \ google/protobuf/repeated_field_reflection_unittest.cc \ google/protobuf/repeated_field_unittest.cc \ diff --git a/src/google/protobuf/compiler/java/java_message_lite.cc b/src/google/protobuf/compiler/java/java_message_lite.cc index d2cc5f95..85a7453d 100644 --- a/src/google/protobuf/compiler/java/java_message_lite.cc +++ b/src/google/protobuf/compiler/java/java_message_lite.cc @@ -737,10 +737,10 @@ void ImmutableMessageLiteGenerator::GenerateSerializeOneExtensionRange( void ImmutableMessageLiteGenerator::GenerateBuilder(io::Printer* printer) { printer->Print( "public static Builder newBuilder() {\n" - " return DEFAULT_INSTANCE.createBuilder();\n" + " return (Builder) DEFAULT_INSTANCE.createBuilder();\n" "}\n" "public static Builder newBuilder($classname$ prototype) {\n" - " return DEFAULT_INSTANCE.createBuilder(prototype);\n" + " return (Builder) DEFAULT_INSTANCE.createBuilder(prototype);\n" "}\n" "\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); diff --git a/src/google/protobuf/descriptor_database.h b/src/google/protobuf/descriptor_database.h index 15ed8c64..0a87a147 100644 --- a/src/google/protobuf/descriptor_database.h +++ b/src/google/protobuf/descriptor_database.h @@ -164,7 +164,7 @@ class LIBPROTOBUF_EXPORT SimpleDescriptorDatabase : public DescriptorDatabase { bool FindAllExtensionNumbers(const string& extendee_type, std::vector* output) override; - bool FindAllFileNames(std::vector* output); + bool FindAllFileNames(std::vector* output) override; private: // So that it can use DescriptorIndex. diff --git a/src/google/protobuf/stubs/strutil.h b/src/google/protobuf/stubs/strutil.h index d6bcbc32..ec5512d6 100644 --- a/src/google/protobuf/stubs/strutil.h +++ b/src/google/protobuf/stubs/strutil.h @@ -913,6 +913,15 @@ LIBPROTOBUF_EXPORT void CleanStringLineEndings(const string& src, string* dst, LIBPROTOBUF_EXPORT void CleanStringLineEndings(string* str, bool auto_end_last_line); +namespace strings { +inline bool EndsWith(StringPiece text, StringPiece suffix) { + return suffix.empty() || + (text.size() >= suffix.size() && + memcmp(text.data() + (text.size() - suffix.size()), suffix.data(), + suffix.size()) == 0); +} +} // namespace strings + } // namespace protobuf } // namespace google diff --git a/src/google/protobuf/text_format.cc b/src/google/protobuf/text_format.cc index 09267be1..93c24b23 100644 --- a/src/google/protobuf/text_format.cc +++ b/src/google/protobuf/text_format.cc @@ -1356,8 +1356,9 @@ bool CheckParseInputSize(StringPiece input, io::ErrorCollector* error_collector) { if (input.size() > INT_MAX) { error_collector->AddError( - -1, 0, StrCat("Input size too large: ", input.size(), " bytes", - " > ", INT_MAX, " bytes.")); + -1, 0, StrCat("Input size too large: ", + static_cast(input.size()), " bytes", + " > ", INT_MAX, " bytes.")); return false; } return true; -- cgit v1.2.3